How to incorporate pre-trained perceptrons into AdaBoostClassifier?

740 views Asked by At

I want to use sklearn.ensamble's AdaBoostClassifier for a simple binary classification task. How can I use multiple, pre-fit perceptrons as the weak classifiers in an AdaBoostClassifier?

i.e.

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")

Or, do I need to build the AdaBoost manually?

0

There are 0 answers