How do you handle missing data without introducing bias?
Written by the mlprep team · Updated
How do you handle missing data in a production ML system? When is missingness itself predictive, and when does imputation introduce bias?
Types of missingness#
Missing data is not one problem.
- MCAR: missing completely at random. Example: random logging dropout.
- MAR: missingness depends on observed variables. Example: income missing more often for a geography you observe.
- MNAR: missingness depends on the missing value itself. Example: high-income users decline to report income.
MNAR is the hardest because the missing pattern carries information you do not directly observe.
Basic strategies#
Simple imputation: fill numeric features with median/mean and categorical features with "unknown." This is robust and often strong for tabular baselines.
Missing indicators: add a boolean feature is_missing_x. This lets the model learn that absence itself is informative. GBDTs often handle this well.
Model-based imputation: predict missing values using other features. Useful when missingness is moderate and relationships are stable, but risky if it creates leakage or false certainty.
Dropping rows or columns: acceptable only when missingness is small or the feature is unreliable. Dropping rows can bias the population if missingness is not random.
Production risks#
Imputation must be fitted on training data only and applied consistently at serving. If the missing rate changes in production, the model can fail silently. Nulls often mean a pipeline broke, not that the user has no value.
For real-time systems, distinguish "missing because not applicable," "missing because not collected yet," and "missing because the feature pipeline failed." These should often be different categories.
Senior/staff considerations#
A strong answer asks why the value is missing. Product flows create missingness: optional profile fields, privacy settings, device permissions, geography-specific collection, delayed joins, or logging bugs.
Monitor missing rates by segment and over time. A global 2% null rate can hide a 60% null rate for a new app version. Treat missingness as a data contract with ownership and alerts, not just preprocessing.
The key takeaway unlocks after you reveal an expert answer.
Key Takeaway
Handle missing data based on why it is missing. Use simple imputation plus missing indicators as a strong baseline, fit imputers inside training/CV only, and monitor missing rates in production. Missingness can be predictive, biased, or a pipeline failure.
Follow-up Questions to Test Yourself
Interviewers often pivot here once you cover the core concept.
- What is the difference between MCAR, MAR, and MNAR?
- Why can dropping rows with missing values bias a model?
- How would you distinguish legitimate missingness from a broken feature pipeline?
How confident do you feel explaining this?
Track your understanding or flag it to revisit before your next loop.
Related Questions
Walk me through feature engineering for tabular data
How do you encode categorical features? Compare one-hot, target encoding, and embeddings.
When do feature crosses matter, and how do you control their complexity?
How would you design a feature store for a large ML platform?