A student's notebook does the following, in order:
1. scaler.fit_transform(X) on the full dataset 2. train_test_split(...) 3. Fit a logistic regression on the training rows 4. Report test AUC
What is the flaw, and how does scikit-learn help you avoid it?
Why did you pick that answer? Two or three sentences. The act of articulating it is what builds the judgment — not the click that follows.
StandardScaler learns a mean and a standard deviation — statistics that here include the test set. That is preprocessing leakage: mild with a scaler, severe with imputers, target encoders, or feature selectors. A Pipeline fits every step on the training data only and applies it to test data, and it does the same inside cross-validation automatically.
Anything with a .fit() learns from data. The scaler's mean and standard deviation are parameters estimated from rows the model should never see.
Splitting after fitting means the model has trained on the test rows — the most serious leak possible.
With L2 regularization (scikit-learn's default), unscaled features are penalized unevenly. Scaling belongs in the pipeline, not in the trash.