You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A common use case is to use Pipeline to transform the feature set and to wrap it with TransformedTargetRegressor to transform the response variable. But when used in combination and calling fit on the TransformedTargetRegressor object, the model internal to the Pipeline is not actually fit.
jmaddalena
changed the title
TransformedTargetRegressor with Pipeline is not fitting upon calling .fit
TransformedTargetRegressor with Pipeline is not fitting model upon calling .fit
Oct 1, 2024
Thank you, that is very helpful! May I ask why there is both an unfitted estimator (mod_pipeline.regressor) and a fitted one (mod_pipeline.regressor_) when there is not an equivalent in the Pipeline object? I imagine I'm not the only user confused by this.
The scikit-learn API enforces that the parameters passed at __init__ should not be modified. Therefore, we need to clone the object and and store it as a fitted attribute (the name is finishing with an _).
The only estimator in scikit-learn that does not follow this API is indeed Pipeline but this is a design bug instead of a feature (cf. #8157). However, solving this issue is really not trivial because we might break a lot of code. So we refrain to solve it for the moment (cf. #8350).
We thought about breaking the backward compatibility when bumping to scikit-learn 2.0 or creating a new pipeline class that follow the API and deprecate the previous one.
Describe the bug
A common use case is to use Pipeline to transform the feature set and to wrap it with TransformedTargetRegressor to transform the response variable. But when used in combination and calling fit on the TransformedTargetRegressor object, the model internal to the Pipeline is not actually fit.
Steps/Code to Reproduce
Expected Results
True
Actual Results
False
Versions
The text was updated successfully, but these errors were encountered: