我有分类问题,我想测试所有可用的算法来测试它们在解决问题时的表现。 如果您知道除下面列出的分类算法以外的任何分类算法,请在此处列出。
GradientBoostingClassifier()
DecisionTreeClassifier()
RandomForestClassifier()
LinearDiscriminantAnalysis()
LogisticRegression()
KNeighborsClassifier()
GaussianNB()
ExtraTreesClassifier()
BaggingClassifier()
非常感谢您的帮助。
答案 0 :(得分:8)
您可能需要查看以下问题:
How to list all scikit-learn classifiers that support predict_proba()
接受的答案显示了获取scikit中支持 predict_probas 方法的所有估算器的方法。只需迭代并打印所有名称而不检查条件,即可获得所有估算器。 (分类器,回归器,簇等)
仅对于分类器,请按如下所示进行修改,以检查实现ClassifierMixin
的所有类from sklearn.base import ClassifierMixin
from sklearn.utils.testing import all_estimators
classifiers=[est for est in all_estimators() if issubclass(est[1], ClassifierMixin)]
print(classifiers)
注意事项:
在使用之前,您应该检查各自的参考文档
答案 1 :(得分:7)
以上答案未提供分类器的完整列表,因此我在下面列出了它们
from sklearn.tree import ExtraTreeClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.svm.classes import OneClassSVM
from sklearn.neural_network.multilayer_perceptron import MLPClassifier
from sklearn.neighbors.classification import RadiusNeighborsClassifier
from sklearn.neighbors.classification import KNeighborsClassifier
from sklearn.multioutput import ClassifierChain
from sklearn.multioutput import MultiOutputClassifier
from sklearn.multiclass import OutputCodeClassifier
from sklearn.multiclass import OneVsOneClassifier
from sklearn.multiclass import OneVsRestClassifier
from sklearn.linear_model.stochastic_gradient import SGDClassifier
from sklearn.linear_model.ridge import RidgeClassifierCV
from sklearn.linear_model.ridge import RidgeClassifier
from sklearn.linear_model.passive_aggressive import PassiveAggressiveClassifier
from sklearn.gaussian_process.gpc import GaussianProcessClassifier
from sklearn.ensemble.voting_classifier import VotingClassifier
from sklearn.ensemble.weight_boosting import AdaBoostClassifier
from sklearn.ensemble.gradient_boosting import GradientBoostingClassifier
from sklearn.ensemble.bagging import BaggingClassifier
from sklearn.ensemble.forest import ExtraTreesClassifier
from sklearn.ensemble.forest import RandomForestClassifier
from sklearn.naive_bayes import BernoulliNB
from sklearn.calibration import CalibratedClassifierCV
from sklearn.naive_bayes import GaussianNB
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.naive_bayes import MultinomialNB
from sklearn.neighbors import NearestCentroid
from sklearn.svm import NuSVC
from sklearn.linear_model import Perceptron
from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis
from sklearn.svm import SVC
from sklearn.mixture import DPGMM
from sklearn.mixture import GMM
from sklearn.mixture import GaussianMixture
from sklearn.mixture import VBGMM
答案 2 :(得分:1)
答案 3 :(得分:1)
这是最新的解决方案:
from sklearn.utils import all_estimators
estimators = all_estimators(type_filter='classifier')
all_clfs = []
for name, ClassifierClass in estimators:
print('Appending', name)
try:
clf = ClassifierClass()
all_clfs.append(clf)
except Exception as e:
print('Unable to import', name)
print(e)
更新 先前的代码停止工作,因为某些估计器需要一个估计器作为init参数。因此,我用try ... except更新了代码。 Here's a colab code正常运作。