numpy - Get a column of probability values for a certain class in python/sklearn -


when using randomforest in sklearn binary classification. know can use clf.predict(x) predicted class. , when use clf.predict_proba(x), array this: enter image description here

i think first column indicates probability of prediction? how can column probability of class being 1?

from randomforest.predict_proba docs:

predict_proba(x) 

predict class probabilities x.

returns:
p : [...] class probabilities of input samples. order of classes corresponds in attribute classes_.

you can @ clf.classes_ attribute, see @ index class 1 appears, , access probabilities so:

prob_class_1 = clf.predict_proba(x)[:, i]  

where i index of class 1 in clf.classes_.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -