Module imodels

Python imodels package for interpretable models compatible with scikit-learn. Github repo available here.

Interpretable machine learning models (imodels)

Straightforward implementations of interpretable ML models + demos of how to use various interpretability techniques. Code is optimized for readability. Pull requests welcome!

Implementations of imodels Demo notebookAccompanying slides

Implementations of interpretable models

Provides scikit-learn style wrappers/implementations of different interpretable models - can be easily installed and used:

pip install git+https://github.com/csinva/interpretability-implementations-demos

from imodels import RuleListClassifier, RuleFit, GreedyRuleList, SkopeRules, SLIM, IRFClassifier
model = RuleListClassifier()  # initialize Bayesian Rule List
model.fit(X_train, y_train)   # fit model
preds = model.predict(X_test) # discrete predictions: shape is (n_test, 1)
preds_proba = model.predict_proba(X_test) # predicted probabilities: shape is (n_test, n_classes)

Demo notebook

Demo on all usage is contained in this notebook, focusing on the model-based interpretability part of this cheat-sheet: cheat_sheet For post-hoc interpretability, see the github repo.

References / further reading

Expand source code
"""
Python `imodels` package for interpretable models compatible with scikit-learn.
Github repo available [here](https://github.com/csinva/interpretability-implementations-demos).
.. include:: ./documentation.md
"""

from .bayesian_rule_list.RuleListClassifier import RuleListClassifier
from .rulefit.rulefit import RuleFit
from .slim.SLIM import SLIM
from .greedy_rule_list.GreedyRuleList import GreedyRuleList
from .skrules.skope_rules import SkopeRules
from .irf.irf import IRFClassifier
# from .optimal_classification_tree import OptimalTreeModel

Sub-modules

bayesian_rule_list

bayesian rule list (based on this implementation) - learn a compact …

greedy_rule_list

greedy rule list (based on this implementation) - …

irf
optimal_classification_tree

(in progress) optimal classification tree (based on [this …

rulefit

rulefit (based on this implementation) - find rules from …

skrules

skope-rules (based on this implementation)

slim

sparse integer linear model (simple implementation with cvxpy)