{"id":13487035,"url":"https://github.com/csinva/imodels","last_synced_at":"2025-05-13T20:20:24.265Z","repository":{"id":37021953,"uuid":"195266931","full_name":"csinva/imodels","owner":"csinva","description":"Interpretable ML package 🔍 for concise, transparent, and accurate predictive modeling (sklearn-compatible).","archived":false,"fork":false,"pushed_at":"2025-03-05T14:46:53.000Z","size":169473,"stargazers_count":1449,"open_issues_count":37,"forks_count":124,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-04-28T11:57:53.083Z","etag":null,"topics":["ai","artificial-intelligence","bayesian-rule-list","data-science","explainable-ai","explainable-ml","imodels","interpretability","machine-learning","ml","optimal-classification-tree","python","rule-learning","rulefit","rules","scikit-learn","statistics","supervised-learning"],"latest_commit_sha":null,"homepage":"https://csinva.io/imodels","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csinva.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"citation.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-07-04T15:38:48.000Z","updated_at":"2025-04-28T09:25:15.000Z","dependencies_parsed_at":"2023-09-22T03:01:52.271Z","dependency_job_id":"b0d463ac-4aaf-4b75-9d27-0d3cda224021","html_url":"https://github.com/csinva/imodels","commit_stats":{"total_commits":924,"total_committers":27,"mean_commits":34.22222222222222,"dds":0.5660173160173161,"last_synced_commit":"7581f435e7e9d991643cbdef850e4e31e69ebdb7"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csinva%2Fimodels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csinva%2Fimodels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csinva%2Fimodels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csinva%2Fimodels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csinva","download_url":"https://codeload.github.com/csinva/imodels/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251311332,"owners_count":21569008,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","artificial-intelligence","bayesian-rule-list","data-science","explainable-ai","explainable-ml","imodels","interpretability","machine-learning","ml","optimal-classification-tree","python","rule-learning","rulefit","rules","scikit-learn","statistics","supervised-learning"],"created_at":"2024-07-31T18:00:54.630Z","updated_at":"2025-04-28T11:58:11.552Z","avatar_url":"https://github.com/csinva.png","language":"Jupyter Notebook","readme":"\u003cp align=\"center\"\u003e\n\t\u003cimg align=\"center\" width=60% src=\"https://csinva.io/imodels/img/imodels_logo.svg?sanitize=True\u0026kill_cache=1\"\u003e \u003c/img\u003e\t \u003cbr/\u003e\n\tPython package for concise, transparent, and accurate predictive modeling. \u003cbr/\u003e\n\tAll sklearn-compatible and easy to use. \u003cbr/\u003e\n\t\u003ci\u003e For interpretability in NLP, check out our new package: \u003ca href=\"https://github.com/csinva/imodelsX\"\u003eimodelsX\u003c/a\u003e \u003c/i\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://csinva.github.io/imodels/\"\u003e📚 docs\u003c/a\u003e •\n  \u003ca href=\"#demo-notebooks\"\u003e📖 demo notebooks\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/license-mit-blue.svg\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/python-3.9--3.11-blue\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/numpy-\u003e=2.0-blue\"\u003e\n  \u003ca href=\"https://doi.org/10.21105/joss.03192\"\u003e\u003cimg src=\"https://joss.theoj.org/papers/10.21105/joss.03192/status.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/csinva/imodels/actions\"\u003e\u003cimg src=\"https://github.com/csinva/imodels/workflows/tests/badge.svg\"\u003e\u003c/a\u003e\n  \u003c!--img src=\"https://img.shields.io/github/checks-status/csinva/imodels/master\"--\u003e\n  \u003cimg src=\"https://img.shields.io/pypi/v/imodels?color=orange\"\u003e\n  \u003cimg src=\"https://static.pepy.tech/personalized-badge/imodels?period=total\u0026units=none\u0026left_color=gray\u0026right_color=orange\u0026left_text=downloads\u0026kill_cache=12\"\u003e\n\u003c/p\u003e  \n\n\n\u003cimg align=\"center\" width=100% src=\"https://csinva.io/imodels/img/anim.gif\"\u003e \u003c/img\u003e\n\nModern machine-learning models are increasingly complex, often making them difficult to interpret. This package provides a simple interface for fitting and using state-of-the-art interpretable models, all compatible with scikit-learn. These models can often replace black-box models (e.g. random forests) with simpler models (e.g. rule lists) while improving interpretability and computational efficiency, all without sacrificing predictive accuracy! Simply import a classifier or regressor and use the `fit` and `predict` methods, same as standard scikit-learn models.\n\n```python\nfrom sklearn.model_selection import train_test_split\nfrom imodels import get_clean_dataset, HSTreeClassifierCV # import any imodels model here\n\n# prepare data (a sample clinical dataset)\nX, y, feature_names = get_clean_dataset('csi_pecarn_pred')\nX_train, X_test, y_train, y_test = train_test_split(\n    X, y, random_state=42)\n\n# fit the model\nmodel = HSTreeClassifierCV(max_leaf_nodes=4)  # initialize a tree model and specify only 4 leaf nodes\nmodel.fit(X_train, y_train, feature_names=feature_names)   # fit model\npreds = model.predict(X_test) # discrete predictions: shape is (n_test, 1)\npreds_proba = model.predict_proba(X_test) # predicted probabilities: shape is (n_test, n_classes)\nprint(model) # print the model\n```\n\n```\n------------------------------\nDecision Tree with Hierarchical Shrinkage\nPrediction is made by looking at the value in the appropriate leaf of the tree\n------------------------------\n|--- FocalNeuroFindings2 \u003c= 0.50\n|   |--- HighriskDiving \u003c= 0.50\n|   |   |--- Torticollis2 \u003c= 0.50\n|   |   |   |--- value: [0.10]\n|   |   |--- Torticollis2 \u003e  0.50\n|   |   |   |--- value: [0.30]\n|   |--- HighriskDiving \u003e  0.50\n|   |   |--- value: [0.68]\n|--- FocalNeuroFindings2 \u003e  0.50\n|   |--- value: [0.42]\n```\n\n### Installation\n\nInstall with `pip install imodels` (see [here](https://github.com/csinva/imodels/blob/master/docs/troubleshooting.md) for help).\n\n### Supported models\n\n\u003cp align=\"left\"\u003e\n\u003ca href=\"https://csinva.io/imodels/\"\u003e🗂️\u003c/a\u003e Docs \u0026emsp; 📄 Research paper \u0026emsp;  🔗 Reference code implementation\n\u003c/br\u003e\n\u003c/p\u003e\n\n| Model                       | Reference                                                    | Description                                                  |\n| :-------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |\n| Rulefit rule set            | [🗂️](https://csinva.io/imodels/rule_set/rule_fit.html), [📄](http://statweb.stanford.edu/~jhf/ftp/RuleFit.pdf), [🔗](https://github.com/christophM/rulefit) | Fits a sparse linear model on rules extracted from decision trees |\n| Skope rule set              | [🗂️](https://csinva.io/imodels/rule_set/skope_rules.html#imodels.rule_set.skope_rules.SkopeRulesClassifier), [🔗](https://github.com/scikit-learn-contrib/skope-rules) | Extracts rules from gradient-boosted trees, deduplicates them,\u003cbr/\u003ethen linearly combines them based on their OOB precision |\n| Boosted rule set            | [🗂️](https://csinva.io/imodels/rule_set/boosted_rules.html), [📄](https://www.sciencedirect.com/science/article/pii/S002200009791504X), [🔗](https://github.com/jaimeps/adaboost-implementation) | Sequentially fits a set of rules with Adaboost           |\n| Slipper rule set            | [🗂️](https://csinva.io/imodels/rule_set/slipper.html), [📄](https://www.aaai.org/Papers/AAAI/1999/AAAI99-049.pdf) | Sequentially learns a set of rules with SLIPPER            |\n| Bayesian rule set           | [🗂️](https://csinva.io/imodels/rule_set/brs.html#imodels.rule_set.brs.BayesianRuleSetClassifier), [📄](https://www.jmlr.org/papers/volume18/16-003/16-003.pdf), [🔗](https://github.com/wangtongada/BOA) | Finds concise rule set with Bayesian sampling (slow)  |\n| Optimal rule list           | [🗂️](https://csinva.io/imodels/rule_list/corels_wrapper.html#imodels.rule_list.corels_wrapper.OptimalRuleListClassifier), [📄](https://www.jmlr.org/papers/volume18/17-716/17-716.pdf), [🔗](https://github.com/corels/pycorels) | Fits rule list using global optimization for sparsity (CORELS) |\n| Bayesian rule list          | [🗂️](https://csinva.io/imodels/rule_list/bayesian_rule_list/bayesian_rule_list.html#imodels.rule_list.bayesian_rule_list.bayesian_rule_list.BayesianRuleListClassifier), [📄](https://projecteuclid.org/journals/annals-of-applied-statistics/volume-9/issue-3/Interpretable-classifiers-using-rules-and-Bayesian-analysis--Building-a/10.1214/15-AOAS848.full), [🔗](https://github.com/tmadl/sklearn-expertsys) | Fits compact rule list distribution with Bayesian sampling (slow) |\n| Greedy rule list            | [🗂️](https://csinva.io/imodels/rule_list/greedy_rule_list.html), [🔗](https://medium.com/@penggongting/implementing-decision-tree-from-scratch-in-python-c732e7c69aea) | Uses CART to fit a list (only a single path), rather than a tree |\n| OneR rule list              | [🗂️](https://csinva.io/imodels/rule_list/one_r.html), [📄](https://link.springer.com/article/10.1023/A:1022631118932) | Fits rule list restricted to only one feature              |\n| Optimal rule tree           | [🗂️](https://csinva.io/imodels/tree/gosdt/pygosdt.html#imodels.tree.gosdt.pygosdt.OptimalTreeClassifier), [📄](https://arxiv.org/abs/2006.08690), [🔗](https://github.com/Jimmy-Lin/GeneralizedOptimalSparseDecisionTrees) | Fits succinct tree using global optimization for sparsity (GOSDT) |\n| Greedy rule tree            | [🗂️](https://csinva.io/imodels/tree/cart_wrapper.html), [📄](https://www.taylorfrancis.com/books/mono/10.1201/9781315139470/classification-regression-trees-leo-breiman-jerome-friedman-richard-olshen-charles-stone), [🔗](https://scikit-learn.org/stable/modules/tree.html)  | Greedily fits tree using CART                              |\n| C4.5 rule tree        | [🗂️](https://csinva.io/imodels/tree/c45_tree/c45_tree.html#imodels.tree.c45_tree.c45_tree.C45TreeClassifier), [📄](https://link.springer.com/article/10.1007/BF00993309), [🔗](https://github.com/RaczeQ/scikit-learn-C4.5-tree-classifier) | Greedily fits tree using C4.5                           |\n| TAO rule tree        | [🗂️](https://csinva.io/imodels/tree/tao.html), [📄](https://proceedings.neurips.cc/paper/2018/hash/185c29dc24325934ee377cfda20e414c-Abstract.html) | Fits tree using alternating optimization                    |\n| Iterative random\u003cbr/\u003eforest | [🗂️](https://csinva.io/imodels/tree/iterative_random_forest/iterative_random_forest.html), [📄](https://www.pnas.org/content/115/8/1943), [🔗](https://github.com/Yu-Group/iterative-Random-Forest) | Repeatedly fit random forest, giving features with\u003cbr/\u003ehigh importance a higher chance of being selected |\n| Sparse integer\u003cbr/\u003elinear model | [🗂️](https://csinva.io/imodels/algebraic/slim.html), [📄](https://link.springer.com/article/10.1007/s10994-015-5528-6) | Sparse linear model with integer coefficients                           |\n| Tree GAM | [🗂️](https://csinva.io/imodels/algebraic/tree_gam.html), [📄](https://dl.acm.org/doi/abs/10.1145/2339530.2339556), [🔗](https://github.com/interpretml/interpret) | Generalized additive model fit with short boosted trees                           |\n| \u003cb\u003eGreedy tree\u003c/br\u003esums (FIGS)\u003c/b\u003e | [🗂️](https://csinva.io/imodels/figs.html),ㅤ[📄](https://arxiv.org/abs/2201.11931) | Sum of small trees with very few total rules (FIGS)                          |\n| \u003cb\u003eHierarchical\u003cbr/\u003e shrinkage wrapper\u003c/b\u003e | [🗂️](https://csinva.io/imodels/shrinkage.html), [📄](https://arxiv.org/abs/2202.00858) | Improve a decision tree, random forest, or\u003cbr/\u003egradient-boosting ensemble with ultra-fast, post-hoc regularization |\n| \u003cb\u003eRF+ (MDI+)\u003c/b\u003e | [🗂️](https://csinva.io/imodels/mdi_plus.html), [📄](https://arxiv.org/pdf/2307.01932) | Flexible random forest-based feature importance |\n| Distillation\u003cbr/\u003ewrapper | [🗂️](https://csinva.io/imodels/util/distillation.html)  | Train a black-box model,\u003cbr/\u003ethen distill it into an interpretable model |\n| AutoML wrapper | [🗂️](https://csinva.io/imodels/util/automl.html)  | Automatically fit and select an interpretable model |\n| More models                 | ⌛                                                            | (Coming soon!) Lightweight Rule Induction, MLRules, ... |\n\n## Demo notebooks\n\nDemos are contained in the [notebooks](notebooks) folder.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ca href=\"https://github.com/csinva/imodels/blob/master/notebooks/imodels_demo.ipynb\"\u003eQuickstart demo\u003c/a\u003e\u003c/summary\u003e\nShows how to fit, predict, and visualize with different interpretable models\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ca href=\"https://auto.gluon.ai/dev/tutorials/tabular_prediction/tabular-interpretability.html\"\u003eAutogluon demo\u003c/a\u003e\u003c/summary\u003e\nFit/select an interpretable model automatically using Autogluon AutoML\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ca href=\"https://colab.research.google.com/drive/1WfqvSjegygT7p0gyqiWpRpiwz2ePtiao#scrollTo=bLnLknIuoWtQ\"\u003eQuickstart colab demo\u003c/a\u003e \u003ca href=\"https://colab.research.google.com/drive/1WfqvSjegygT7p0gyqiWpRpiwz2ePtiao#scrollTo=bLnLknIuoWtQ\"\u003e \u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\"\u003e\u003c/a\u003e\u003c/summary\u003e\nShows how to fit, predict, and visualize with different interpretable models\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ca href=\"https://github.com/csinva/iai-clinical-decision-rule/blob/master/notebooks/05_fit_interpretable_models.ipynb\"\u003eClinical decision rule notebook\u003c/a\u003e\u003c/summary\u003e\nShows an example of using \u003ccode\u003eimodels\u003c/code\u003e for deriving a clinical decision rule\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003ePosthoc analysis\u003c/summary\u003e\nWe also include some demos of posthoc analysis, which occurs after fitting models:\n\u003ca href=\"https://github.com/csinva/imodels/blob/master/notebooks/posthoc_analysis.ipynb\"\u003eposthoc.ipynb\u003c/a\u003e shows different simple analyses to interpret a trained model and \n\u003ca href=\"https://github.com/csinva/imodels/blob/master/notebooks/uncertainty_analysis.ipynb\"\u003euncertainty.ipynb\u003c/a\u003e contains basic code to get uncertainty estimates for a model\n\u003c/details\u003e\n\n## What's the difference between the models?\n\nThe final form of the above models takes one of the following forms, which aim to be simultaneously simple to understand and highly predictive:\n\n|                           Rule set                           |                        Rule list                        |                        Rule tree                        |                       Algebraic models                       |\n| :----------------------------------------------------------: | :-----------------------------------------------------: | :-----------------------------------------------------: | :----------------------------------------------------------: |\n| \u003cimg src=\"https://csinva.io/imodels/img/rule_set.jpg\" width=\"100%\"\u003e | \u003cimg src=\"https://csinva.io/imodels/img/rule_list.jpg\"\u003e | \u003cimg src=\"https://csinva.io/imodels/img/rule_tree.jpg\"\u003e | \u003cimg src=\"https://csinva.io/imodels/img/algebraic_models.jpg\"\u003e |\n\nDifferent models and algorithms vary not only in their final form but also in different choices made during modeling, such as how they generate, select, and postprocess rules:\n\n|                  Rule candidate generation                   |                       Rule selection                       |                Rule postprocessing|\n| :----------------------------------------------------------: | :--------------------------------------------------------: | :-------------------------------------------------------: |\n| \u003cimg src=\"https://csinva.io/imodels/img/rule_candidates.jpg\"\u003e | \u003cimg src=\"https://csinva.io/imodels/img/rule_overfit.jpg\"\u003e | \u003cimg src=\"https://csinva.io/imodels/img/rule_pruned.jpg\"\u003e |\n\n\u003cdetails\u003e\n\u003csummary\u003eEx. RuleFit vs. SkopeRules\u003c/summary\u003e\nRuleFit and SkopeRules differ only in the way they prune rules: RuleFit uses a linear model whereas SkopeRules heuristically deduplicates rules sharing overlap.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eEx. Bayesian rule lists vs. greedy rule lists\u003c/summary\u003e\nBayesian rule lists and greedy rule lists differ in how they select rules; bayesian rule lists perform a global optimization over possible rule lists while Greedy rule lists pick splits sequentially to maximize a given criterion.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eEx. FPSkope vs. SkopeRules\u003c/summary\u003e\nFPSkope and SkopeRules differ only in the way they generate candidate rules: FPSkope uses FPgrowth whereas SkopeRules extracts rules from decision trees.\n\u003c/details\u003e\n\n## Support for different tasks\n\nDifferent models support different machine-learning tasks. Current support for different models is given below (each of these models can be imported directly from imodels (e.g. `from imodels import RuleFitClassifier`):\n\n| Model                       |                    Binary classification                     |                          Regression                          | Notes |\n| :-------------------------- | :----------------------------------------------------------: | :----------------------------------------------------------: | --------------------------- |\n| Rulefit rule set            | [RuleFitClassifier](https://csinva.io/imodels/rule_set/rule_fit.html#imodels.rule_set.rule_fit.RuleFitClassifier) | [RuleFitRegressor](https://csinva.io/imodels/rule_set/rule_fit.html#imodels.rule_set.rule_fit.RuleFitRegressor) |  |\n| Skope rule set              | [SkopeRulesClassifier](https://csinva.io/imodels/rule_set/skope_rules.html#imodels.rule_set.skope_rules.SkopeRulesClassifier) |                                                              |  |\n| Boosted rule set            | [BoostedRulesClassifier](https://csinva.io/imodels/rule_set/boosted_rules.html#imodels.rule_set.boosted_rules.BoostedRulesClassifier) | [BoostedRulesRegressor](https://csinva.io/imodels/rule_set/boosted_rules.html#imodels.rule_set.boosted_rules.BoostedRulesRegressor) |  |\n| SLIPPER rule set            | [SlipperClassifier](https://csinva.io/imodels/rule_set/slipper.html#imodels.rule_set.slipper.SlipperClassifier) |                                                              |  |\n| Bayesian rule set           | [BayesianRuleSetClassifier](https://csinva.io/imodels/rule_set/brs.html#imodels.rule_set.brs.BayesianRuleSetClassifier) |                                                              | Fails for large problems |\n| Optimal rule list (CORELS)  | [OptimalRuleListClassifier](https://csinva.io/imodels/rule_list/corels_wrapper.html#imodels.rule_list.corels_wrapper.OptimalRuleListClassifier) |                                                              | Requires [corels](https://pypi.org/project/corels/), fails for large problems |\n| Bayesian rule list          | [BayesianRuleListClassifier](https://csinva.io/imodels/rule_list/bayesian_rule_list/bayesian_rule_list.html#imodels.rule_list.bayesian_rule_list.bayesian_rule_list.BayesianRuleListClassifier) |                                                              |  |\n| Greedy rule list            | [GreedyRuleListClassifier](https://csinva.io/imodels/rule_list/greedy_rule_list.html#imodels.rule_list.greedy_rule_list.GreedyRuleListClassifier) |                                                              |  |\n| OneR rule list              | [OneRClassifier](https://csinva.io/imodels/rule_list/one_r.html#imodels.rule_list.one_r.OneRClassifier) |                                                              |  |\n| Optimal rule tree (GOSDT)   | [OptimalTreeClassifier](https://csinva.io/imodels/tree/gosdt/pygosdt.html#imodels.tree.gosdt.pygosdt.OptimalTreeClassifier) |                                                              | Requires [gosdt](https://pypi.org/project/gosdt/), fails for large problems |\n| Greedy rule tree (CART)     | [GreedyTreeClassifier](https://csinva.io/imodels/tree/cart_wrapper.html#imodels.tree.cart_wrapper.GreedyTreeClassifier) |      [GreedyTreeRegressor](https://csinva.io/imodels/tree/cart_wrapper.html#imodels.tree.cart_wrapper.GreedyTreeRegressor)                                                        |  |\n| C4.5 rule tree              | [C45TreeClassifier](https://csinva.io/imodels/tree/c45_tree/c45_tree.html#imodels.tree.c45_tree.c45_tree.C45TreeClassifier) |           |  |\n| TAO rule tree              | [TaoTreeClassifier](https://csinva.io/imodels/tree/tao.html#imodels.tree.tao.TaoTreeClassifier) |   [TaoTreeRegressor](https://csinva.io/imodels/tree/tao.html#imodels.tree.tao.TaoTreeRegressor)        |  |\n| Iterative random forest     | [IRFClassifier](https://csinva.io/imodels/tree/iterative_random_forest/iterative_random_forest.html#imodels.tree.iterative_random_forest.iterative_random_forest.IRFClassifier)                                                             |                                                              | Requires [irf](https://pypi.org/project/irf/) |\n| Sparse integer linear model | [SLIMClassifier](https://csinva.io/imodels/algebraic/slim.html#imodels.algebraic.slim.SLIMClassifier) | [SLIMRegressor](https://csinva.io/imodels/algebraic/slim.html#imodels.algebraic.slim.SLIMRegressor) | Requires extra dependencies for speed |\n| Tree GAM | [TreeGAMClassifier](https://csinva.io/imodels/algebraic/tree_gam.html) | [TreeGAMRegressor](https://csinva.io/imodels/algebraic/tree_gam.html) | |\n| Greedy tree sums (FIGS) | [FIGSClassifier](https://csinva.io/imodels/tree/figs.html#imodels.tree.figs.FIGSClassifier) | [FIGSRegressor](https://csinva.io/imodels/tree/figs.html#imodels.tree.figs.FIGSRegressor) |                                                              |\n| Hierarchical shrinkage | [HSTreeClassifierCV](https://csinva.io/imodels/tree/hierarchical_shrinkage.html#imodels.tree.hierarchical_shrinkage.HSTreeClassifierCV) | [HSTreeRegressorCV](https://csinva.io/imodels/tree/hierarchical_shrinkage.html#imodels.tree.hierarchical_shrinkage.HSTreeRegressorCV) | Wraps any sklearn tree-based model |\n| Distillation |  | [DistilledRegressor](https://csinva.io/imodels/util/distillation.html#imodels.util.distillation.DistilledRegressor) | Wraps any sklearn-compatible models |\n| AutoML model | [AutoInterpretableClassifier️](https://csinva.io/imodels/util/automl.html)  | [AutoInterpretableRegressor️](https://csinva.io/imodels/util/automl.html) | |\n\n\n### Extras\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ca href=\"https://csinva.io/imodels/util/data_util.html#imodels.util.data_util.get_clean_dataset\"\u003eData-wrangling functions\u003c/a\u003e for working with popular tabular datasets (e.g. compas).\u003c/summary\u003e\nThese functions, in conjunction with \u003ca href=\"https://github.com/csinva/imodels-data\"\u003eimodels-data\u003c/a\u003e and \u003ca href=\"https://github.com/Yu-Group/imodels-experiments\"\u003eimodels-experiments\u003c/a\u003e, make it simple to download data and run experiments on new models.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ca href=\"https://csinva.io/imodels/util/explain_errors.html\"\u003eExplain classification errors\u003c/a\u003e with a simple posthoc function.\u003c/summary\u003e\nFit an interpretable model to explain a previous model's errors (ex. in \u003ca href=\"https://github.com/csinva/imodels/blob/master/notebooks/error_detection_demo.ipynb\"\u003ethis notebook📓\u003c/a\u003e).\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ca href=\"https://csinva.io/imodels/discretization/index.html\"\u003eFast and effective discretizers\u003c/a\u003e for data preprocessing.\u003c/summary\u003e\n\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eDiscretizer\u003c/th\u003e\n\u003cth\u003eReference\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003eMDLP\u003c/td\u003e\n\u003ctd\u003e\u003ca href=\"https://csinva.io/imodels/discretization/mdlp.html#imodels.discretization.mdlp.MDLPDiscretizer\"\u003e🗂️\u003c/a\u003e, \u003ca href=\"https://github.com/navicto/Discretization-MDLPC\"\u003e🔗\u003c/a\u003e, \u003ca href=\"https://trs.jpl.nasa.gov/handle/2014/35171\"\u003e📄\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eDiscretize using entropy minimization heuristic\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eSimple\u003c/td\u003e\n\u003ctd\u003e\u003ca href=\"https://csinva.io/imodels/discretization/simple.html#imodels.discretization.simple.SimpleDiscretizer\"\u003e🗂️\u003c/a\u003e, \u003ca href=\"https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.KBinsDiscretizer.html\"\u003e🔗\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eSimple KBins discretization\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eRandom Forest\u003c/td\u003e\n\u003ctd\u003e\u003ca href=\"https://csinva.io/imodels/discretization/discretizer.html#imodels.discretization.discretizer.RFDiscretizer\"\u003e🗂️\u003c/a\u003e\u003c/td\u003e\n\u003ctd\u003eDiscretize into bins based on random forest split popularity\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ca href=\"https://csinva.io/imodels/util/index.html\"\u003eRule-based utils\u003c/a\u003e for customizing models\u003c/summary\u003e\nThe code here contains many useful and customizable functions for rule-based learning in the \u003ca href=\"https://csinva.io/imodels/util/index.html\"\u003eutil folder\u003c/a\u003e. This includes functions / classes for rule deduplication, rule screening, and converting between trees, rulesets, and neural networks.\n\u003c/details\u003e\n\n## Our favorite models\n\nAfter developing and playing with `imodels`, we developed a few new models to overcome limitations of existing interpretable models.\n\n### FIGS: Fast interpretable greedy-tree sums\n\n[📄 Paper](https://arxiv.org/abs/2201.11931), [🔗 Post](https://csinva.io/imodels/figs.html), [📌 Citation](https://scholar.google.com/scholar?hl=en\u0026as_sdt=0%2C5\u0026q=fast+interpretable+greedy-tree+sums\u0026oq=fast#d=gs_cit\u0026u=%2Fscholar%3Fq%3Dinfo%3ADnPVL74Rop0J%3Ascholar.google.com%2F%26output%3Dcite%26scirp%3D0%26hl%3Den)\n\nFast Interpretable Greedy-Tree Sums (FIGS) is an algorithm for fitting concise rule-based models. Specifically, FIGS generalizes CART to simultaneously grow a flexible number of trees in a summation. The total number of splits across all the trees can be restricted by a pre-specified threshold, keeping the model interpretable. Experiments across a wide array of real-world datasets show that FIGS achieves state-of-the-art prediction performance when restricted to just a few splits (e.g. less than 20).\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://demos.csinva.io/figs/diabetes_figs.svg?sanitize=True\" width=\"50%\"\u003e\n\u003c/p\u003e  \n\u003cp align=\"center\"\u003e\t\n\t\u003ci\u003e\u003cb\u003eExample FIGS model.\u003c/b\u003e FIGS learns a sum of trees with a flexible number of trees; to make its prediction, it sums the result from each tree.\u003c/i\u003e\n\u003c/p\u003e\n\n### Hierarchical shrinkage: post-hoc regularization for tree-based methods\n\n[📄 Paper](https://arxiv.org/abs/2202.00858) (ICML 2022), [🔗 Post](https://csinva.io/imodels/shrinkage.html), [📌 Citation](https://scholar.google.com/scholar?hl=en\u0026as_sdt=0%2C5\u0026q=hierarchical+shrinkage+singh\u0026btnG=\u0026oq=hierar#d=gs_cit\u0026u=%2Fscholar%3Fq%3Dinfo%3Azc6gtLx-aL4J%3Ascholar.google.com%2F%26output%3Dcite%26scirp%3D0%26hl%3Den)\n\nHierarchical shrinkage is an extremely fast post-hoc regularization method which works on any decision tree (or tree-based ensemble, such as Random Forest). It does not modify the tree structure, and instead regularizes the tree by shrinking the prediction over each node towards the sample means of its ancestors (using a single regularization parameter). Experiments over a wide variety of datasets show that hierarchical shrinkage substantially increases the predictive performance of individual decision trees and decision-tree ensembles.\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://demos.csinva.io/shrinkage/shrinkage_intro.svg?sanitize=True\" width=\"75%\"\u003e\n\u003c/p\u003e  \n\u003cp align=\"center\"\u003e\t\n\t\u003ci\u003e\u003cb\u003eHS Example.\u003c/b\u003e HS applies post-hoc regularization to any decision tree by shrinking each node towards its parent.\u003c/i\u003e\n\u003c/p\u003e\n\n### MDI+: Flexible Tree-Based Feature Importance\n\n[📄 Paper](https://arxiv.org/pdf/2307.01932.pdf), [🔗 Post](https://csinva.io/imodels/mdi_plus.html), [📌 Citation](https://scholar.google.com/scholar?hl=en\u0026as_sdt=0%2C23\u0026q=MDI%2B%3A+A+Flexible+Random+Forest-Based+Feature+Importance+Framework\u0026btnG=#d=gs_cit\u0026t=1690399844081\u0026u=%2Fscholar%3Fq%3Dinfo%3Axc0LcHXE_lUJ%3Ascholar.google.com%2F%26output%3Dcite%26scirp%3D0%26hl%3Den)\n\nMDI+ is a novel feature importance framework, which generalizes the popular mean decrease in impurity (MDI) importance score for random forests. At its core, MDI+ expands upon a recently discovered connection between linear regression and decision trees. In doing so, MDI+ enables practitioners to (1) tailor the feature importance computation to the data/problem structure and (2) incorporate additional features or knowledge to mitigate known biases of decision trees. In both real data case studies and extensive real-data-inspired simulations, MDI+ outperforms commonly used feature importance measures (e.g., MDI, permutation-based scores, and TreeSHAP) by substantional margins.\n\n\n## References\n\n\u003cdetails\u003e\n\u003csummary\u003eReadings\u003c/summary\u003e\n\u003cul\u003e\n  \u003cli\u003eInterpretable ML good quick overview: murdoch et al. 2019, \u003ca href=\"https://arxiv.org/pdf/1901.04592.pdf\"\u003epdf\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003eInterpretable ML book: molnar 2019, \u003ca href=\"https://christophm.github.io/interpretable-ml-book/\"\u003epdf\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003eCase for interpretable models rather than post-hoc explanation: rudin 2019, \u003ca href=\"https://arxiv.org/pdf/1811.10154.pdf\"\u003epdf\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003eReview on evaluating interpretability: doshi-velez \u0026 kim 2017, \u003ca href=\"https://arxiv.org/pdf/1702.08608.pdf\"\u003epdf\u003c/a\u003e\u003c/li\u003e\t\n\u003c/ul\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eReference implementations (also linked above)\u003c/summary\u003e\nThe code here heavily derives from the wonderful work of previous projects. We seek to to extract out, unify, and maintain key parts of these projects.\n\u003cul\u003e\n  \u003cli\u003e\u003ca href=\"https://github.com/corels/pycorels\"\u003epycorels\u003c/a\u003e - by \u003ca href=\"https://github.com/fingoldin\"\u003e@fingoldin\u003c/a\u003e and the \u003ca href=\"https://github.com/corels/corels\"\u003eoriginal CORELS team\u003c/a\u003e\n  \u003cli\u003e\u003ca href=\"https://github.com/tmadl/sklearn-expertsys\"\u003esklearn-expertsys\u003c/a\u003e - by \u003ca href=\"https://github.com/tmadl\"\u003e@tmadl\u003c/a\u003e and \u003ca href=\"https://github.com/kenben\"\u003e@kenben\u003c/a\u003e based on original code by \u003ca href=\"http://lethalletham.com/\"\u003eBen Letham\u003c/a\u003e\u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"https://github.com/christophM/rulefit\"\u003erulefit\u003c/a\u003e - by \u003ca href=\"https://github.com/christophM\"\u003e@christophM\u003c/a\u003e\u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"https://github.com/scikit-learn-contrib/skope-rules\"\u003eskope-rules\u003c/a\u003e - by the \u003ca href=\"https://github.com/scikit-learn-contrib/skope-rules/blob/master/AUTHORS.rst\"\u003eskope-rules team\u003c/a\u003e (including \u003ca href=\"https://github.com/ngoix\"\u003e@ngoix\u003c/a\u003e, \u003ca href=\"https://github.com/floriangardin\"\u003e@floriangardin\u003c/a\u003e, \u003ca href=\"https://github.com/datajms\"\u003e@datajms\u003c/a\u003e, \u003ca href=\"\"\u003eBibi Ndiaye\u003c/a\u003e, \u003ca href=\"\"\u003eRonan Gautier\u003c/a\u003e)\u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"https://github.com/wangtongada/BOA\"\u003eboa\u003c/a\u003e - by \u003ca href=\"https://github.com/wangtongada\"\u003e@wangtongada\u003c/a\u003e\u003c/li\u003e\t\n\u003c/ul\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eRelated packages\u003c/summary\u003e\n\u003cul\u003e\n  \u003cli\u003e\u003ca href=\"https://github.com/trevorstephens/gplearn/tree/ad57cb18caafdb02cca861aea712f1bf3ed5016e\"\u003egplearn\u003c/a\u003e: symbolic regression/classification\u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"https://github.com/MilesCranmer/PySR\"\u003epysr\u003c/a\u003e: fast symbolic regression\u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"https://github.com/dswah/pyGAM\"\u003epygam\u003c/a\u003e: generative additive models\u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"https://github.com/interpretml/interpret\"\u003einterpretml\u003c/a\u003e: boosting-based gam\u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"https://github.com/h2oai/h2o-3\"\u003eh20 ai\u003c/a\u003e: gams + glms (and more)\u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"https://github.com/guillermo-navas-palencia/optbinning\"\u003eoptbinning\u003c/a\u003e: data discretization / scoring models\u003c/li\u003e\t\n\u003c/ul\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eUpdates\u003c/summary\u003e\n\u003cul\u003e\n  \u003cli\u003eFor updates, star the repo, \u003ca href=\"https://github.com/csinva/csinva.github.io\"\u003esee this related repo\u003c/a\u003e, or follow \u003ca href=\"https://twitter.com/csinva_\"\u003e@csinva_\u003c/a\u003e\u003c/li\u003e\n  \u003cli\u003ePlease make sure to give authors of original methods / base implementations appropriate credit!\u003c/li\u003e\n  \u003cli\u003eContributing: pull requests \u003ca href=\"https://github.com/csinva/imodels/blob/master/docs/contributing.md\"\u003every welcome\u003c/a\u003e!\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/details\u003e\n\n\nPlease cite the package if you use it in an academic work :)\n\n```r\n@software{\n\timodels2021,\n\ttitle        = {imodels: a python package for fitting interpretable models},\n\tjournal      = {Journal of Open Source Software},\n\tpublisher    = {The Open Journal},\n\tyear         = {2021},\n\tauthor       = {Singh, Chandan and Nasseri, Keyan and Tan, Yan Shuo and Tang, Tiffany and Yu, Bin},\n\tvolume       = {6},\n\tnumber       = {61},\n\tpages        = {3192},\n\tdoi          = {10.21105/joss.03192},\n\turl          = {https://doi.org/10.21105/joss.03192},\n}\n\n```\n","funding_links":[],"categories":["Jupyter Notebook","The Data Science Toolbox","Python Libraries(sort in alphabeta order)","其他_机器学习与深度学习","Tools","模型的可解释性","🏠 Explainable AI Library","Technical Resources"],"sub_categories":["General Machine Learning Packages","Evaluation methods","Interpretable Models","Subtask Scheduling with Human Annotation","Open Source/Access Responsible AI Software Packages"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsinva%2Fimodels","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsinva%2Fimodels","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsinva%2Fimodels/lists"}