@@ -113,12 +113,6 @@ def __init__(self, regressor=None, transformer=None,
113
113
self .check_inverse = check_inverse
114
114
115
115
def _fit_transformer (self , y ):
116
- """Check transformer and fit transformer.
117
-
118
- Create the default transformer, fit it and make additional inverse
119
- check on a subset (optional).
120
-
121
- """
122
116
if (self .transformer is not None and
123
117
(self .func is not None or self .inverse_func is not None )):
124
118
raise ValueError ("'transformer' and functions 'func'/"
@@ -183,20 +177,19 @@ def fit(self, X, y, sample_weight=None):
183
177
y_2d = y
184
178
self ._fit_transformer (y_2d )
185
179
186
- # transform y and convert back to 1d array if needed
187
- y_trans = self .transformer_ .transform (y_2d )
188
- # FIXME: a FunctionTransformer can return a 1D array even when validate
189
- # is set to True. Therefore, we need to check the number of dimension
190
- # first.
191
- if y_trans .ndim == 2 and y_trans .shape [1 ] == 1 :
192
- y_trans = y_trans .squeeze (axis = 1 )
193
-
194
180
if self .regressor is None :
195
181
from ..linear_model import LinearRegression
196
182
self .regressor_ = LinearRegression ()
197
183
else :
198
184
self .regressor_ = clone (self .regressor )
199
185
186
+ # transform y and convert back to 1d array if needed
187
+ y_trans = self .transformer_ .fit_transform (y_2d )
188
+ # FIXME: a FunctionTransformer can return a 1D array even when validate
189
+ # is set to True. Therefore, we need to check the number of dimension
190
+ # first.
191
+ if y_trans .ndim == 2 and y_trans .shape [1 ] == 1 :
192
+ y_trans = y_trans .squeeze (axis = 1 )
200
193
if sample_weight is None :
201
194
self .regressor_ .fit (X , y_trans )
202
195
else :
0 commit comments