Explore Courses Blog Tutorials Interview Questions
0 votes
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(),classes)


>> 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:

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.1k points)

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

For example:

>>> clf.classes_

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


Your short and optimal question helped me answer faster.

Hope this answer helps.

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

Browse Categories