Non-Integer Class Labels Scikit-Learn

后端 未结 2 753
醉酒成梦
醉酒成梦 2020-12-17 09:18

Quick SVM question for scikit-learn. When you train an SVM, it\'s something like

from sklearn import svm
s = svm.SVC()
s.fit(training_data, labels)
         


        
2条回答
  •  时光说笑
    2020-12-17 09:37

    The recent version of sklearn is able to use string as the labels. For example:

    from sklearn.svm import SVC
    clf = SVC()
    x = [[1,2,3], [4,5,6]]
    y = ['dog', 'cat']
    clf.fit(x,y)
    
    yhat = clf.predict([[1,2,5]])
    print yhat[0]
    

提交回复
热议问题