我想将 sklearn.ensamble 的 AdaBoostClassifier 用于简单的二进制分类任务。如何使用多个预拟合感知器作为 AdaBoostClassifier 中的弱分类器?
IE
from sklearn.ensemble import AdaBoostClassifier
from sklearn import linear_model
Xa, ya, Xb, yb #training data
#train perceptrons
perceptron_A = linear_model.Perceptron(n_iter=200)
perceptron_A.fit(Xa, ya)
perceptron_B = linear_model.Perceptron(n_iter=200)
perceptron_B.fit(Xb, yb)
# Then, can I initiate an AdaBoostClassifier with existing perceptrons?
ada_real = AdaBoostClassifier(
base_estimator='Perceptron', # [perceptron_A, perceptron_B]
learning_rate=learning_rate,
n_estimators=2,
algorithm="SAMME.R")
或者,我需要手动构建 AdaBoost 吗?