I am using jupyter installed via Anaconda3. i cannot import DecisionTreeClassifier and getting the below error. Python version installed in Ananconda - 3.7.3.
Can someone help me here?
import pandas as pd
from sklearn import tree
music = pd.read_csv('music.csv')
X = music.drop(columns=['genre'])
y = music['genre']
modl = tree.DecisionTreeClassifier()
modl.fit(X,y)
predictions = modl.predict([[21,1],[22,0]])
predictions
Error Message:
AttributeError Traceback (most recent call last) in 1 import pandas as pd ----> 2 from sklearn import tree 3 4 music = pd.read_csv('music.csv') 5 X = music.drop(columns=['genre'])
~\\Anaconda3\\lib\\site-packages\\sklearn\\tree__init__.py in 4 """ 5 ----> 6 from .tree import DecisionTreeClassifier 7 from .tree import DecisionTreeRegressor 8 from .tree import ExtraTreeClassifier
~\\Anaconda3\\lib\\site-packages\\sklearn\\tree\\tree.py in 38 from ..utils.validation import check_is_fitted 39 ---> 40 from ._criterion import Criterion 41 from ._splitter import Splitter 42 from ._tree import DepthFirstTreeBuilder
~\\Anaconda3\\lib\\site-packages\\sklearn\\tree_splitter.pxd in init sklearn.tree._criterion()
~\\Anaconda3\\lib\\site-packages\\sklearn\\tree_tree.pxd in init sklearn.tree._splitter()
sklearn\\tree_tree.pyx in init sklearn.tree._tree()
AttributeError: type object 'sklearn.tree._tree.TreeBuilder' has no attribute ' reduce_cython '
I meet the same trouble ,and try to solve it . Finally, I find conda update scikit-learn
in anaconda prompt is useful for me. here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.