简体   繁体   English

如何解决 ImportError: cannot import name 'DesicionTreeClassifier' from 'sklearn.tree' in python?

[英]How to resolve the ImportError: cannot import name 'DesicionTreeClassifier' from 'sklearn.tree' in python?

Hello there, I am new to python and I was trying out a project on jupyter notebook when I encountered an error which I couldn't resolve.您好,我是 python 的新手,当我遇到无法解决的错误时,我正在 jupyter notebook 上尝试一个项目。 I'd really appreciate some help.我真的很感激一些帮助。 This is my code:这是我的代码:

import pandas as pd
from sklearn.tree import DesicionTreeClassifier 
music_data = pd.read_csv(r'C:\python\python382\music.csv')    
X=music_data.drop(columns=['genre']) 
y=music_data['genre']    
model=DesicionTreeClassifier() 
model.fit(X,y)  
music_data

And i got the output as:我得到了 output 为:

ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_2540/2462038274.py in <module>
      1 import pandas as pd
----> 2 from sklearn.tree import DesicionTreeClassifier #using desicion tree algo here to make model[we import DesicionTree module from tree module which is imported from sklearn library]
      3 music_data = pd.read_csv(r'C:\python\python382\music.csv')
      4 
      5   ##Cleaning and segregating data

ImportError: cannot import name 'DesicionTreeClassifier' from 'sklearn.tree' (C:\python\python382\lib\site-packages\sklearn\tree\__init__.py)

Thank you.谢谢你。

You have missspelled the fumction name DesicionTreeClassifier is in reality DecisionTreeClassifier您拼错了函数名称DesicionTreeClassifier实际上是DecisionTreeClassifier

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 导入错误:无法从“sklearn.tree”导入名称“plot_tree” - ImportError: cannot import name 'plot_tree' from 'sklearn.tree' 导入错误:无法从“sklearn.tree”导入名称“tree” - Import Error: cannot import name 'tree' from 'sklearn.tree' ImportError:无法为sklearn导入名称“树” - ImportError: cannot import name 'tree' for sklearn 如何解决 python 人性化错误:ImportError cannot import name on_windows from 'humanfriendly.compat' - How to resolve python humanfriendly error: ImportError cannot import name on_windows from 'humanfriendly.compat' 来自sklearn import svm ImportError:无法导入名称lsqr - from sklearn import svm ImportError: cannot import name lsqr python 3.4“ ImportError:无法导入名称&#39;数据集&#39;”中的sklearn - sklearn in Python 3.4 “ImportError: cannot import name 'datasets'” ImportError:无法从“sklearn.inspection”导入名称“DecisionBoundaryDisplay” - ImportError: cannot import name 'DecisionBoundaryDisplay' from 'sklearn.inspection' ImportError:无法从“ sklearn.base”导入名称“ _UnstableArchMixin” - ImportError: cannot import name '_UnstableArchMixin' from 'sklearn.base' 导入错误:无法从“sklearn.model_selection”导入名称“StratifiedGroupKFold” - ImportError: cannot import name 'StratifiedGroupKFold' from 'sklearn.model_selection' ImportError:无法从“sklearn.utils.fixes”导入名称“_argmax” - ImportError: cannot import name '_argmax' from 'sklearn.utils.fixes'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM