Introduction
In high-stakes domains such as finance, healthcare, and criminal justice, model interpretability is often a regulatory or ethical necessity. While Generalized Additive Models (GAMs) are inherently interpretable—relying on a sum of univariate functions—practitioners often face a persistent "accuracy-interpretability" trade-off. Sophisticated ensembles like bagged boosted decision trees are highly accurate but produce "jagged" shape functions that are difficult for humans to audit or deploy simply. Conversely, simpler models like those using few-segment linear curves are easy to read but hard to optimize directly from raw data. This research addresses this gap by decoupling the learning process from the representation process: training a complex "teacher" model first, then distilling its knowledge into a clean, human-readable format.
The Localized Distillation Framework
The core of the proposed approach is a two-step "Localized Distillation" pipeline. First, a high-accuracy teacher model, such as a GAM forest or a Neural Additive Model (NAM), is trained on the raw data. Second, each univariate function within the teacher model is distilled individually. By evaluating the teacher's shape function across the dataset, the researchers create $(x, y)$ pairs and fit a piecewise-linear (PWL) curve to these points.
As shown in the figure above, the distillation process effectively smooths out the noise and "jaggedness" of the teacher model. This acts as a form of regularization by construction; by limiting a feature to a small number of linear segments (typically 3 to 5), the model naturally ignores erratic, non-interpretable behavior that might represent overfitting in the teacher.
The pwlfit Algorithm
The researchers developed the pwlfit algorithm to perform this distillation with high speed and robustness. Key technical innovations include:
- Knot Discretization & Greedy Search: The algorithm discretizes the search space for "knots" (the points where linear segments meet) and employs a greedy heuristic to find optimal placement.
- Linear Condensation: To handle massive datasets, a "condensation" technique reduces millions of data points into a few synthetic points. This allows the algorithm to solve a linear least squares problem in $O(\text{number of knots})$ time rather than $O(\text{number of data points})$.
- Constraints: The algorithm supports monotonicity constraints and automatic input transformations, such as log scales, to better fit skewed data distributions.
Experimental Results and Insights
The method was evaluated on four diverse datasets: COMPAS (recidivism), FICO (credit), MSLR-WEB30K (ranking), and a private Chrome Web Store dataset.
Key findings from the experiments include:
- Accuracy Parity: In almost all cases, the distilled 5-segment models matched the accuracy of the complex teacher models. On the COMPAS dataset, the distilled model even matched the performance of "black-box" interacting forests (AUC ~0.74).
- Efficiency:
pwlfitproved significantly faster and more robust than existing libraries likepwlf, consistently finding better fits with lower variance in runtime. - Code as the Model: The final output is literally source code (e.g., C++ or Python). This allows models to be integrated into standard software engineering workflows, enabling code reviews, version control, and manual expert intervention to ensure fairness or safety.
Conclusion and Future Work
By treating a machine learning model as traditional source code, this approach bridges the gap between high-performance ML and transparent software engineering. While the current focus is on univariate functions, the authors suggest that localized distillation could serve as a high-quality initialization for global optimization steps. Future work will explore extending this human-readable representation to higher-dimensional feature interactions.
Summary updated