Reputation: 1270
I'm using the DecisionTreeClassifier from scikit-learn (https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html) and getting the following warning:
FutureWarning: The sklearn.tree.tree module is deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.tree. Anything that cannot be imported from sklearn.tree is now part of the private API.
I'm a bit confused about why I'm receiving this warning as I'm not using sklearn.tree.tree
anywhere. I am using sklearn.tree
as the warning suggests but still receive this warning. In fact I'm using code of the form:
from sklearn.tree import DecisionTreeClassifier
tree = DecisionTreeClassifier(<params>)
tree.fit(training_data, training_labels)
As per the example code given in https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html but still get this warning.
I've searched the scikit documentation and online and can't find how to update my code inline with the suggestion in the warning. Does anyone know what I need to change to fix the warning?
Upvotes: 1
Views: 1864
Reputation: 33950
You can ignore the deprecation warning, it's only a warning (I wouldn't worry if your code isn't referencing that subpackage, there's probably an import somewhere under the hood inside sklearn.)
You could suppress all FutureWarnings, but then you might miss another more important one, on sklearn or another package. So I'd just ignore it for now. But if you want to:
import warnings
warnings.simplefilter('ignore', FutureWarning)
from sklearn.tree import ...
# ... Then turn warnings back on for other packages
warnings.filterwarnings('module') # or 'once', or 'always'
See the doc, or How to suppress Future warning from import?, although obviously you replace import pandas
with your own import statement.
Upvotes: 2
Reputation: 711
link of the same kind of problem
It's just a warning, for now -- until you upgrade scikit/sklearn to version 0.24, You need to update your scikit/sklearn version.
Upvotes: 1