python - 使用部分拟合的 sklearn 投票合奏

标签 python machine-learning scikit-learn ensemble-learning

有人可以告诉我如何使用部分拟合在 sklearn 中使用集成。 我不想重新训练我的模型。 或者,我们可以通过预训练模型进行集成吗? 例如,我已经看到投票分类器不支持使用部分拟合进行训练。

最佳答案

Mlxtend 库有一个 VotingEnsemble 的实现,它允许您传入预拟合模型。例如,如果您有三个预训练模型 clf1、clf2、clf3。以下代码将起作用。

from mlxtend.classifier import EnsembleVoteClassifier
import copy
eclf = EnsembleVoteClassifier(clfs=[clf1, clf2, clf3], weights=[1,1,1], fit_base_estimators=False)

 

当设置为 false 时,EnsembleVoteClassifier 中的 fit_base_estimators 参数确保分类器不会被重新拟合。

一般来说,在寻找 sci-kit learn 没有提供的更高级的技术特性时,请将 mlxtend 作为第一个引用点。

关于python - 使用部分拟合的 sklearn 投票合奏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42920148/

相关文章:

image - Scikit 学习。对无序 jpg 进行分类

python - tkinter 在打开对话框或创建窗口时打开第二个窗口

python - 确定数据存储中存在一组键中的哪一个的最佳方法

python - Pandas groupby + ifelse + 将新列添加回原始 df

python - Keras 使用什么损失函数?

python - 为什么我的smo运行这么慢?

python - dataframe .head() 的替代方案,尝试根据值打印排序字典并仅返回顶部指定结果

python - Tensorflow 中的成对排名损失函数

machine-learning - scikit learn - 如何对由多个独立值组成的单个特征进行建模

python - sklearn中roc_auc值有什么区别