Issue
I am using Watson Studio and using a markdown notebook. In the notebook, I write the code:
from sklearn.tree import DecisionTreeClassifier
Tree_Loan= DecisionTreeClassifier(criterion="entropy", max_depth = 4)
Tree_Loan
and it displays
DecisionTreeClassifier(criterion='entropy', max_depth=4)
However, it should display something in the form of (this is from a different lab I've done using Skills Network Labs):
DecisionTreeClassifier(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=False, random_state=None,
splitter='best')
The best I can tell is that it is not importing the decision tree classifier. I have the same problem with svm from sklearn. Other functions in scikit-learn like train test split and k nearest neighbors work fine. A classmate says the rest of my code is correct and there is no reason for the error. What might be causing it?
Solution
It is importing the DecisionTreeClassifier
, no problem there. But by default, sklearn
prints only the parameters that were given to estimator with non-default values, from this function.
But if you want to see the "full" output, you can set the configuration of print_changed_only
to False
via sklearn._config.set_config
like so:
>>> from sklearn.tree import DecisionTreeClassifier
>>> tree = DecisionTreeClassifier(criterion="entropy", max_depth=4)
>>> # only displays the changed parameters
>>> tree
DecisionTreeClassifier(criterion='entropy', max_depth=4)
>>> from sklearn._config import get_config, set_config
>>> # default setting
>>> get_config()["print_changed_only"]
True
>>> # now changing it
>>> set_config(print_changed_only=False)
# now we get the default values, too
>>> tree
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')
Answered By - Mustafa Aydın
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.