File tree 2 files changed +11
-0
lines changed
2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,15 @@ def _final_estimator(self):
244
244
estimator = self .steps [- 1 ][1 ]
245
245
return 'passthrough' if estimator is None else estimator
246
246
247
+ @property
248
+ def _final_non_passthrough_estimator (self ):
249
+ final_estimator = None
250
+ for name , est in reversed (self .steps ):
251
+ if est not in [None , 'passthrough' ]:
252
+ final_estimator = est
253
+ break
254
+ return final_estimator
255
+
247
256
def _log_message (self , step_idx ):
248
257
if not self .verbose :
249
258
return None
Original file line number Diff line number Diff line change @@ -699,6 +699,7 @@ def make():
699
699
assert_array_equal ([[exp ]], pipeline .fit_transform (X , y ))
700
700
assert_array_equal ([exp ], pipeline .fit (X ).predict (X ))
701
701
assert_array_equal (X , pipeline .inverse_transform ([[exp ]]))
702
+ assert pipeline ._final_non_passthrough_estimator is mult5
702
703
703
704
pipeline = make ()
704
705
pipeline .set_params (last = passthrough )
@@ -707,6 +708,7 @@ def make():
707
708
assert_array_equal ([[exp ]], pipeline .fit (X , y ).transform (X ))
708
709
assert_array_equal ([[exp ]], pipeline .fit_transform (X , y ))
709
710
assert_array_equal (
5545
X , pipeline .inverse_transform ([[exp ]]))
711
+ assert pipeline ._final_non_passthrough_estimator is mult3
710
712
assert_raise_message (AttributeError ,
711
713
"'str' object has no attribute 'predict'" ,
712
714
getattr , pipeline , 'predict' )
You can’t perform that action at this time.
0 commit comments