How does LightGBM find splits on categorical features without one-hot encoding?

Quick Overview

Asks how LightGBM splits a categorical feature into two groups of categories at a tree node without one-hot encoding the column. Tests knowledge of gradient boosting split search, histogram statistics, the cost of partition search, and overfitting controls for high-cardinality features.

How does LightGBM find splits on categorical features without one-hot encoding?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: hard

Interview Round: Other

LightGBM can take a categorical column directly and split it into two groups of categories at a tree node. How does LightGBM find splits on categorical features without one-hot encoding? ```hint Count the candidates Count how many ways $k$ categories can be divided into two non-empty groups. Then ask what ordering of the categories would let you check only a handful of those groups. ``` ```hint Reuse the histogram For numeric features LightGBM already keeps gradient and hessian sums per histogram bin. Think about what one bin per category would let it compute. ``` ### What a Strong Answer Covers - How many binary partitions of $k$ categories exist, and why trying them all is infeasible - The per-node procedure: the statistics kept per category, the sort key, and the scan - Why scanning the sorted order finds a good partition, and when that is exact - How low-cardinality features are handled, and why many-vs-many splits beat one-hot splits - Overfitting risk at high cardinality and the parameters that control it ### Follow-up Questions - When is the sorted-order scan guaranteed to find the best partition, and when is it only a heuristic? - Where does a category that never appeared in training go at prediction time? - How would you compare this native handling with target encoding the column before training? - Why can native categorical splits overfit more than one-hot encoding on a column with thousands of rare categories?

Overview: Asks how LightGBM splits a categorical feature into two groups of categories at a tree node without one-hot encoding the column. Tests knowledge of gradient boosting split search, histogram statistics, the cost of partition search, and overfitting controls for high-cardinality features.

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

LightGBM can take a categorical column directly and split it into two groups of categories at a tree node. How does LightGBM find splits on categorical features without one-hot encoding?

What a Strong Answer Covers Guidance

  • How many binary partitions of kk categories exist, and why trying them all is infeasible
  • The per-node procedure: the statistics kept per category, the sort key, and the scan
  • Why scanning the sorted order finds a good partition, and when that is exact
  • How low-cardinality features are handled, and why many-vs-many splits beat one-hot splits
  • Overfitting risk at high cardinality and the parameters that control it

Follow-up Questions Guidance

  • When is the sorted-order scan guaranteed to find the best partition, and when is it only a heuristic?
  • Where does a category that never appeared in training go at prediction time?
  • How would you compare this native handling with target encoding the column before training?
  • Why can native categorical splits overfit more than one-hot encoding on a column with thousands of rare categories?