Data & Features

missing data and imputation

/ MISS-ing DAY-tuh and im-pyoo-TAY-shun /

Real datasets have holes. A survey respondent skips the income question, a sensor drops out for an hour, a medical record simply lacks a test that was never ordered. These blanks are missing data, and since most models choke on empty cells, you have to decide what to do with them. Imputation is the act of filling those holes with reasonable estimates.

First, ask why the value is missing — it changes everything. Sometimes data is missing completely at random (a clipboard got rained on). Sometimes it is missing for a reason tied to the value itself (people with very high incomes decline to report). That second case is dangerous: the very fact of being missing carries information, and naive filling can bias your results. Simple imputation methods replace blanks with the column's mean, median, or most common value; smarter ones predict the missing value from the other features, or run the analysis many times over different plausible fill-ins (multiple imputation) to honestly reflect the added uncertainty.

Why it matters: dropping every row with any blank can throw away most of your data and, worse, can systematically remove a particular kind of person or situation, biasing the model. Thoughtful imputation keeps the data usable. But every imputed value is a guess, not a fact — a good practice is to add a separate "was missing" flag column, so the model can learn that the absence itself might be meaningful, rather than pretending the gap was never there.

A loan dataset is missing income for 8% of applicants. Filling all blanks with the average income looks tidy — but if the people who left it blank are mostly the unemployed, you've just invented a comfortable middle income for them, hiding the real risk. Adding an "income missing" flag lets the model treat that group with appropriate caution.

Why a value is missing can matter more than the value you fill in.

Like all preprocessing, imputation must be fit on the training data alone. Computing a mean to fill blanks using the whole dataset — test set included — is a quiet form of data leakage that flatters your scores.

Also called
missing valuesimputationfilling missing data缺失值插补缺失數據填補