@@ -146,7 +146,6 @@ def __init__(self, steps, *, memory=None, verbose=False):
146146 self .steps = steps
147147 self .memory = memory
148148 self .verbose = verbose
149- self ._validate_steps ()
150149
151150 def get_params (self , deep = True ):
152151 """Get parameters for this estimator.
@@ -202,14 +201,25 @@ def _validate_steps(self):
202201 for t in transformers :
203202 if t is None or t == "passthrough" :
204203 continue
204+ < << << << HEAD
205205 if (not hasattr (t , "fit_transform" ) and
206206 (not hasattr (t , "fit" ) and hasattr (t , "transform" ))):
207+ raise TypeError ("All intermediate steps should be "
208+ "transformers and implement fit and "
209+ "transform, fit_transform or be the string "
210+ "'passthrough'. '%s' (type %s) doesn't"
211+ % (t , type (t )))
212+ == == == =
213+ if not (hasattr (t , "fit" ) or hasattr (t , "fit_transform" )) or not hasattr (
214+ t , "transform"
215+ ):
207216 raise TypeError (
208217 "All intermediate steps should be "
209- "transform, fit_transform or be the string "
210- "'passthrough'. '%s' (type %s) doesn't "
211- % (t , type (t ))
218+ "transformers and implement fit and transform "
219+ "or be the string 'passthrough' "
220+ "'%s' (type %s) doesn't" % (t , type (t ))
212221 )
222+ > >> >> >> parent of 3 b294b20d ... [fix ]allow - when - only - fit - transform
213223
214224 # We allow last estimator to be None as an identity transformation
215225 if (
@@ -218,10 +228,16 @@ def _validate_steps(self):
218228 and not hasattr (estimator , "fit" )
219229 ):
220230 raise TypeError (
231+ << << << < HEAD
221232 "Last step of Pipeline should implement fit, "
222233 "fit_transform or be the string 'passthrough'. "
234+ "'%s' (type %s) doesn't" % (estimator , type (estimator )))
235+ == == == =
236+ "Last step of Pipeline should implement fit "
237+ "or be the string 'passthrough'. "
223238 "'%s' (type %s) doesn't" % (estimator , type (estimator ))
224239 )
240+ >> >> >> > parent of 3 b294b20d ... [fix ]allow - when - only - fit - transform
225241
226242 def _iter (self , with_final = True , filter_passthrough = True ):
227243 """
0 commit comments