[Paper Review] Random Forests, Decision Trees, and Categorical Predictors: The "Absent Levels" Problem
This paper identifies and analyzes the 'absent levels' problem in decision tree-based models like random forests, where unseen categorical levels during inference cause systematic bias due to undefined behavior in splits trained without those levels. The authors demonstrate through real-world examples and empirical testing that simple heuristics—especially the Random heuristic—can mitigate this bias more effectively than default naive approaches, which are systematically flawed.
One advantage of decision tree based methods like random forests is their ability to natively handle categorical predictors without having to first transform them (e.g., by using feature engineering techniques). However, in this paper, we show how this capability can lead to an inherent "absent levels" problem for decision tree based methods that has never been thoroughly discussed, and whose consequences have never been carefully explored. This problem occurs whenever there is an indeterminacy over how to handle an observation that has reached a categorical split which was determined when the observation in question's level was absent during training. Although these incidents may appear to be innocuous, by using Leo Breiman and Adele Cutler's random forests FORTRAN code and the randomForest R package (Liaw and Wiener, 2002) as motivating case studies, we examine how overlooking the absent levels problem can systematically bias a model. Furthermore, by using three real data examples, we illustrate how absent levels can dramatically alter a model's performance in practice, and we empirically demonstrate how some simple heuristics can be used to help mitigate the effects of the absent levels problem until a more robust theoretical solution is found.
Motivation & Objective
- To identify and formalize the 'absent levels' problem in decision tree-based models, where categorical predictor levels present in inference but absent during training lead to undefined behavior.
- To demonstrate that this issue causes systematic bias in model predictions, particularly in widely used implementations like the randomForest R package and Breiman & Cutler's FORTRAN code.
- To empirically evaluate the impact of absent levels on model performance using three real-world datasets, showing dramatic performance degradation when unhandled.
- To propose and evaluate practical heuristics—such as Random, Majority, and One-Hot encoding—for mitigating the absent levels problem until a robust theoretical solution is developed.
- To advocate for software and user-level changes, including feature engineering and adoption of reliable heuristics like Random, to avoid biased predictions in production systems.
Proposed method
- The study uses Breiman and Cutler’s original random forests FORTRAN code and the widely used randomForest R package as case studies to analyze how absent levels are currently handled in practice.
- The authors simulate the absent levels problem across three real-world datasets, introducing previously unseen categorical levels during inference to assess model behavior and performance degradation.
- They evaluate multiple heuristics for handling absent levels: Left/Right (default naive choices), Stop (halt prediction), DBI (distance-based imputation), Majority, Random, and One-Hot encoding.
- Performance is measured using log loss, with statistical comparison across 1,000 experimental replications to assess robustness and consistency of each heuristic.
- The Random heuristic is implemented as a plug-in solution due to its consistent performance and ease of integration with existing randomForest R package workflows.
- The study compares heuristic performance against baseline naive approaches and evaluates trade-offs in bias, variance, and predictive accuracy.
Experimental results
Research questions
- RQ1How does the presence of previously unseen categorical levels during inference affect the behavior and performance of decision tree-based models like random forests?
- RQ2Why do default implementations of random forests (e.g., randomForest R package) produce systematically biased predictions when faced with absent categorical levels?
- RQ3Which heuristic strategies for handling absent levels yield the most robust and accurate predictions across diverse real-world datasets?
- RQ4Can simple, practical heuristics outperform default naive strategies like Left or Right splitting in the absence of training-level data?
- RQ5To what extent does feature engineering mitigate the absent levels problem, and when might it be less effective than heuristic-based solutions?
Key findings
- The absent levels problem causes systematic bias in random forests and decision trees, with default implementations like randomForest R package and Breiman & Cutler’s FORTRAN code making arbitrary Left or Right decisions when levels are unseen.
- The Left and Right heuristics resulted in log losses 0.7% and 1.9% worse, respectively, than the best-performing missing data heuristic, indicating measurable and consistent bias.
- The Majority and Random heuristics outperformed all other missing data heuristics in 999 out of 1,000 replications, achieving the smallest log loss and demonstrating high reliability.
- The One-Hot encoding heuristic occasionally outperformed missing data heuristics but on average yielded a 4.5% higher log loss than the best-performing heuristic, indicating suboptimal performance.
- The Random heuristic was consistently competitive, easy to implement, and recommended as a provisional standard for software and user-level mitigation.
- The problem is not limited to prediction; it affects downstream tasks like variable importance, outlier detection, and imputation in tree-based models, suggesting widespread impact across ML pipelines.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.