【发布时间】:2017-04-26 10:56:16
【问题描述】:
在这里,我使用 scikit learn 对模型进行分类,并提供训练数据以及我在下面使用的程序。
from sklearn import tree
#Training data
#weight --- texture --- label
#150g bumpy orange
#170 " "
#140 smooth apple
#130 " "
features = [[140,1],[130,1],[150,0],[170,0]]
labels = [0,0,1,1]
clf = tree.DecisionClassifier()
clf = tree.fit(features , labels)
print (clf.predict([150 , 0]))
我们可以看到训练数据和这个程序的输出应该预测相应的水果和根据我们已经采取的数据orange = 0 and apple =1
但是在执行过程中我遇到了以下错误
C:\Users\HOME\Desktop\KIRAN\Scikit-Classifier>python fruit-classifier.py
Traceback (most recent call last):
File "fruit-classifier.py", line 14, in <module>
clf = tree.DecisionClassifier()
AttributeError: module 'sklearn.tree' has no attribute 'DecisionClassifier'
解决此问题的任何解决方案,因为我已尝试再次安装模块 numpy and scikit 但没有用。
【问题讨论】:
标签: python image python-2.7 machine-learning scikit-learn