imodels: a python package for fitting interpretable models

Chandan Singh, Keyan Nasseri, Yan Shuo Tan, Tiffany M. Tang, Bin Yu 0001, Bin YuJ. Open Source Softw 2021 · DBLP

Introduction

imodels is a Python library designed to bridge the gap between "black-box" performance and "white-box" interpretability. By providing a unified, scikit-learn-compatible interface for state-of-the-art interpretable machine learning—including rule sets, lists, and trees—it enables researchers and engineers to build models that are as transparent as they are accurate.

The Journal of Open Source Software logo.

The Challenge of Interpretability

In high-stakes domains such as medicine, biology, and criminal justice, understanding the logic behind a prediction is often as critical as the prediction's accuracy. While complex ensembles like XGBoost or deep neural networks offer high predictive power, they function as "black boxes," making them difficult to audit or trust in sensitive applications.

Conversely, inherently interpretable models—which rely on simple rules or sparse logic—have historically been difficult to implement. Their codebases are often fragmented across different programming languages, lack standardized documentation, or fail to adhere to modern API conventions. imodels was developed to centralize these tools, making interpretable modeling as accessible as fitting a standard random forest.

Methods and Model Architectures

The imodels package organizes interpretable models into four primary structural forms, allowing users to choose the logic best suited for their data:

  1. Rule Sets: Collections of independent "if-then" rules (e.g., RuleFit). These are ideal for identifying specific, high-precision patterns within data.
  2. Rule Lists: Rules that execute in a specific sequence (e.g., Bayesian Rule Lists). If a condition is not met, the model proceeds to the next rule in the list.
  3. Rule Trees: Similar to standard decision trees (like CART), these utilize branching logic but are specifically optimized for simplicity and sparsity to ensure human readability.
  4. Algebraic Models: Simple mathematical expressions, such as "supersparse linear integer models," where coefficients are restricted to small integers.
Comparison of the four structural forms supported by imodels: Rule sets, Rule lists, Rule trees, and Algebraic models.

The library is fully integrated into the scikit-learn ecosystem, supporting standard workflows like GridSearchCV and Pipeline directly with these interpretable models.

Key Insights

  • Challenging the Accuracy-Interpretability Trade-off: The authors posit that for many tabular datasets, interpretable models can match the performance of black-box models while offering superior computational efficiency and transparency.
  • Unified API: By wrapping diverse algorithms in a single package, imodels removes the technical barriers to comparing different interpretable strategies.
  • Extensibility: The package provides a foundational framework for researchers to develop and test new custom rule-based models.

Software Utility and Results

As a software announcement published in the Journal of Open Source Software (JOSS), the primary contribution is the library itself.

  • Ease of Use: Fitting a complex rule-based model requires only two lines of code: model.fit(X, y) and model.predict(X).
  • Efficiency: These models are often significantly more computationally efficient than large-scale ensembles, making them suitable for real-time applications or resource-constrained environments.

Limitations and Future Directions

While imodels simplifies the application of these techniques, certain challenges remain:

  • Optimization Complexity: Finding the mathematically optimal sparse rule set is often an NP-hard problem; many algorithms in the package rely on heuristics to find high-quality, though not necessarily global, optima.
  • Feature Sensitivity: Like most rule-based systems, performance is highly dependent on the quality of input features and preprocessing.
  • Future Work: The modular design of the package is intended to facilitate the "recombining and extending" of existing methods, potentially leading to new hybrid models or improved optimization techniques for rule discovery.

Summary updated

BibTeX
@article{singh2021imodels,
  author = {Chandan Singh and Keyan Nasseri and Yan Shuo Tan and Tiffany M. Tang and Bin Yu and Yan Tan and Tiffany M. Tang and Bin Yu and Bin Yu and Keyan Nasseri},
  title = {{imodels: a python package for fitting interpretable models}},
  journal = {J. Open Source Softw.},
  year = {2021},
  doi = {10.21105/joss.03192},
}
Figure