Skip to content

Commit 063da64

Browse files
authored
DOC add a warning regarding fit_transform != fit.transform (#954)
1 parent efccc66 commit 063da64

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

imblearn/pipeline.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ class Pipeline(pipeline.Pipeline):
8181
-----
8282
See :ref:`sphx_glr_auto_examples_pipeline_plot_pipeline_classification.py`
8383
84+
.. warning::
85+
A surprising behaviour of the `imbalanced-learn` pipeline is that it
86+
breaks the `scikit-learn` contract where one expects
87+
`estimmator.fit_transform(X, y)` to be equivalent to
88+
`estimator.fit(X, y).transform(X)`.
89+
90+
The semantic of `fit_resample` is to be applied only during the fit
91+
stage. Therefore, resampling will happen when calling `fit_transform`
92+
while it will only happen on the `fit` stage when calling `fit` and
93+
`transform` separately. Practically, `fit_transform` will lead to a
94+
resampled dataset while `fit` and `transform` will not.
95+
8496
Examples
8597
--------
8698
>>> from collections import Counter

0 commit comments

Comments
 (0)