Almost every real dataset has missing values. How you handle them affects your results.
First, Find It
Missing values aren't always blank. Look for NA, null, ?, -999, empty strings, "unknown" and impossible values like a birth year of 1900. Tell your tools about these markers when loading data.
Understand Why It's Missing
- Missing completely at random: unrelated to anything — a sensor glitch. Dropping rows causes little bias.
- Missing at random: related to other observed variables — younger customers skip a field more often.
- Missing not at random: related to the missing value itself — people with high incomes decline to state income. Most dangerous for bias.
Options
| Approach | When it fits |
|---|---|
| Drop rows | Few rows affected, missingness random |
| Drop columns | Mostly empty or unimportant |
| Impute median/mode | Simple, modest gaps |
| Impute from other features | Missingness depends on other variables |
| Add a "missing" indicator | Missingness itself may carry information |
| Use models that handle missing values | Gradient boosting libraries often do natively |
Avoid Leakage
Compute imputation values from training data only, then apply them to validation and test data — pipelines make this automatic.
Report It
State how much data was missing and what you did. Results can change substantially depending on the approach, so test sensitivity when it matters.