8000 FIX Remove validation for FeatureUnion from __init__ (#21954) · scikit-learn/scikit-learn@faff01b · GitHub
[go: up one dir, main page]

Skip to content

Commit faff01b

Browse files
iofallarisayoshglemaitre
authored
FIX Remove validation for FeatureUnion from __init__ (#21954)
Co-authored-by: iofall <50991099+iofall@users.noreply.github.com> Co-authored-by: arisayosh <15692997+arisayosh@users.noreply.github.com> Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
1 parent fcbd4e0 commit faff01b

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

doc/whats_new/v1.1.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@ Changelog
506506
`__init__` but in `.fit()`.
507507
:pr:`21888` by :user:`iofall <iofall>` and :user:`Arisa Y. <arisayosh>`.
508508

509+
- |Fix| :class: `pipeline.FeatureUnion` does not validate hyper-parameters in
510+
`__init__`. Validation is now handled in `.fit()` and `.fit_transform()`.
511+
:pr:`21954` and :pr:`21888` by :user:`iofall <iofall>` and
512+
:user:`Arisa Y. <arisayosh>`.
513+
509514
:mod:`sklearn.preprocessing`
510515
............................
511516

sklearn/pipeline.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,6 @@ def __init__(
991991
self.n_jobs = n_jobs
992992
self.transformer_weights = transformer_weights
993993
self.verbose = verbose
994-
self._validate_transformers()
995994

996995
def get_params(self, deep=True):
997996
"""Get parameters for this estimator.

sklearn/tests/test_common.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ def test_transformers_get_feature_names_out(transformer):
419419

420420
VALIDATE_ESTIMATOR_INIT = [
421421
"ColumnTransformer",
422-
"FeatureUnion",
423422
"SGDOneClassSVM",
424423
"TheilSenRegressor",
425424
"TweedieRegressor",

sklearn/tests/test_pipeline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,9 @@ def test_feature_union():
518518

519519
# test error if some elements do not support transform
520520
msg = "All estimators should implement fit and transform.*\\bNoTrans\\b"
521+
fs = FeatureUnion([("transform", Transf()), ("no_transform", NoTrans())])
521522
with pytest.raises(TypeError, match=msg):
522-
FeatureUnion([("transform", Transf()), ("no_transform", NoTrans())])
523+
fs.fit(X)
523524

524525
# test that init accepts tuples
525526
fs = FeatureUnion((("svd", svd), ("select", select)))

0 commit comments

Comments
 (0)
0