New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to use prefitted SelectFromModel in ColumnTransformer #28928
Comments
|
I checked an indeed this is a discrepancy with the behavior of pipelines that does not attempt to clone the passed estimators prior to fitting: >>> from sklearn.datasets import load_iris
... from sklearn.linear_model import LogisticRegression
... from sklearn.pipeline import make_pipeline
... from sklearn.feature_selection import SelectFromModel
...
... iris = load_iris()
... X = pd.DataFrame(data=iris.data, columns=iris.feature_names)
... y = iris.target
...
... clf = LogisticRegression(max_iter=1000)
... clf.fit(X, y)
...
... pipe = make_pipeline(SelectFromModel(clf, prefit=True, max_features=2)).fit(X, y) |
One option that would not imply modifying the cloning behavior of We could probably do a similar thing for any meta-estimator that can be configured to operate on fitted base estimators. |
@NTSER as a short term workaround for this problem, feel free to use your own custom wrapper for freezing the base estimator as explained in: https://scikit-learn.org/stable/developers/develop.html#cloning |
Thanks.
instead of I accidentally closed the issue. Not sure if I have to close or keep it open. |
You can keep the issue open. I just change the tag because I would not consider it as a bug but rather a limitation in our API and we should improve. |
yields:
The text was updated successfully, but these errors were encountered: