Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list all scikit-learn classifiers that support predict_proba()

Tags:

I need a list of all scikit-learn classifiers that support the predict_proba() method. Since the documentation provides no easy way of getting that information, how can get this programatically?

like image 510
Toby Avatar asked May 05 '15 14:05

Toby


People also ask

What is predict_proba in Scikit-learn?

The predict method is used to predict the actual class while predict_proba method can be used to infer the class probabilities (i.e. the probability that a particular data point falls into the underlying classes).

Which model has a predict_proba method?

Many Scikit-learn models, such as Tree-based methods, ensemble methods, kNN, and Naive Bayes have a predict_proba method; but these should really be thought of as giving scores rather than "true" probabilities.

What are the classifiers in Sklearn?

Decision Tree Classifiers/Random Forests. Naive Bayes. Linear Discriminant Analysis. Logistic Regression.

How is predict_proba calculated?

The predict_proba() returns the number of votes for each class, divided by the number of trees in the forest. Your precision is exactly 1/n_estimators. If you want to see variation at the 5th digit, you will need 10**5 = 100,000 estimators, which is excessive.


1 Answers

from sklearn.utils.testing import all_estimators  estimators = all_estimators()  for name, class_ in estimators:     if hasattr(class_, 'predict_proba'):         print(name) 

You can also use CalibratedClassifierCV to make any classifier into one that has predict_proba.

This was asked before on SO, but I can't find it, so you should be excused for the duplicate ;)

like image 84
Andreas Mueller Avatar answered Oct 25 '22 10:10

Andreas Mueller