How does KNN imputation work and when is it a good choice?
mediumAnswer
- For each row with missing values, find the k nearest complete rows using the observed features, then fill the missing values with a weighted average (regression) or mode (categorical) of those neighbours.
- Handles multivariate structure automatically — better than mean/median for correlated features.
- Downsides: quadratic in n (slow on large data), sensitive to scale (standardize first), degrades in high dimensions.
- Great default for medium tabular data with < 100k rows.
Check yourself — multiple choice
- It replaces missing values with the mean of the column
- Fills missing values with the average of k nearest complete rows in observed-feature space
- It requires labels
- Only for regression targets
KNN imputation: average of k nearest complete rows using observed features.
#missing-data#knn
Practise Supervised Learning
215 interview questions in this topic.
Related questions
- How do you choose k in k-Nearest Neighbours?
- How do you choose the distance metric for KNN?
- What's the point of distance-weighted KNN?
- Why does KNN degrade badly in high dimensions?
- How do KD-trees and ball-trees speed up KNN, and when do they stop helping?
- What is the nearest centroid (Rocchio) classifier and when is it useful?