Skip to content
Quantoros

With handleunknown='ignore', what does OneHotEncoder emit for an unseen category, and what ambiguity can dropping a…

Classic MLLevel: IntermediateUnknown one-hot categories

With handle_unknown='ignore', what does OneHotEncoder emit for an unseen category, and what ambiguity can dropping a category create?

Hints
  • Inspect the entire feature block.
  • Compare an unknown with the reference category.

Answer

The feature's encoded block is all zeros. If a known category was dropped, its block is also all zeros, so that representation cannot distinguish it from an unknown.

Source and licence: scikit-learn 1.7.2 — preprocessing · BSD-3-Clause · answer: Quantoros editorial

Related questions