Data leakage in missing value imputation: what causes it and how to prevent it when preparing ML data

Quick Overview

Asks how missing value imputation can leak information from test data into model training and how to prevent it when preparing data for machine learning. Tests understanding of train/test discipline, cross-validation pipelines, time-ordered data and how fitted imputers are used at prediction time.

Data leakage in missing value imputation: what causes it and how to prevent it when preparing ML data

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Other

Explain the data leakage problem in the context of missing value imputation and how you would prevent it when preparing data for machine learning. ```hint Follow the fill value For each value that gets filled in, ask which rows were used to compute it, and whether the model would have those rows at prediction time. ``` ### What a Strong Answer Covers - What leakage means for imputation and why it inflates validation scores - The ways imputation can leak, including less obvious ones - The order of operations that prevents it, in cross-validation as well as a single train/test split - How the fitted imputer is applied to new data at prediction time ### Follow-up Questions - The data is a daily time series of sensor readings with gaps. Which ways of filling the gaps leak, and which are safe? - Is it ever acceptable to use the target when imputing a feature? - How much does a median computed on the full dataset actually inflate scores, and when does the leak become serious? - Why add a missing-value indicator column, and can that indicator leak information too?

Overview: Asks how missing value imputation can leak information from test data into model training and how to prevent it when preparing data for machine learning. Tests understanding of train/test discipline, cross-validation pipelines, time-ordered data and how fitted imputers are used at prediction time.

General logo
General
Nov 25, 2026
mediumData ScientistOtherData Manipulation (SQL/Python)
0
0

Explain the data leakage problem in the context of missing value imputation and how you would prevent it when preparing data for machine learning.

What a Strong Answer Covers Guidance

  • What leakage means for imputation and why it inflates validation scores
  • The ways imputation can leak, including less obvious ones
  • The order of operations that prevents it, in cross-validation as well as a single train/test split
  • How the fitted imputer is applied to new data at prediction time

Follow-up Questions Guidance

  • The data is a daily time series of sensor readings with gaps. Which ways of filling the gaps leak, and which are safe?
  • Is it ever acceptable to use the target when imputing a feature?
  • How much does a median computed on the full dataset actually inflate scores, and when does the leak become serious?
  • Why add a missing-value indicator column, and can that indicator leak information too?