In analogy to How to list all scikit-learn classifiers that support predict_proba() I want to retrieve a list of all classification/regression/clustering algorithms currently supported in scikit-learn.
Asked
Active
Viewed 3,694 times
7
-
possible duplicate of https://stackoverflow.com/questions/41844311/list-of-all-classification-algorithms/41853264#41853264 – Vivek Kumar Feb 10 '17 at 13:38
-
Did you read my question? This is exactly what I am referring to and pointing out the difference. – dreamflasher Feb 10 '17 at 14:23
2 Answers
10
Combining How to list all scikit-learn classifiers that support predict_proba() and http://scikit-learn.org/stable/modules/classes.html#module-sklearn.base yields the solution:
from sklearn.utils.testing import all_estimators
from sklearn import base
estimators = all_estimators()
for name, class_ in estimators:
if issubclass(class_, base.ClassifierMixin):
print(name)
Or use any other base class: ClusterMixin, RegressorMixin, TransformerMixin.

Community
- 1
- 1

dreamflasher
- 1,387
- 15
- 22
4
As a more up-to-date solution, sklearn updated the module to sklearn.utils.all_estimators. Here's an example for importing all regression models:
from sklearn.utils import all_estimators
estimators = all_estimators(type_filter='regressor')
all_regs = []
for name, RegressorClass in estimators:
try:
print('Appending', name)
reg = RegressorClass()
all_regs.append(reg)
except Exception as e:
print(e)
Some of them require an init parameter (like estimator) and had to be ignored using try..except.

Fernando Wittmann
- 1,991
- 20
- 16