csinva/imodels
Interpretable ML package 🔍 for concise, transparent, and accurate predictive modeling (sklearn-compatible).
imodels – Interpretable Machine‑Learning Models for Python
What it is – imodels is a Python library that bundles a large collection of interpretable supervised‑learning algorithms (rule‑based, tree‑based, and sparse linear models) and makes them usable through the familiar scikit‑learn estimator API (fit, predict, predict_proba, etc.). The package is aimed at practitioners who need models that are both accurate and easy to understand, for example in clinical decision‑support, finance, or any regulated domain.
Key features (as described in the README)
- Wide model catalogue – rule‑set learners (RuleFit, SkopeRules, BoostedRules, SLIPPER, Bayesian rule set/list), rule‑list learners (Greedy, OneR, Fast‑and‑Frugal trees), tree learners (CART, C4.5, TAO, hierarchical‑shrinkage wrappers), and algebraic models (SLIM integer‑coefficient linear models, Tree‑GAM, FIGS – greedy tree sums, BART, marginal‑shrinkage linear models). Each can be imported directly, e.g.
from imodels import RuleFitClassifier. - Scikit‑learn compatibility – all estimators implement the standard estimator methods, work inside pipelines, support hyper‑parameter search, and return proper
feature_names_in_attributes. - Post‑hoc utilities – wrappers for distillation (train a black‑box then compress it into an interpretable model) and AutoML (automatically select the best interpretable model for a given dataset).
- Model‑specific tricks – hierarchical shrinkage (
HSTree*) adds ultra‑fast regularisation to any tree‑based model; RF+ (MDI+) provides a more flexible random‑forest feature‑importance metric. - Installation –
pip install imodels(Python 3.10‑3.13, NumPy ≥ 2.0). Badges show MIT license, PyPI version, download count, CI status, and a JOSS paper. - Documentation & demos – online docs, a JOSS research paper, and several Jupyter notebooks (quick‑start, clinical decision‑rule example, post‑hoc analysis, uncertainty estimates, Autogluon AutoML demo).
Typical usage (from the README)
from imodels import get_clean_dataset, HSTreeClassifierCV
from sklearn.model_selection import train_test_split
X, y, feature_names = get_clean_dataset('csi_pecarn_pred')
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
model = HSTreeClassifierCV(max_leaf_nodes=4) # a shrinkage‑regularised decision tree
model.fit(X_train, y_train, feature_names=feature_names)
preds = model.predict(X_test)
preds_proba = model.predict_proba(X_test)
print(model) # prints a compact textual representation of the tree
The output shows a tiny decision tree with only four leaves, illustrating the library’s focus on concise models.
Why it matters – Modern ensembles (random forests, gradient‑boosted trees, deep nets) often achieve high accuracy but are opaque. imodels lets users replace many of those black‑box models with rule‑based or sparse linear alternatives that retain predictive performance while being transparent, easily audited, and fast to evaluate.
Where to go next – The README points to two companion projects:
imodelsXfor text‑based interpretability,agentic-imodelsfor agent‑driven interpretability on tabular data.
All information above is taken directly from the repository’s README; no external assumptions have been added.
Related
- Project
- Project
- Project
- Project
- Project