Code QuizIntermediate Data Leakage in Scaling
Spot the leakage when fitting the scaler on the full dataset.
Codepython
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
X_train, X_test = train_test_split(X, test_size=0.2)
scaler = StandardScaler()
scaler.fit(X)
X_train = scaler.transform(X_train)
X_test = scaler.transform(X_test)
What is the bug that causes data leakage?