How do native categorical splits differ from one-hot encoded categorical splits in CART?

Quick Overview

Compare native categorical splits with splits on one-hot encoded columns in CART decision trees. It tests whether you can explain what one split can express under each encoding, how the best category grouping is found, and how each choice affects tree depth, overfitting and library support.

How do native categorical splits differ from one-hot encoded categorical splits in CART?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: hard

Interview Round: Other

How do native categorical splits differ from one-hot encoded categorical splits in CART? Consider a categorical feature with $k$ levels, such as color, and compare what one split can express under each representation, how the best split is found, and what each approach does to the tree. ```hint Count the splits How many splits does each representation need to send an arbitrary group of categories to the same side of the tree? ``` ```hint The search space A feature with $k$ levels has ${2^{k-1} - 1}$ possible two-group partitions. For a binary target, think about ordering the categories by some statistic so that only a few partitions need to be checked. ``` ### What a Strong Answer Covers - What a single native split and a single one-hot split can each express - How the best subset split is found efficiently, and when that shortcut is exact - The cost of one-hot encoding: deeper, more fragmented trees and weak high-cardinality dummies, including the effect of feature subsampling - The overfitting risk of native splits on high-cardinality features and how to control it - Which common libraries support native categorical splits ### Follow-up Questions - Why is sorting categories by mean target optimal for binary classification and regression but not for multiclass targets? - How does ordinal encoding with an arbitrary order compare with both approaches? - A feature has 50,000 levels and most appear fewer than 10 times. What would you do before training a gradient-boosted model on it? - How does LightGBM decide whether to use a one-vs-rest split or a sorted subset split for a categorical feature?

Overview: Compare native categorical splits with splits on one-hot encoded columns in CART decision trees. It tests whether you can explain what one split can express under each encoding, how the best category grouping is found, and how each choice affects tree depth, overfitting and library support.

PracHub logo
General
Nov 25, 2026
hardMachine Learning EngineerOtherMachine Learning
0
0

How do native categorical splits differ from one-hot encoded categorical splits in CART? Consider a categorical feature with kk levels, such as color, and compare what one split can express under each representation, how the best split is found, and what each approach does to the tree.

What a Strong Answer Covers Guidance

  • What a single native split and a single one-hot split can each express
  • How the best subset split is found efficiently, and when that shortcut is exact
  • The cost of one-hot encoding: deeper, more fragmented trees and weak high-cardinality dummies, including the effect of feature subsampling
  • The overfitting risk of native splits on high-cardinality features and how to control it
  • Which common libraries support native categorical splits

Follow-up Questions Guidance

  • Why is sorting categories by mean target optimal for binary classification and regression but not for multiclass targets?
  • How does ordinal encoding with an arbitrary order compare with both approaches?
  • A feature has 50,000 levels and most appear fewer than 10 times. What would you do before training a gradient-boosted model on it?
  • How does LightGBM decide whether to use a one-vs-rest split or a sorted subset split for a categorical feature?