I've seen some experiments using two different StandardScaler as follows:
scaler_1 = StandardScaler().fit(X_train)
train_sc = scaler_1.transform(X_train)
scaler_2 = StandardScaler().fit(X_test)
test_sc = scaler_2.fit(X_test)
I understand that one shouldn't bias the classifier mixing train/test data, but i would like to know if this other scenario is correct or not:
# X_all represents X feature vector before splitting (train + test)
X_scaled = StandardScaler().fit_transform(X_all)
X_train, y_train, X_test, y_test = train_test_split(X_scaled,y_all)
Besides, i would like to know how this case extends to KFold cross-validation.