When data is incomplete, you have choices. Drop affected rows? Estimate missing values? See how each strategy trades off data loss against bias, and how it affects your model's performance.
Original Dataset
12 rows| ID | Feature_A | Feature_B | Feature_C | Target |
|---|---|---|---|---|
| 1 | 45.2 | 23.1 | 98 | 0 |
| 2 | null | 19.4 | 101 | 0 |
| 3 | 38.5 | null | 88 | 1 |
| 4 | 52.1 | 22.3 | 95 | 1 |
| 5 | 41.3 | 25.8 | 105 | 0 |
| 6 | null | null | 91 | 1 |
| 7 | 48.9 | 20.1 | 99 | 0 |
| 8 | 39.2 | 24.5 | 93 | 1 |
| 9 | 46.5 | null | 102 | 0 |
| 10 | 50.1 | 21.7 | 97 | 1 |
| 11 | 43.8 | 22.9 | 96 | 0 |
| 12 | 47.3 | 23.6 | 100 | 1 |
Distribution: Feature_A vs Feature_B
Model Performance Comparison
Accuracies shown are estimates for a simple logistic regression model trained on the imputed dataset. Real results will vary with your data distribution and model complexity.
Choose a Strategy
Drop Rows
Remove any row containing at least one missing value. Simple and bias-free within remaining rows, but discards 25% of the dataset and may introduce selection bias if missingness is not random.
Mean Imputation
Replace each null with the column mean. Keeps all rows and is trivial to implement, but compresses the feature distribution: variance shrinks and relationships between features are weakened.
KNN Imputation
Estimate each missing value from K nearest neighbors (k=3) using Euclidean distance on available features. Preserves feature relationships and produces the most realistic fill values, at the cost of extra computation.
Key Concepts