Introduction
In high-stakes domains such as healthcare and finance, practitioners often face a trade-off between the predictive power of "black-box" models (e.g., deep neural networks, gradient-boosted trees) and the transparency of "white-box" models (e.g., linear regression). Neural Additive Models (NAMs) have emerged as a compelling middle ground, offering the flexibility of neural networks while maintaining the interpretability of additive models.
However, existing implementations often struggle with high-dimensional data, categorical variables, and specialized tasks like survival analysis. The dnamite package addresses these gaps by providing a unified, scikit-learn-compatible framework for NAMs that supports automated feature selection and survival modeling natively in Python.
The DNAMite Architecture
The core of the package is the DNAMite architecture, which refines standard NAMs through several key innovations designed for robustness and interpretability.
Discretization and Neighborhood Embeddings
Rather than processing raw continuous features, dnamite discretizes inputs into bins (typically via quantiles). It then learns embeddings for these bins. To ensure functional smoothness, the final embedding for a specific value is calculated as a weighted sum of its neighbors using a Gaussian kernel. This approach allows the model to handle non-linear relationships and missing data naturally by treating "missing" as a distinct bin.
Automated Feature Selection
A significant challenge in tabular data is identifying relevant features among hundreds of candidates. dnamite integrates learnable "feature gates" directly into the optimization loop. A regularizer encourages sparsity, pushing the gates of non-informative features to zero. This end-to-end selection is more efficient than post-hoc heuristic methods and often leads to better predictive performance.
Survival Analysis with IPCW
For time-to-event prediction, dnamite implements Inverse Probability of Censoring Weighting (IPCW). This allows the model to handle censored data—where the outcome is unknown for some subjects because they left the study early—while maintaining the interpretability of the additive components.
Experimental Evaluation
The authors evaluated dnamite using the MIMIC III clinical database, focusing on two tasks: in-hospital mortality (binary classification) and time-to-death (survival analysis).
Performance and Interpretability
On a comprehensive set of 757 features, the automated feature selection achieved an AUC of 0.8792, significantly outperforming a manually curated benchmark set (AUC 0.8521). This suggests that the model can identify predictive signals overlooked by human experts. Furthermore, the resulting "shape functions"—visualizations of how individual features impact the outcome—were found to be consistent with established statistical packages like mgcv, while offering superior handling of missingness.
Clinical Utility
The survival models demonstrated high calibration, ensuring that predicted probabilities align with observed frequencies. A key insight from the MIMIC III analysis was the "informative missingness" of certain vitals; for instance, the absence of respiratory rate measurements was a strong predictor of lower risk, reflecting clinical workflows where healthier patients require less frequent monitoring.
Conclusion and Future Work
dnamite bridges the gap between complex neural architectures and interpretable statistical modeling. While current limitations include the assumption of independent censoring in survival tasks and a two-stage training process for interactions, the package provides a powerful tool for "glass-box" modeling in critical applications. Future iterations may explore joint training of main effects and interactions to capture even more complex patterns without sacrificing transparency.
Summary updated