Non-Integer Class Labels Scikit-Learn Non-Integer Class Labels Scikit-Learn python python

Non-Integer Class Labels Scikit-Learn


Passing strings as classes directly is on my todo, but it is not supported in the SVMs yet.For the moment, we have the LabelEncoder that can do the book keeping for you.

[edit]This should work now out of the box[/edit]


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

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