I made a short Jupyter notebook to go with my question regarding the TransformedTargetRegressor.
I wanted to put a transformer inside a pipeline to play with a parameter grid but the scores didn't match.
...
model = linear_model.LinearRegression()
lg_tr = preprocessing.FunctionTransformer(func=np.log, inverse_func=np.exp, check_inverse=True)
y_log = lg_tr.transform(y)
score_0 = model.fit(X, y_log).score(X, y_log)
...
model = compose.TransformedTargetRegressor(func=np.log, inverse_func=np.exp, check_inverse=True,
regressor=linear_model.LinearRegression())
score_1 = model.fit(X, y).score(X, y)
The score_0
value is correct. Why is the one from score_1
not?
I don't have problem with the prediction that works fine, only the score.
Did I miss something?
Thank you =)