@@ -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,12 @@ def _validate_steps(self):
202201 for t in transformers :
203202 if t is None or t == "passthrough" :
204203 continue
205- if (not hasattr (t , "fit_transform" ) and
206- (not hasattr (t , "fit" ) and hasattr (t , "transform" ))):
207- raise TypeError (
208- "All intermediate steps should be "
209- "transform, fit_transform or be the string "
210- "'passthrough'. '%s' (type %s) doesn't"
211- % (t , type (t ))
212- )
204+ if (not (hasattr (t , "fit" ) or hasattr (t , "fit_transform" )) or not
205+ hasattr (t , "transform" )):
206+ raise TypeError ("All intermediate steps should be "
207+ "transformers and implement fit and transform "
208+ "or be the string 'passthrough' "
209+ "'%s' (type %s) doesn't" % (t , type (t )))
213210
214211 # We allow last estimator to be None as an identity transformation
215212 if (
@@ -218,10 +215,9 @@ def _validate_steps(self):
218215 and not hasattr (estimator , "fit" )
219216 ):
220217 raise TypeError (
221- "Last step of Pipeline should implement fit, "
222- "fit_transform or be the string 'passthrough'. "
223- "'%s' (type %s) doesn't" % (estimator , type (estimator ))
224- )
218+ "Last step of Pipeline should implement fit "
219+ "or be the string 'passthrough'. "
220+ "'%s' (type %s) doesn't" % (estimator , type (estimator )))
225221
226222 def _iter (self , with_final = True , filter_passthrough = True ):
227223 """
0 commit comments