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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.