What fallback does sklearn TargetEncoder use for a category absent from training?
Classic MLLevel: IntermediateTarget encoding fallback
What fallback does sklearn TargetEncoder use for a category absent from training?
Hints
- Distinguish unseen from missing.
- There is no category-specific statistic for an unseen value.
Answer
It uses the training target mean. Missing values are instead treated as a category when present during fitting; unknown and missing are not automatically the same event.
Source and licence: scikit-learn 1.7.2 — preprocessing · BSD-3-Clause · answer: Quantoros editorial