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 notebook • Accompanying 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)
- bayesian rule list (based on this implementation) - learn a compact rule list
- rulefit (based on this implementation) - find rules from a decision tree and build a linear model with them
- sparse integer linear model (simple implementation with cvxpy)
- greedy rule list (based on this implementation) - uses CART to learn a list (only a single path), rather than a decision tree
- skope-rules (based on this implementation)
- (in progress) optimal classification tree (based on this implementation) - learns succinct trees using global optimization rather than greedy heuristics
- iterative random forest (based on this implementation)
Demo notebook
Demo on all usage is contained in this notebook, focusing on the model-based interpretability part of this cheat-sheet:
For post-hoc interpretability, see the
github repo.
References / further reading
- high-level review on interpretable machine learning
- book on interpretable machine learning
- review on black-blox explanation methods
- review on variable importance
- for updates, star the repo, see this related repo, or follow @chandan_singh96
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)