/interpretability-implementations-demos

Sklearn-compatible interpretability implementations and demos.

Primary LanguageJupyter NotebookMIT LicenseMIT

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 notebooksAccompanying slides

Implementations of interpretable models

Scikit-learn style wrappers/implementations of different interpretable models. Docs is available here. The interpretable models within the imodels folder 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 notebooks

The demos are contained in 3 main notebooks, following this cheat-sheet:cheat_sheet

  1. model_based.ipynb - how to use different interpretable models
  2. posthoc.ipynb - different simple analyses to interpret a trained model
  3. uncertainty.ipynb - code to get uncertainty estimates for a model

References / further reading