Issue
When using a scaling function in sklearn
's Pipeline utility, is the scalar applied to the target variable during training and prediction?
In other words, is my code below, which makes use of TransformedTargetRegressor
redundant to the pipeline?
cowboy = Lasso(max_iter=10000, tol=.005)
climber = Ridge()
gymshorts = ElasticNet()
scaler = pre.RobustScaler()
models = [('xgb', xgb.XGBRegressor(**best_params)),
('ridge', make_pipeline(scaler, TransformedTargetRegressor(climber, scaler))),
('lasso', make_pipeline(scaler, TransformedTargetRegressor(cowboy, scaler))),
('enet', make_pipeline(scaler, TransformedTargetRegressor(gymshorts, scaler)))]
stack = ensemble.StackingRegressor(estimators=models)
stack = stack.fit(x_train, y_train)
Solution
In sklearn's Pipeline, the scaler isn't applied to the target. Only independent varibales (aka features) get scaled.
Thus, the use of TransformedTargetRegressor
in your code is not redundant.
Answered By - maya-ami
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.