让初学者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]])
你错过了一个]
from sklearn import tree
## In Features 1 = Smooth, 0 = Bumpy
features = [[140, 1], [130, 1], [150, 0], [170, 0]] # missed an ] here
labels = ["apple", "apple", "orange", "orange"]
clf = tree.DecisionTreeClassifier()
clf = clf.fit(features, labels)
print clf.predict([[150, 0]])
运行Python脚本时出现的错误是什么?
例如:
>>> x = [ ["x", y"]
给我:
SyntaxError: EOL while scanning string literal
甚至指向它失败的线。你有没有尝试谷歌搜索?我觉得你正在努力学习一些关于人工智能的东西,但是用一种语言你仍然是新来的。