79805620

Date: 2025-10-31 10:00:00
Score: 0.5
Natty:
Report link

You should apply StandardScaler after train_test_split and fit it only on the training data. If you scale before splitting, the scaler learns the mean and standard deviation from the entire dataset — including the test set — which leaks information about unseen data and can make validation results unrealistically good. Fitting the scaler only on X_train ensures that scaling parameters reflect the same data distribution the model learns from, and applying that scaler to both X_train and X_test preserves a realistic, generalizable evaluation.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: Undepdev