Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know what classes are represented in return array from predict_proba in Scikit-learn

I'm starting off with Scikit-learn...

>>> import sklearn
>>> sklearn.__version__
'0.13.1'
>>> from sklearn import svm
>>> model = svm.SVC(probability=True)
>>> X = [[1,2,3], [2,3,4]] # feature vectors
>>> Y = ['apple', 'orange'] # classes
>>> model.fit(X, Y)
>>> model.predict_proba([1,2,3])
array([[ 0.39097541,  0.60902459]])

How do I know which class is supposed to be which?

like image 571
Alex Avatar asked Jun 05 '13 10:06

Alex


1 Answers

The prediction results belong to the classes in this order: model.classes_

like image 149
Bilal Dadanlar Avatar answered Sep 21 '22 04:09

Bilal Dadanlar