I want to run a logistic regression using GridSearchCV
, but I want to contrast the performance when Scaling and PCA is used, so I don't want to use it in all cases.
I basically would like to include PCA and Scaling as "parameters" of the GridSearchCV
I am aware I can make a pipeline like this:
mnl = LogisticRegression(fit_intercept=True, multi_class="multinomial")
pipe = Pipeline([
('scale', StandardScaler()),
('mnl', mnl)])
params_mnl = {'mnl__solver': ['newton-cg', 'lbfgs', 'liblinear', 'sag', 'saga'],
'mnl__max_iter':[500,1000,2000,3000]}
The thing is that, in this case, the scaling would be applied in all folds, right? Is there a way to make it so it's "included" in the gridsearch?
EDIT:
I just read this answer and even though it's similar to what I want, it's not really it, because in that case the Scaler will be applied to the best estimator out of the GridSearch.
What I want to do is, for example, let's say
params_mnl = {'mnl__solver': ['newton-cg', 'lbfgs']}
I want to run the regression with Scaler+newton-cg, No Scaler+newton-cg, Scaler+lbfgs, No Scaler+lbfgs.