I was wondering, in the feature scaling part of data preprocessing, why is the data in the testing set standardized using the fit values from the training set? Why aren't the fit values recalculated separately for the testing set and then used for transforming the testing set? Here is the code I am using as reference:
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
x_train[:, 3:] = sc.fit_transform(x_train[:, 1:3])
x_test[:, 3:] = sc.transform(x_test[:, 1:3])
In this example, x_train is the training set and x_test is the testing set.
Thanks!