How to scale each fold separately in GridSearchCV?
While training an ML model we should normalize (scale) features regarding to the training data. And then use the fitted scaler on the test data. But if using a grid search CV (5 fold) we usually provide it the training data which is already scaled. That then gets separated into folds. But How would we separately scale each of the 4-1 folds?
scl = MinMaxScaler()
scl.fit_transform(X_train)
scl.transform(X_test)
# The training data was scaled all together and
# not train and validation separately
cv = GridSearchCV(MODEL, GRID, scoring='f1', cv=5)
cv.fit(X_train, Y_train)
Please let me know if you have a suggestion how to achieve something like this.