scikit-learn 的 VotingClassifier 中使用的分类器是什么?

What is the classifier used in scikit-learn's VotingClassifier?

我查看了 scikit-learn 的文档,但我不清楚 VotingClassifier 背后使用的是哪种分类方法?是逻辑回归、SVM 还是某种树方法?

我对改变底层使用的分类器方法感兴趣。如果 Scikit-learn 不提供这样的选项,是否有一个 python 包可以轻松地与 scikit-learn 集成,从而提供这样的功能?

编辑:

我指的是用于second级模型的分类器方法。我完全清楚第一级分类器可以是 scikit-learn 支持的任何类型的分类器。

第二级分类器使用第一级分类器的预测作为输入。所以我的问题是——这个二级分类器使用什么方法?是逻辑回归吗?或者是其他东西?我可以更改吗?

一般

投票Class者不限于一个特定的method/algorithm。您可以选择多种不同的算法并将它们组合成一个 VotingClassifier。请参见下面的示例:

iris = datasets.load_iris()
X, y = iris.data[:, 1:3], iris.target

clf1 = LogisticRegression(...)
clf2 = RandomForestClassifier(...)
clf3 = SVC(...)

eclf = VotingClassifier(estimators=[('lr', clf1), ('rf', clf2), ('svm', clf3)], voting='hard')

在此处阅读有关用法的更多信息:VotingClassifier-Usage。 当谈到 VotingClassifier "votes" 的方式时,您可以指定 voting='hard'voting='soft'。有关更多详细信息,请参阅下面的段落。

投票

多数 Class 标签(Majority/Hard 投票)

In majority voting, the predicted class label for a particular sample is the class label that represents the majority (mode) of the class labels predicted by each individual classifier.

E.g., if the prediction for a given sample is

classifier 1 -> class 1 classifier 2 -> class 1 classifier 3 -> class 2 the VotingClassifier (with voting='hard') would classify the sample as “class 1” based on the majority class label.

来源:scikit-learn-majority-class-labels-majority-hard-voting

加权平均概率(软投票)

In contrast to majority voting (hard voting), soft voting returns the class label as argmax of the sum of predicted probabilities.

Specific weights can be assigned to each classifier via the weights parameter. When weights are provided, the predicted class probabilities for each classifier are collected, multiplied by the classifier weight, and averaged. The final class label is then derived from the class label with the highest average probability.

Source/Read 更多信息:scikit-learn-weighted-average-probabilities-soft-voting

VotingClassifier 不适合第一级分类器输出的任何元模型。 它只是通过模式(如果投票是硬的)或平均概率(如果投票是软的)来聚合第一级中每个分类器的输出。

简单来说,VotingClassifier 不会从第一级分类器中学到任何东西。它仅合并单个分类器的输出。

如果您希望元模型更加智能,请尝试使用 adaboost, gradientBoosting 模型。