-
-
Notifications
You must be signed in to change notification settings - Fork 26.4k
Description
Describe the workflow you want to enable
Allow passing trained models to VotingClassifier, and use these trained models directly for prediction, without refitting.
The current VotingClassifier requires fitting all inputted estimators on the given training data, even if these estimators have already been trained. This is inconvenient if we want to create an ensemble classifier from estimators trained with different datasets (or with different partitions of the dataset).
Describe your proposed solution
Maybe adding a new prefit parameter to VotingClassifier, allow the user to specify whether fitting is needed.
A similar solution has been implemented in #22215 for StackingClassifier and StackingRegressor
Additional context
This workflow is also mentioned in #12297, as there seems to be no update, here I am requesting it as a new feature.
This feature can be implemented at the user-level, code from stackoverflow, mors
from sklearn.ensemble import VotingClassifier
from sklearn.preprocessing import LabelEncoder
clf_list = [clf1, clf2, clf3]
eclf = VotingClassifier(estimators = [('1' ,clf1), ('2', clf2), ('3', clf3)], voting='soft')
eclf.estimators_ = clf_list
eclf.le_ = LabelEncoder().fit(y)
eclf.classes_ = seclf.le_.classes_
# Now it will work without calling fit
eclf.predict(X,y)
If this feature is approved, I can work on it.