From 3b294b20d405d25e5c6725373ca9654276c66e7c Mon Sep 17 00:00:00 2001 From: cathelineparisot Date: Mon, 10 Jan 2022 01:29:52 +0100 Subject: [PATCH 1/4] [fix]allow-when-only-fit-transform --- sklearn/pipeline.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sklearn/pipeline.py b/sklearn/pipeline.py index 794919f6942e1..bb82b80814a2c 100644 --- a/sklearn/pipeline.py +++ b/sklearn/pipeline.py @@ -146,6 +146,7 @@ def __init__(self, steps, *, memory=None, verbose=False): self.steps = steps self.memory = memory self.verbose = verbose + self._validate_steps() def get_params(self, deep=True): """Get parameters for this estimator. @@ -201,14 +202,13 @@ def _validate_steps(self): for t in transformers: if t is None or t == "passthrough": continue - if not (hasattr(t, "fit") or hasattr(t, "fit_transform")) or not hasattr( - t, "transform" - ): + if (not hasattr(t, "fit_transform") and + (not hasattr(t, "fit") and hasattr(t, "transform"))): raise TypeError( "All intermediate steps should be " - "transformers and implement fit and transform " - "or be the string 'passthrough' " - "'%s' (type %s) doesn't" % (t, type(t)) + "transform, fit_transform or be the string " + "'passthrough'. '%s' (type %s) doesn't" + % (t, type(t)) ) # We allow last estimator to be None as an identity transformation @@ -218,8 +218,8 @@ def _validate_steps(self): and not hasattr(estimator, "fit") ): raise TypeError( - "Last step of Pipeline should implement fit " - "or be the string 'passthrough'. " + "Last step of Pipeline should implement fit, " + "fit_transform or be the string 'passthrough'. " "'%s' (type %s) doesn't" % (estimator, type(estimator)) ) From 02d4f2d6e5776bd010d324faa1375f2db476a828 Mon Sep 17 00:00:00 2001 From: cathelineparisot Date: Mon, 10 Jan 2022 01:50:24 +0100 Subject: [PATCH 2/4] Try to fix linting pb --- sklearn/pipeline.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/sklearn/pipeline.py b/sklearn/pipeline.py index bb82b80814a2c..e2904428c3622 100644 --- a/sklearn/pipeline.py +++ b/sklearn/pipeline.py @@ -146,7 +146,6 @@ def __init__(self, steps, *, memory=None, verbose=False): self.steps = steps self.memory = memory self.verbose = verbose - self._validate_steps() def get_params(self, deep=True): """Get parameters for this estimator. @@ -202,14 +201,25 @@ def _validate_steps(self): for t in transformers: if t is None or t == "passthrough": continue +<<<<<<< HEAD if (not hasattr(t, "fit_transform") and (not hasattr(t, "fit") and hasattr(t, "transform"))): + raise TypeError("All intermediate steps should be " + "transformers and implement fit and " + "transform, fit_transform or be the string " + "'passthrough'. '%s' (type %s) doesn't" + % (t, type(t))) +======= + if not (hasattr(t, "fit") or hasattr(t, "fit_transform")) or not hasattr( + t, "transform" + ): raise TypeError( "All intermediate steps should be " - "transform, fit_transform or be the string " - "'passthrough'. '%s' (type %s) doesn't" - % (t, type(t)) + "transformers and implement fit and transform " + "or be the string 'passthrough' " + "'%s' (type %s) doesn't" % (t, type(t)) ) +>>>>>>> parent of 3b294b20d... [fix]allow-when-only-fit-transform # We allow last estimator to be None as an identity transformation if ( @@ -218,10 +228,16 @@ def _validate_steps(self): and not hasattr(estimator, "fit") ): raise TypeError( +<<<<<<< HEAD "Last step of Pipeline should implement fit, " "fit_transform or be the string 'passthrough'. " + "'%s' (type %s) doesn't" % (estimator, type(estimator))) +======= + "Last step of Pipeline should implement fit " + "or be the string 'passthrough'. " "'%s' (type %s) doesn't" % (estimator, type(estimator)) ) +>>>>>>> parent of 3b294b20d... [fix]allow-when-only-fit-transform def _iter(self, with_final=True, filter_passthrough=True): """ From 4046912ff1882ce6ed404f7c891cd671b74ec981 Mon Sep 17 00:00:00 2001 From: cathelineparisot Date: Mon, 10 Jan 2022 03:14:31 +0100 Subject: [PATCH 3/4] Back to the original branch because I had modified it unintentionally --- sklearn/pipeline.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sklearn/pipeline.py b/sklearn/pipeline.py index e2904428c3622..6561408e91a65 100644 --- a/sklearn/pipeline.py +++ b/sklearn/pipeline.py @@ -201,6 +201,7 @@ def _validate_steps(self): for t in transformers: if t is None or t == "passthrough": continue +<<<<<<< HEAD <<<<<<< HEAD if (not hasattr(t, "fit_transform") and (not hasattr(t, "fit") and hasattr(t, "transform"))): @@ -210,6 +211,8 @@ def _validate_steps(self): "'passthrough'. '%s' (type %s) doesn't" % (t, type(t))) ======= +======= +>>>>>>> parent of 3b294b20d... [fix]allow-when-only-fit-transform if not (hasattr(t, "fit") or hasattr(t, "fit_transform")) or not hasattr( t, "transform" ): @@ -228,11 +231,14 @@ def _validate_steps(self): and not hasattr(estimator, "fit") ): raise TypeError( +<<<<<<< HEAD <<<<<<< HEAD "Last step of Pipeline should implement fit, " "fit_transform or be the string 'passthrough'. " "'%s' (type %s) doesn't" % (estimator, type(estimator))) ======= +======= +>>>>>>> parent of 3b294b20d... [fix]allow-when-only-fit-transform "Last step of Pipeline should implement fit " "or be the string 'passthrough'. " "'%s' (type %s) doesn't" % (estimator, type(estimator)) From bf0455817cb3bed73062cb82676a0bfa3dd4e702 Mon Sep 17 00:00:00 2001 From: cathelineparisot Date: Mon, 10 Jan 2022 03:17:45 +0100 Subject: [PATCH 4/4] [build doc] fix broken image documentation --- doc/modules/manifold.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/modules/manifold.rst b/doc/modules/manifold.rst index e6e8e842fa7fc..54e052dd2d614 100644 --- a/doc/modules/manifold.rst +++ b/doc/modules/manifold.rst @@ -417,7 +417,7 @@ version, the algorithms will try to preserve the order of the distances, and hence seek for a monotonic relationship between the distances in the embedded space and the similarities/dissimilarities. -.. figure:: ../auto_examples/manifold/images/sphx_glr_plot_lle_digits_010.png +.. figure:: ../auto_examples/manifold/images/sphx_glr_plot_lle_digits_002.png :target: ../auto_examples/manifold/plot_lle_digits.html :align: center :scale: 50