python - Sklearn - How to predict probability for all target labels -


i have data set target variable can have 7 different labels. each sample in training set has 1 label target variable.

for each sample, want calculate probability each of target labels. prediction consist of 7 probabilities each row.

on sklearn website read multi-label classification, doesn't seem want.

i tried following code, gives me 1 classification per sample.

from sklearn.multiclass import onevsrestclassifier clf = onevsrestclassifier(decisiontreeclassifier()) clf.fit(x_train, y_train) pred = clf.predict(x_test) 

does have advice on this? thanks!

you can removing onevsrestclassifer , using predict_proba method of decisiontreeclassifier. can following:

clf = decisiontreeclassifier() clf.fit(x_train, y_train) pred = clf.predict_proba(x_test) 

this give probability each of 7 possible classes.

hope helps!


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -