0
votes

I am curious whether the training of majority voting in scikit-learn will re-train the classifiers?

For example:

model_perceptron = CalibratedClassifierCV(Perceptron(max_iter=100,
                                                     random_state=rng),
                                          cv=3)

model_perceptron.fit(X_train, y_train)
model_svc = SVC(probability=True, gamma='auto',
                random_state=rng).fit(X_train, y_train)
model_bayes = GaussianNB().fit(X_train, y_train)
model_tree = DecisionTreeClassifier(random_state=rng).fit(X_train, y_train)
model_knn = KNeighborsClassifier(n_neighbors=1).fit(X_train, y_train)

voting_classifiers = [("perceptron", model_perceptron),
                      ("svc", model_svc),
                      ("bayes", model_bayes),
                      ("tree", model_tree),
                      ("knn", model_knn)]

model_voting = VotingClassifier(estimators=voting_classifiers).fit(
    X_train, y_train)

I have trained all these base models.

Does scikit-learn simply use that already-trained classifier that I trained and tested independently previously? Does scikit-learn's majority voting not consider a pre-trained set of classifiers as the input?

Or, does it re-train the base models inside?

1
It appears that the models are retrained: scikit-learn.org/stable/modules/generated/…. Particularly this line: "Invoking the fit method on the VotingClassifier will fit clones of those original estimators that will be stored in the class attribute self.estimators_" - jhso
@jhso it is so indeed; please post this as an answer, including the quote from the linked documentation - desertnaut
@jhso Thanks. Can you post it as an answer so that anyone who searches about can find the asnwer? - Aqee

1 Answers

0
votes

Reposted from the comments above:

It appears that the models are retrained: https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.VotingClassifier.html. I particularly noted this line:

Invoking the fit method on the VotingClassifier will fit clones of those original estimators that will be stored in the class attribute self.estimators_