代码TypeError出错:' builtin_function_or_method'对象没有属性' __ getitem __'

时间:2018-03-03 05:25:00

标签: python

from sklearn import tree
import numpy as np

#data=vadi,samvadi,pakad
X=np.array[[8,3,[5,7,10,8,7,8,5,7,3,2,5,7]],[12,7,[5,7,8,11,12,8,10,7,5,7,3,5,2,0]],[8,1,[4,5,8,8,7,5,7,4,5,1,1,0]],[5,0,[4,5,7,8,12,8,10,8,7,5,1,1,0]],[5,0,[5,3,0,1,0,8,10,12]],[5,0,[5,3,5,8,10,8,5,3,0]],[4,11,[7,6,7,4,5,4,0]],[9,2,[9,4,2,7,7,9,5,2,0,2,-3,0]],[5,0,[-3,-1,0,5,9,10,9,5,5,7,9,3,5,3,2,0]],[7,2,[2,7,5,7,3,2,5,5,7]],[9,4,[0,2,0,4,5,11,9]],[4,11,[-1,2,4,2,7,2,-1,2,0]],[4,11,[10,7,4,5,4]],[4,11,[10,9,5,7,9,5,4,7,5,4,2,0]],[9,4,[12,11,9,11,9,6,4,6,9,11,12,13,12]],[5,0,[0,5,7,9,11,13,11,9,5,7,4,1,0]],[4,11,[-1,0,1,4,1,4,1,5,4,6,4,1,0]],[7,0,[-1,1,4,6,7,8,7,6,4,6,1,4,1,0]],[7,0,[-1,0,6,3,6,7,6,3,6,3,1,0]],[8,3,[8,7,6,3,1,3,1,0]]]

#classification
Y=np.array['asawari','asawari','bhairav','bhairav','bhairavi','bhairavi','bilawal','bilawal','kafi','kafi','kalyan','kalyan','khamaj','khamaj','marwa','marwa','pooravi','pooravi','todi','todi']

#decision tree classifier
clf=tree.DecisionTreeClassifier()

#trending data
clf=clf.fit(X,Y)

#predict
prediction=clf.predict(8,3,[5,7,10,8,7,8,5,7,3,2,5,7])

print prediction

但我收到此错误

TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'

我该如何解决这个问题?

0 个答案:

没有答案