What does DictVectorizer do with a string-valued categorical entry versus a numeric entry in a record?
Classic MLLevel: IntermediateStructured sparse records
What does DictVectorizer do with a string-valued categorical entry versus a numeric entry in a record?
Hints
- Data values can influence feature names.
- A stable vocabulary gives consistent columns.
Answer
It expands string categories into named indicator features, while numeric values remain feature values. A fitted vocabulary aligns columns across records; validate unknown-key handling at transform.
Source and licence: scikit-learn 1.7.2 — feature extraction · BSD-3-Clause · answer: Quantoros editorial