Why does mean imputation fail for a column of strings, and which SimpleImputer strategies apply?
Classic MLLevel: FoundationCategorical imputation
Why does mean imputation fail for a column of strings, and which SimpleImputer strategies apply?
Hints
- Match statistics to the data type.
- Preserve an explicit missing category if useful.
Answer
Strings have no arithmetic mean. Use most_frequent or a constant missing-category token, then encode categories for the estimator.
Source and licence: scikit-learn 1.7.2 — impute · BSD-3-Clause · answer: Quantoros editorial