How to perform standardizing on the data in GridSearchCV?
Here is the code. I have no idea on how to do it.
import dataset
import warnings
warnings.filterwarnings("ignore")import pandas as pd
dataset = pd.read_excel('../dataset/dataset_experiment1.xlsx')
X = dataset.iloc[:,1:-1].values
y = dataset.iloc[:,66].valuesfrom sklearn.model_selection import GridSearchCV
#from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
stdizer = StandardScaler()print('===Grid Search===')print('logistic regression')
model = LogisticRegression()
parameter_grid = {'solver': ['newton-cg', 'lbfgs', 'liblinear', 'sag', 'saga']}
grid_search = GridSearchCV(model, param_grid=parameter_grid, cv=kfold, scoring = scoring3)
grid_search.fit(X, y)
print('Best score: {}'.format(grid_search.best_score_))
print('Best parameters: {}'.format(grid_search.best_params_))
print('\n')
Update This is what I try to run but get the error:
print('logistic regression')
model = LogisticRegression()
pipeline = Pipeline([('scale', StandardScaler()), ('clf', model)])
parameter_grid = {'solver': ['newton-cg', 'lbfgs', 'liblinear', 'sag', 'saga']}
grid_search = GridSearchCV(pipeline, param_grid=parameter_grid, cv=kfold, scoring = scoring3)
grid_search.fit(X, y)
print('Best score: {}'.format(grid_search.best_score_))
print('Best parameters: {}'.format(grid_search.best_params_))
print('\n')