Вы добавляете в разные ярлыки y-класса, и поэтому он не работает.См. Решение со встроенными комментариями ниже.
from sklearn import svm
x=[[0,0],[1,1],[7,8]]
y=[0,1, 2] # class labels
clf=svm.SVC() # clf=svm.SVC(gamma='scale') > gamma is auto. no need to add this.
print (clf.fit(x,y))
q = clf.predict([[2., 2.]]) # simple example to test prediction.
print ('array : %s ' % q)
# use of multiple class labes for y
x=[[0,0],[1,1]]
y=[[0,1],[0,2]] # the value 2 is to show the difference in printed output.
# add here your `for item in x:` if both arrays are 3D. `for item in y:` needs
# indentation if you do.
for item in y: # iters through the labeling list.
print (item)
clf=svm.SVC()
print (clf.fit(x,item))
q = clf.predict([[2., 2.]])
print ('array : %s ' % q)
Печатный результат:
SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,
decision_function_shape=None, degree=3, gamma='auto', kernel='rbf',
max_iter=-1, probability=False, random_state=None, shrinking=True,
tol=0.001, verbose=False)
array : [1]
[0, 1]
SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,
decision_function_shape=None, degree=3, gamma='auto', kernel='rbf',
max_iter=-1, probability=False, random_state=None, shrinking=True,
tol=0.001, verbose=False)
array : [1]
[0, 2]
SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,
decision_function_shape=None, degree=3, gamma='auto', kernel='rbf',
max_iter=-1, probability=False, random_state=None, shrinking=True,
tol=0.001, verbose=False)
array : [2]