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?

- 16,288
- 9
- 49
- 77

- 2,174
- 4
- 22
- 32
5 Answers
from sklearn.utils 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 ;)

- 27,470
- 8
- 62
- 74
-
Thanks! I just yesterday read about CalibratedClassifierCV and I am eager to try it out. – Toby May 06 '15 at 05:09
-
Oh, and months later, I stumbled over what might be the duplicate you had in mind: http://stackoverflow.com/questions/22737053/which-estimators-in-scikit-learn-dont-support-sparse-matrices – Toby Oct 12 '15 at 12:16
-
This is not available on 0.19 version. The documentation still refers to it http://scikit-learn.org/stable/developers/utilities.html#testing-functions but the testing function is not working. Is there any other way to know if a method is supported on all estimators (as original question)? – iblasi Oct 24 '17 at 20:39
-
2@AndreasMueller, on sklearn version '0.19.0', when `from sklearn.utils.testing import all_estimators` it raises the following error: `ImportError: No module named nose.tools` on line 49 of `/usr/local/lib/python2.7/site-packages/sklearn/utils/testing.py` – iblasi Oct 28 '17 at 15:32
-
Ups! I see that nose is another package, and after installing it (`pip install nose`) everything works. Sorry for my mistake. – iblasi Oct 28 '17 at 15:35
-
When I run this I get an error ModuleNotFoundError: No module named 'pytest' – Nic Scozzaro Apr 26 '19 at 22:58
-
We moved from nose to pytest a while ago. Use `pip install pytest` – Andreas Mueller May 07 '19 at 17:22
-
first line should be now "from sklearn.utils import all_estimators" – Volkan Yurtseven Jun 04 '22 at 06:59
-
For version >= 0.22 use: from sklearn.utils import all_estimators – Sinba Jan 20 '23 at 14:08
AdaBoostClassifier
BaggingClassifier
BayesianGaussianMixture
BernoulliNB
CalibratedClassifierCV
ComplementNB
DecisionTreeClassifier
ExtraTreeClassifier
ExtraTreesClassifier
GaussianMixture
GaussianNB
GaussianProcessClassifier
GradientBoostingClassifier
KNeighborsClassifier
LabelPropagation
LabelSpreading
LinearDiscriminantAnalysis
LogisticRegression
LogisticRegressionCV
MLPClassifier
MultinomialNB
NuSVC
QuadraticDiscriminantAnalysis
RandomForestClassifier
SGDClassifier
SVC
_BinaryGaussianProcessClassifierLaplace
_ConstantPredictor

- 649
- 5
- 13
-
1
-
3Not a perfect answer, but it is a list of predictors that support the predict_proba() – Farzad Amirjavid Jul 04 '19 at 18:19
Those who are facing module not found for all_estimators in newer version of sklearn. Kindly try the following
import sklearn
estimators = sklearn.utils.all_estimators(type_filter=None)
for name, class_ in estimators:
if hasattr(class_, 'predict_proba'):
print(name)
Output:
AdaBoostClassifier
BaggingClassifier
BayesianGaussianMixture
BernoulliNB
CalibratedClassifierCV
CategoricalNB
ClassifierChain
ComplementNB
DecisionTreeClassifier
DummyClassifier
ExtraTreeClassifier
ExtraTreesClassifier
GaussianMixture
GaussianNB
GaussianProcessClassifier
GradientBoostingClassifier
GridSearchCV
HalvingGridSearchCV
HalvingRandomSearchCV
HistGradientBoostingClassifier
KNeighborsClassifier
LabelPropagation
LabelSpreading
LinearDiscriminantAnalysis
LogisticRegression
LogisticRegressionCV
MLPClassifier
MultiOutputClassifier
MultinomialNB
NuSVC
OneVsRestClassifier
Pipeline
QuadraticDiscriminantAnalysis
RFE
RFECV
RadiusNeighborsClassifier
RandomForestClassifier
RandomizedSearchCV
SGDClassifier
SVC
SelfTrainingClassifier
StackingClassifier
VotingClassifier

- 467
- 4
- 5
If you are interested in a spesific type of estimator(say classifier), you could go with:
import sklearn estimators = sklearn.utils.all_estimators(type_filter="classifier") for name, class_ in estimators: if not hasattr(class_, 'predict_proba'): print(name)

- 425
- 3
- 15
Actual import code you can get actual import code with it (sklearn 1.0.2):
from sklearn.utils import all_estimators
estimators = all_estimators(type_filter='classifier')
for name, class_ in estimators:
module_name = str(class_).split("'")[1].split(".")[1]
class_name = class_.__name__
print(f'from sklearn.{module_name} import {class_name}')
Output
from sklearn.ensemble import AdaBoostClassifier
from sklearn.ensemble import BaggingClassifier
from sklearn.naive_bayes import BernoulliNB
from sklearn.calibration import CalibratedClassifierCV
from sklearn.naive_bayes import CategoricalNB
from sklearn.multioutput import ClassifierChain
from sklearn.naive_bayes import ComplementNB
from sklearn.tree import DecisionTreeClassifier
from sklearn.dummy import DummyClassifier
from sklearn.tree import ExtraTreeClassifier
from sklearn.ensemble import ExtraTreesClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.gaussian_process import GaussianProcessClassifier
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.ensemble import HistGradientBoostingClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.semi_supervised import LabelPropagation
from sklearn.semi_supervised import LabelSpreading
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
from sklearn.svm import LinearSVC
from sklearn.linear_model import LogisticRegression
from sklearn.linear_model import LogisticRegressionCV
from sklearn.neural_network import MLPClassifier
from sklearn.multioutput import MultiOutputClassifier
from sklearn.naive_bayes import MultinomialNB
from sklearn.neighbors import NearestCentroid
from sklearn.svm import NuSVC
from sklearn.multiclass import OneVsOneClassifier
from sklearn.multiclass import OneVsRestClassifier
from sklearn.multiclass import OutputCodeClassifier
from sklearn.linear_model import PassiveAggressiveClassifier
from sklearn.linear_model import Perceptron
from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis
from sklearn.neighbors import RadiusNeighborsClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import RidgeClassifier
from sklearn.linear_model import RidgeClassifierCV
from sklearn.linear_model import SGDClassifier
from sklearn.svm import SVC
from sklearn.ensemble import StackingClassifier
from sklearn.ensemble import VotingClassifier
List of classification estimators
from sklearn.utils import all_estimators
estimators = all_estimators(type_filter='classifier')
i = 0
for name, class_ in estimators:
print(f'{i}. {class_.__name__}')
i += 1
Output (41 estimators)
- AdaBoostClassifier
- BaggingClassifier
- BernoulliNB
- CalibratedClassifierCV
- CategoricalNB
- ClassifierChain
- ComplementNB
- DecisionTreeClassifier
- DummyClassifier
- ExtraTreeClassifier
- ExtraTreesClassifier
- GaussianNB
- GaussianProcessClassifier
- GradientBoostingClassifier
- HistGradientBoostingClassifier
- KNeighborsClassifier
- LabelPropagation
- LabelSpreading
- LinearDiscriminantAnalysis
- LinearSVC
- LogisticRegression
- LogisticRegressionCV
- MLPClassifier
- MultiOutputClassifier
- MultinomialNB
- NearestCentroid
- NuSVC
- OneVsOneClassifier
- OneVsRestClassifier
- OutputCodeClassifier
- PassiveAggressiveClassifier
- Perceptron
- QuadraticDiscriminantAnalysis
- RadiusNeighborsClassifier
- RandomForestClassifier
- RidgeClassifier
- RidgeClassifierCV
- SGDClassifier
- SVC
- StackingClassifier
- VotingClassifier

- 314
- 3
- 12