2.1.2 · D5Data Preprocessing & Feature Engineering

Question bank — Handling missing values (deletion, imputation strategies)

1,540 words7 min readBack to topic

Before we start, three words we lean on everywhere. If any feel shaky, re-read the parent's definition box.


True or false — justify

True or false: MCAR data can be safely deleted without introducing bias.
True on bias, but you still pay a price — deletion under MCAR loses statistical power (fewer rows = wider confidence intervals), it just doesn't tilt the estimates in any direction.
True or false: Mean imputation leaves the feature's mean unchanged.
True — that's exactly why it feels safe. But it silently shrinks the variance, because every filled value sits at the center with zero spread.
True or false: Since MAR means "Missing At Random", the missingness is random and can be ignored.
False — "at random" is a misleading name. Under MAR the missingness is predictable from observed variables (e.g. younger people skip income), so ignoring it biases results unless you condition on those variables.
True or false: KNN imputation with equal to the whole dataset reduces to mean imputation.
True — with all points as neighbours and uniform weights, the imputed value is just the average of every observed value in that feature, i.e. the global mean.
True or false: Multiple imputation (like MICE generating several datasets) is only about accuracy, not honesty.
False — its main gift is honesty about uncertainty. Single imputation pretends the guess is a fact; multiple imputation spreads answers so downstream standard errors reflect that we were guessing.
True or false: Forward fill and backward fill give the same result on the same time series.
False — forward fill carries the last past value into a gap, backward fill pulls the next future value backward. They agree only if the values bracketing the gap happen to be equal.
True or false: Dropping a row with one missing feature throws away the information in that row's other, present features.
True — listwise deletion discards all the observed values in that row too, which is why it can waste enormous amounts of data when missingness is scattered.
True or false: If a feature has 60% missing values, imputing it is always better than dropping the column.
False — imputing 60% means most of the column is invented, so it can inject a fake, low-variance signal. Often dropping the column (or adding only a missingness indicator) is the safer call.

Spot the error

"Data is missing MCAR, so let's use listwise deletion — no bias, done." What's overlooked?
The no-bias claim is fine, but if many features each have a little missingness, listwise deletion can compound into huge data loss (independent 5% gaps across 10 features drops ~40% of rows), hurting power badly.
"I mean-imputed Income, then computed its variance and reported tight confidence intervals." What went wrong?
The tight intervals are an artifact. Mean imputation pins values at the center and shrinks variance, so the model becomes overconfident — the reported precision is fake.
"I imputed with the mean of the whole dataset, computed once before splitting into train and test." Why is this a mistake?
That leaks test information into training — the imputation statistic saw test rows. See 5.2.03-Data-leakage-prevention; the mean must be computed on the training set only and then applied to validation/test.
"For a categorical color feature I filled blanks with the mean of the encoded numbers, getting 1.7." Error?
Categories have no meaningful mean — 1.7 isn't a color. Use the mode (most frequent category) or a dedicated "Missing" category instead.
"KNN imputation on raw features: Weight in kg, Height in cm, Income in dollars — distance computed directly." What's broken?
Distance is dominated by the large-scale feature (Income), so neighbours are chosen almost entirely by income. Features must be scaled first (2.2.01-Feature-scaling-and-normalization) so each contributes fairly.
"High earners refuse to report income, so I'll impute income using KNN on the other features and call it fixed." Flaw?
This is MNAR — missingness depends on the hidden income value itself. No observed-data method (KNN, MICE) can recover it, because the very people who'd anchor the high end are systematically absent.
"I forward-filled a 30-day gap in a stock price during a bull run." What breaks?
Forward fill assumes values change slowly and carries the last pre-gap price flat for 30 days, badly underestimating during a strong trend. It only works for short gaps with high autocorrelation.

Why questions

Why does mean imputation always underestimate variance, never overestimate it?
Variance measures spread around the mean, and every imputed point is placed exactly at the mean — contributing zero to the spread while inflating the count, so the average squared deviation can only shrink.
Why is the median preferred over the mean for imputing skewed or outlier-heavy data?
The median minimizes the sum of absolute deviations, so a few extreme values barely move it; the mean minimizes squared deviations, so outliers drag it strongly toward the tail.
Why can pairwise deletion produce a correlation matrix that isn't positive semi-definite?
Each pairwise correlation is computed on a different subset of rows (whichever pairs are both present), so the entries aren't mutually consistent, and the assembled matrix can violate the geometric constraints a real covariance structure must satisfy.
Why does MICE iterate in cycles instead of imputing once?
The first pass uses crude initial guesses (mean-fill), so the regression models are trained on partly-fake data. Each cycle re-trains using the improved values, letting the estimates and the feature relationships they rely on refine together until they stabilize.
Why does adding a "missingness indicator" feature sometimes help even after you impute?
The fact that a value was missing can itself be predictive (e.g. skipping a question signals something). The indicator lets the model separate "real value X" from "we guessed X", so imputation error doesn't silently corrupt the signal.
Why is conditional imputation (KNN, MICE) better at preserving feature relationships than mean imputation?
Mean imputation fills every blank with one constant, erasing any link to other features. Conditional methods predict the blank from the other features, so a correlation like Age–Income survives instead of being flattened.

Edge cases

Edge case: a feature is 100% missing. What can imputation do?
Nothing meaningful — with no observed values there's no distribution and no neighbours to borrow from. Drop the column; only its (constant) missingness indicator carries any information.
Edge case: forward fill on a series whose first value is missing.
There's no earlier observation to carry forward, so forward fill leaves it blank — you need backward fill (or another rule) to seed the leading gap.
Edge case: KNN imputation where every candidate neighbour is also missing the target feature.
There's nothing to average, so the neighbourhood must be expanded or those rows excluded; naively you'd get an undefined (division-by-zero-style) result with no valid values to weight.
Edge case: MCAR but only 3 rows survive listwise deletion out of 1000.
Technically unbiased, practically useless — such tiny samples give estimates with enormous variance, so "no bias" is cold comfort. Prefer imputation to retain data. Relevant to a sane 3.1.02-Training-validation-test-split.
Edge case: the missing value is exactly what you're trying to predict (the label) for some rows.
Don't impute the label — imputing the target manufactures the answer you're supposed to learn. Drop those rows from training or treat them as a semi-supervised problem instead.
Edge case: imputation choice interacting with model complexity — does it affect the bias–variance tradeoff?
Yes: aggressive low-variance imputation (mean fill) adds bias and false confidence, while flexible imputation (MICE) can lower bias but add variance/leakage risk — the same tension studied in 4.3.01-Bias-variance-tradeoff.
Recall One-line summary to lock in

The mechanism (MCAR/MAR/MNAR) decides whether a strategy is honest; the method (deletion/mean/KNN/MICE) decides how much it costs in bias, variance, and leakage.