Tree ensembles like XGBoost and Random Forests are the workhorses of machine learning for tabular data. They offer excellent predictive performance and are efficient to train. However, their success often comes at the cost of massive size, which can be a major bottleneck for memory-constrained devices and formal verification.
Researchers from KU Leuven have introduced LOP (Level-wise Optimization and Pruning), a novel algorithm that compresses these models by factors of 10x to 100x more than existing methods—all without sacrificing predictive accuracy.
The Problem with Forest Bloat
A high-performing tree ensemble might contain hundreds of trees with thousands of leaves. This "bloat" creates three major headaches:
- Resource Constraints: Large models drain batteries on mobile devices and exceed memory limits on embedded sensors.
- Latency: More leaves mean more memory lookups and computations per prediction.
- The Verification Bottleneck: Proving a model is fair or robust against adversarial attacks often scales exponentially with the number of trees.
Existing solutions usually either prune entire trees (which is too coarse) or refine leaf values without reducing the structural size (which is too fine). LOP bridges this gap by pruning at any level of any tree while "healing" the remaining model to preserve accuracy.
How LOP Works: Level-wise Optimization
Instead of looking at the forest as a finished product, LOP processes it level-by-level, from the roots down to the deepest leaves. At each level, LOP solves a global optimization problem.
For every node $n$ at the current level, the algorithm learns two parameters: a scaling factor ($c_n$) and a shift ($b_n$). The new value for any leaf $v_k$ under that node becomes $c_n v_k + b_n$.
The compression magic happens via L1 regularization on the scaling factors ($c_n$):
- If $c_n$ is pushed to zero, the entire subtree rooted at that node is pruned and replaced by a single leaf with the value $b_n$.
- If $c_n$ is non-zero, the subtree is kept, but its leaf values are updated to better fit the training data in the context of the newly pruned forest.
This process repeats for several rounds, allowing the model to globally "re-adjust" as more of its structure is stripped away. Unlike standard pruning, which looks at nodes in isolation, LOP’s optimization is global across all trees at a specific level. It can recognize that a subtree in one tree is redundant because its information is now better captured by the updated leaves in another.
Key Results: Massive Compression
The authors evaluated LOP across 14 binary classification and 7 regression datasets, testing on both XGBoost and Random Forest architectures. The quantitative results demonstrate a massive leap in compression efficiency.
- Compression Factors: On XGBoost, LOP achieved an average compression ratio of 50x. On Random Forests, which are naturally bulkier, it reached a staggering 1167x average compression.
- Accuracy Trade-off: These gains came with a negligible drop in balanced accuracy—typically less than 0.5%.
- Superiority: LOP consistently outperformed baselines like ForestPrune and Global Refinement, often providing 2-3x better compression for the exact same accuracy level.
- Memory & Verification: For a typical XGBoost model, LOP reduced the memory footprint from ~92 KB to just ~8 KB. Crucially, compressing a model with LOP made checking for adversarial robustness 2.5x to 10x faster than competing compression methods.
Limitations and Future Work
While highly effective, LOP does have a few limitations. Because it solves a global optimization problem iteratively, it is slower to run than simple "rank-and-prune" methods. Additionally, the user must provide a margin for the maximum allowed accuracy loss, which requires tuning a regularization parameter using a validation set. Finally, extremely deep trees might increase the number of optimization steps required.
Ultimately, LOP represents a significant step forward for deploying high-performance tree ensembles on edge devices and in safety-critical applications requiring formal verification.
Summary updated