Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jupyter lab is not printing all parameters form sklearn model

I've been using jupyter lab for several month and every time I run a sklearn model the output is like this:

from sklearn.tree import DecisionTreeClassifier
clf = DecisionTreeClassifier(criterion="entropy", max_depth = 4)
clf 

Which in the past showed this output:

DecisionTreeClassifier(ccp_alpha=0.0, class_weight=None, criterion='entropy',
                      max_depth=4, max_features=None, max_leaf_nodes=None,
                      min_impurity_decrease=0.0, min_impurity_split=None,
                      min_samples_leaf=1, min_samples_split=2,
                      min_weight_fraction_leaf=0.0, presort='deprecated',
                      random_state=None, splitter='best')

But now it only shows the params that I have actually set:

DecisionTreeClassifier(criterion='entropy', max_depth=4)

Anyone knows how to make Jupyter show the complete list of params again?

like image 434
Ezequiel Malnis Avatar asked Oct 28 '25 09:10

Ezequiel Malnis


2 Answers

It is the new feature called print_only_changed in the version 0.23. So don't roll down to previous version, just set the print_only_changed option as False.

from sklearn import set_config
from sklearn.tree import DecisionTreeClassifier

clf = DecisionTreeClassifier(criterion="entropy", max_depth = 4)

set_config(print_changed_only=True)
clf 
# DecisionTreeClassifier(criterion='entropy', max_depth=4)

set_config(print_changed_only=False)
clf 
# DecisionTreeClassifier(ccp_alpha=0.0, class_weight=None, criterion='entropy',
#                        max_depth=4, max_features=None, max_leaf_nodes=None,
#                        min_impurity_decrease=0.0, min_impurity_split=None,
#                        min_samples_leaf=1, min_samples_split=2,
#                        min_weight_fraction_leaf=0.0, presort='deprecated',
#                        random_state=None, splitter='best')
like image 76
Venkatachalam Avatar answered Oct 29 '25 22:10

Venkatachalam


Other than downgrading sklearn or editing the source code, I would say you can just use:

clf.get_params()
{'ccp_alpha': 0.0,
 'class_weight': None,
 'criterion': 'gini',
 'max_depth': None,
 'max_features': None,
 'max_leaf_nodes': None,
 'min_impurity_decrease': 0.0,
 'min_impurity_split': None,
 'min_samples_leaf': 1,
 'min_samples_split': 2,
 'min_weight_fraction_leaf': 0.0,
 'presort': 'deprecated',
 'random_state': 0,
 'splitter': 'best'}

See the documentation.

like image 23
Nicolas Gervais Avatar answered Oct 29 '25 23:10

Nicolas Gervais