且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何知道在 Scikit-learn 中的 predict_proba 的返回数组中表示哪些类

更新时间:2023-12-02 15:05:10

预测结果属于类的顺序如下:model.classes_

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?

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