Categorical Features, Exactly

Pin a training category list, expand discrete codes into one-hot matrices, lock column order, route unseen categories to Other, and compare group means against false numeric order.

Exact One-Hot Categorical Encoding

Pin training vocabularies, build one-hot rows and tables, preserve column order, handle unknown categories, and fit exact group means.

  1. Pin the Category List

    freeze the ordered category vocabulary and count training occurrences

  2. One Row Becomes One-Hot

    expand one categorical value into a binary one-hot indicator vector

  3. Encode the Shown Table

    broadcast a column of category IDs into a full N-by-K one-hot matrix

  4. Column Order Is Part of the Data

    preserve pinned column order so learned category weights hit the right slots

  5. Unknown Category Goes to Other

    route out-of-vocabulary category codes into a dedicated Other column

  6. What Encoding Is and Is Not

    fit exact per-category group means and see both the power and limits of one-hot encoding