Machine Learning Basics

Which of the following steps in building a machine learning model causes data leakage (information from the evaluation data slipping into training)?

  1. AComputing the mean and standard deviation for standardization from the training data only, and standardizing the validation and test data with the same values
  2. BComputing the mean and standard deviation for standardization from all the data and standardizing it, and then splitting it into training and test data
  3. CSplitting time-series data so that data before a certain date is used for training and data from that date on is used for testing
Show answer and explanation

Answer: B. Computing the mean and standard deviation for standardization from all the data and standardizing it, and then splitting it into training and test data

Data leakage is information that should not be available at prediction time, or information from the evaluation data, entering the training process. Computing the mean and standard deviation over all the data before splitting lets statistics of the test data reach training through preprocessing, which can make performance look better than it really is. The correct procedure is to compute preprocessing parameters from the training data only and apply those values to the validation and test data. For time-series data, a random split would mean predicting the past with future information, so the data is split in time order.

  • A. This is the correct procedure for preventing leakage: preprocessing parameters are computed from the training data only.
  • B. Correct. The mean and standard deviation of the test data enter training through preprocessing.
  • C. This is the correct way to split time-series data, keeping future information out of training.
Practice this topic Back to topic

Related calculators

Books on Machine Learning Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Machine Learning Basics questions

  1. A two-class classification model was evaluated on 200 test samples, and its confusion matrix shows 45 true positives (TP), 5 false positives (FP), 45 false negatives (FN) and 105 true negatives (TN). Which pair of precision and recall is correct?
  2. A two-class classification model was evaluated on 200 test samples, giving TP = 20, FP = 5, FN = 30 and TN = 145. Which is closest to the F1 score?
  3. Which of the following correctly describes the ROC curve and AUC used to evaluate two-class classification models?
  4. For data of 1000 items of which only 10 are positive, what is the accuracy of a model that predicts every item as negative?
  5. Four data points have actual values 3, 5, 2 and 6, and the model predicts 2, 5, 4 and 4 for them. What is the mean squared error (MSE)?