0 votes
1 view
in Machine Learning by (19k points)

I have a number of classes and corresponding feature vectors, and when I run predict_proba() I will get this:

classes = ['one','two','three','one','three']

feature = [[0,1,1,0],[0,1,0,1],[1,1,0,0],[0,0,0,0],[0,1,1,1]]

from sklearn.naive_bayes import BernoulliNB

clf = BernoulliNB()

clf.fit(feature,classes)

clf.predict_proba([0,1,1,0])

>> array([[ 0.48247836,  0.40709111, 0.11043053]])

I would like to get what probability that corresponds to what class. On this page it says that they are ordered by arithmetical order, I'm not 100% sure of what that means: http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC.predict_proba

Does it mean that I have gone through my training examples assign the corresponding index to the first encounter of a class, or is there a command like

clf.getClasses() = ['one','two','three']

1 Answer

0 votes
by (33.2k points)

You can simply use .classes_ attributes of the classifier to recover the mapping of classes. 

For example:

>>> clf.classes_

array(['one', 'three', 'two'], 

      dtype='|S5')

Your short and optimal question helped me answer faster.

Hope this answer helps.

Learn Machine Learning with the help of this Machine Learning Tutorial.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...