Can a standard scikit-learn Pipeline transform the target y?
Classic MLLevel: IntermediateTarget transformations
Can a standard scikit-learn Pipeline transform the target y?
Hints
- State the task, inputs and prediction target.
- Compare with a simple baseline: assumptions, objective and independent validation.
Answer
A standard Pipeline chains transformations of X; it is not a general pipeline for transforming or resampling y. For an invertible regression-target transformation, TransformedTargetRegressor applies the transformation before fitting and the inverse to predictions. Resampling training examples is a different operation because it may change both X and y and should not run on prediction data. It requires a suitable meta-estimator or a resampling-aware pipeline, such as the one provided by imbalanced-learn.
Source and licence: scikit-learn developers — Official FAQ · BSD-3-Clause · answer: Quantoros editorial