【发布时间】:2019-04-11 22:26:12
【问题描述】:
让初学者 Ai 从重量和质地来区分苹果和橙子,并且标签上有语法错误 代码如下:
from sklearn import tree
## In Features 1 = Smooth, 0 = Bumpy
features = [[140, 1], [130, 1], [150, 0], [170, 0]
labels = ["apple", "apple", "orange", "orange"]
clf = tree.DecisionTreeClassifier()
clf = clf.fit(features, labels)
print clf.predict([[150, 0]])
【问题讨论】:
-
查看如何创建minimal reproducible example。
-
错误在哪一行?您可以删除哪些行但仍然出现错误?将代码减少到您仍然不明白问题所在的最低限度。
-
features的嵌套列表缺少右括号。
标签: python python-2.7 artificial-intelligence