When is ordinal encoding appropriate instead of one-hot encoding?

Quick Overview

Asks when ordinal encoding of a categorical feature is the right choice over one-hot encoding. Tests understanding of truly ordered categories, the order and spacing that integer codes imply for linear and distance models, and why tree models tolerate arbitrary codes for nominal features.

When is ordinal encoding appropriate instead of one-hot encoding?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: easy

Interview Round: Other

When is ordinal encoding appropriate instead of one-hot encoding? ```hint What the integers claim Ask what a model assumes when it sees the values 0, 1 and 2 in one column, and which model families depend on that assumption. ``` ### What a Strong Answer Covers - Categories with a real order, and why keeping that order helps - Setting the order explicitly, and why a library's default order is often wrong - What integer codes imply for linear and distance-based models (an order and equal spacing) - Why tree models tolerate integer codes even for nominal features, and the trade-off against one-hot ### Follow-up Questions - How would you encode a nominal feature with 50,000 categories for a linear model? - How should the encoder handle a category at inference time that never appeared in training? - For a survey answer from "strongly disagree" to "strongly agree", when would you keep one integer column and when would you one-hot it? - What do the native categorical options in LightGBM or CatBoost do differently from plain integer codes?

Overview: Asks when ordinal encoding of a categorical feature is the right choice over one-hot encoding. Tests understanding of truly ordered categories, the order and spacing that integer codes imply for linear and distance models, and why tree models tolerate arbitrary codes for nominal features.

Nov 24, 2026
easyMachine Learning EngineerOtherMachine Learning
0
0

When is ordinal encoding appropriate instead of one-hot encoding?

What a Strong Answer Covers Guidance

  • Categories with a real order, and why keeping that order helps
  • Setting the order explicitly, and why a library's default order is often wrong
  • What integer codes imply for linear and distance-based models (an order and equal spacing)
  • Why tree models tolerate integer codes even for nominal features, and the trade-off against one-hot

Follow-up Questions Guidance

  • How would you encode a nominal feature with 50,000 categories for a linear model?
  • How should the encoder handle a category at inference time that never appeared in training?
  • For a survey answer from "strongly disagree" to "strongly agree", when would you keep one integer column and when would you one-hot it?
  • What do the native categorical options in LightGBM or CatBoost do differently from plain integer codes?