gpt4 book ai didi

python-3.x - scikit-learn 的 VotingClassifier 中使用的分类器是什么?

转载 作者:行者123 更新时间:2023-12-03 21:16:48 25 4
gpt4 key购买 nike

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

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

编辑:

我的意思是用于第二级模型的分类器方法。我非常清楚第一级分类器可以是 scikit-learn 支持的任何类型的分类器。

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

最佳答案

一般

VotingClassifier 不限于一种特定的方法/算法。您可以选择多种不同的算法并将它们组合成一个 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 如何“投票”时,您可以指定 voting='hard'voting='soft'。有关更多详细信息,请参阅下面的段落。

投票

多数类标签(多数/硬投票)

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.

来源/阅读更多:scikit-learn-weighted-average-probabilities-soft-voting

关于python-3.x - scikit-learn 的 VotingClassifier 中使用的分类器是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54200344/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com