{"id":19540627,"url":"https://github.com/mauroluzzatto/explainy","last_synced_at":"2025-10-07T05:04:21.288Z","repository":{"id":46774677,"uuid":"379706214","full_name":"MauroLuzzatto/explainy","owner":"MauroLuzzatto","description":"explainy is a Python library for generating machine learning model explanations for humans","archived":false,"fork":false,"pushed_at":"2025-04-27T18:42:30.000Z","size":2015,"stargazers_count":18,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-14T14:16:46.901Z","etag":null,"topics":["data-science","explanation","machine-learning","machine-learning-explainability","python","scikit-learn"],"latest_commit_sha":null,"homepage":"https://explainy.readthedocs.io","language":"Python","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/MauroLuzzatto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-06-23T19:13:42.000Z","updated_at":"2025-04-27T18:42:34.000Z","dependencies_parsed_at":"2024-01-13T21:39:38.747Z","dependency_job_id":"38d1d51e-1e88-4f93-9570-ae176c30900d","html_url":"https://github.com/MauroLuzzatto/explainy","commit_stats":{"total_commits":240,"total_committers":1,"mean_commits":240.0,"dds":0.0,"last_synced_commit":"1d3b2124e7baf830956a36293fdfd8d378a05e30"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/MauroLuzzatto/explainy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MauroLuzzatto%2Fexplainy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MauroLuzzatto%2Fexplainy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MauroLuzzatto%2Fexplainy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MauroLuzzatto%2Fexplainy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MauroLuzzatto","download_url":"https://codeload.github.com/MauroLuzzatto/explainy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MauroLuzzatto%2Fexplainy/sbom","scorecard":{"id":91680,"data":{"date":"2025-08-11","repo":{"name":"github.com/MauroLuzzatto/explainy","commit":"031faf04d1682cdfdeba3d88a94b1304bb97908d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/tests.yaml:1","Warn: no topLevel permission defined: .github/workflows/workflow.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yaml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/MauroLuzzatto/explainy/tests.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yaml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/MauroLuzzatto/explainy/tests.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yaml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/MauroLuzzatto/explainy/tests.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/workflow.yml:8: update your workflow using https://app.stepsecurity.io/secureworkflow/MauroLuzzatto/explainy/workflow.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/workflow.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/MauroLuzzatto/explainy/workflow.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/workflow.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/MauroLuzzatto/explainy/workflow.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/workflow.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/MauroLuzzatto/explainy/workflow.yml/main?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/tests.yaml:25","Warn: pipCommand not pinned by hash: .github/workflows/tests.yaml:26","Warn: pipCommand not pinned by hash: .github/workflows/tests.yaml:30","Warn: pipCommand not pinned by hash: .github/workflows/tests.yaml:31","Warn: pipCommand not pinned by hash: .github/workflows/workflow.yml:25","Warn: pipCommand not pinned by hash: .github/workflows/workflow.yml:26","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   6 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"18 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-29gw-9793-fvw7","Warn: Project is vulnerable to: PYSEC-2015-24 / GHSA-4vwq-x64q-j4cj","Warn: Project is vulnerable to: PYSEC-2017-46 / GHSA-66gw-5xpf-gfp5","Warn: Project is vulnerable to: PYSEC-2015-25 / GHSA-92mr-v722-f48m","Warn: Project is vulnerable to: PYSEC-2022-12 / GHSA-pq7m-3gw7-gq5x","Warn: Project is vulnerable to: PYSEC-2017-47","Warn: Project is vulnerable to: PYSEC-2020-73","Warn: Project is vulnerable to: PYSEC-2024-48 / GHSA-fj7x-q9j7-g6q6","Warn: Project is vulnerable to: GHSA-cpwx-vrp4-4pq7","Warn: Project is vulnerable to: GHSA-gmj6-6f8f-6699","Warn: Project is vulnerable to: GHSA-q2x7-8rv6-6q7h","Warn: Project is vulnerable to: GHSA-55x5-fj6c-h6m8","Warn: Project is vulnerable to: PYSEC-2014-9 / GHSA-57qw-cc2g-pv5p","Warn: Project is vulnerable to: PYSEC-2021-19 / GHSA-jq4v-f5q6-mjqq","Warn: Project is vulnerable to: GHSA-pgww-xf46-h92r","Warn: Project is vulnerable to: PYSEC-2022-230 / GHSA-wrxv-2j5q-m38w","Warn: Project is vulnerable to: PYSEC-2018-12 / GHSA-xp26-p53h-6h2p","Warn: Project is vulnerable to: PYSEC-2022-43017 / GHSA-qwmp-2cf2-g9g6"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 23 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-15T08:03:08.667Z","repository_id":46774677,"created_at":"2025-08-15T08:03:08.667Z","updated_at":"2025-08-15T08:03:08.667Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278722757,"owners_count":26034463,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["data-science","explanation","machine-learning","machine-learning-explainability","python","scikit-learn"],"created_at":"2024-11-11T03:05:15.159Z","updated_at":"2025-10-07T05:04:21.282Z","avatar_url":"https://github.com/MauroLuzzatto.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003c!-- \u003cimg src=\"https://github.com/MauroLuzzatto/explainy/raw/main/docs/_static/logo.png\" width=\"180\" height=\"180\" align=\"right\"/\u003e --\u003e\n\u003cp align=\"center\"\u003e\n\n\u003cimg src=\"https://github.com/MauroLuzzatto/explainy/raw/main/docs/_static/logo.png\" height=\"350\"/\u003e\n\n\u003c/p\u003e\n\u003c!-- # explainy - machine learning model explanations for humans --\u003e\n\u003c!-- # explainy - black-box model explanations for humans --\u003e\n\n\u003ch1 align=\"center\"\u003eblack-box model explanations for humans\u003c/h1\u003e\n\n[![pypi version](https://img.shields.io/pypi/v/explainy.svg)](https://pypi.python.org/pypi/explainy)\n[![codecov](https://codecov.io/gh/MauroLuzzatto/explainy/branch/main/graph/badge.svg?token=N6EKHMEAQR)](https://codecov.io/gh/MauroLuzzatto/explainy)\n[![docs](https://readthedocs.org/projects/explainy/badge/?version=latest)](https://explainy.readthedocs.io/en/latest/?version=latest)\n[![Supported versions](https://img.shields.io/pypi/pyversions/explainy.svg)](https://pypi.org/project/explainy)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/ambv/black)\n[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat\u0026labelColor=ef8336)](https://pycqa.github.io/isort/)\n[![Downloads](https://pepy.tech/badge/explainy)](https://pepy.tech/project/explainy)\n\n\n**explainy** is a library for generating machine learning models explanations in Python. It uses methods from **Machine Learning Explainability** and provides a standardized API to create feature importance explanations for samples. \n\nThe API is inspired by `scikit-learn` and has three core methods `explain()`, `plot()` and, `importance()`. The explanations are generated in the form of texts and plots.\n\n**explainy** comes with four different algorithms to create either *global* or *local* and *contrastive* or *non-contrastive* model explanations.\n\n\n| Method\t\t\t\t|Type | Explanations | Classification | Regression | \n| --- \t\t\t\t| --- | :---: | :---: | :---: | \n|[Permutation Feature Importance](https://explainy.readthedocs.io/en/latest/explainy.explanations.html#module-explainy.explanation.permutation_explanation)\t| non-contrastive | global |  :star: | :star:|\n|[Shap Values](https://explainy.readthedocs.io/en/latest/explainy.explanations.html?highlight=shap#module-explainy.explanations.shap_explanation)\t\t| non-contrastive | local |   \t:star: | :star:|\n|[Surrogate Model](https://explainy.readthedocs.io/en/latest/explainy.explanations.html#module-explainy.explanation.surrogate_model_explanation)|contrastive | global | :star: | :star: | \n|[Counterfactual Example](https://explainy.readthedocs.io/en/latest/explainy.explanations.html#module-explainy.explanation.counterfactual_explanation)| contrastive | local |:star:| :star:|\n\n\nDescription:\n- **global**: explanation of system functionality (all samples have the same explanation)\n- **local**: explanation of decision rationale (each sample has its own explanation)\n- **contrastive**: tracing of decision path (differences to other outcomes are described)\n- **non-contrastive**: parameter weighting (the feature importance is reported)\n\n\n## Documentation\nhttps://explainy.readthedocs.io\n\n\n## Install explainy\n\n\n\n```\npip install explainy\n```\n\n---\n\nFurther, install `graphviz` (version 9.0.0 or later) for plotting tree surrogate models:\n\n#### Windows\n```\nchoco install graphviz\n```\n\n#### Mac\n```\nbrew install graphviz\n```\n#### Linux: Ubuntu packages\n```\nsudo apt install graphviz\n```\n\nFurther details on how to install `graphviz` can be found in the official [graphviz docs](https://graphviz.org/download/).\n\nAlso, make sure that the folder with the `dot` executable is added to your systems `PATH`. You can find further details [here](https://github.com/xflr6/graphviz?tab=readme-ov-file#installation).\n\n## Usage\n\n📚 A comprehensive example of the `explainy` API can be found in this ![Jupyter Notebook](https://github.com/MauroLuzzatto/explainy/blob/main/examples/01-explainy-intro.ipynb) \n \n📖 Or in the [example section](https://explainy.readthedocs.io/en/latest/examples/01-explainy-intro.html) of the documentation\n\n\nInitialize and train a `scikit-learn` model:\n```python\nimport pandas as pd\nfrom sklearn.datasets import load_diabetes\nfrom sklearn.ensemble import RandomForestRegressor\nfrom sklearn.model_selection import train_test_split\n\ndiabetes = load_diabetes()\nX_train, X_test, y_train, y_test = train_test_split(\n    diabetes.data, diabetes.target, random_state=0\n)\nX_test = pd.DataFrame(X_test, columns=diabetes.feature_names)\ny_test = pd.DataFrame(y_test)\n\nmodel = RandomForestRegressor(random_state=0)\nmodel.fit(X_train, y_train)\n```\n\nInitialize the `PermutationExplanation` (or any other explanation) object and pass in the trained model and the to be explained dataset. \n\nAddtionally, define the number of features used in the explanation. This allows you to configure the verbosity of your exaplanation.\n\n Set the index of the sample that should be explained.\n\n```python\nfrom explainy.explanations import PermutationExplanation\n\nnumber_of_features = 4\n\nexplainer = PermutationExplanation(\n    X_test, y_test, model, number_of_features\n)\n```\nCall the `explain()` method and print the explanation for the sample (in case of a local explanation every sample has a different explanation).\n\n```python\nexplanation = explainer.explain(sample_index=1)\nprint(explanation)\n```\n\u003e The RandomForestRegressor used 10 features to produce the predictions. The prediction of this sample was 251.8.\n\n\u003e The feature importance was calculated using the Permutation Feature Importance method.\n\n\u003e The four features which were most important for the predictions were (from highest to lowest): 'bmi' (0.15), 's5' (0.12), 'bp' (0.03), and 'age' (0.02).\n\nUse the `plot()` method to create a feature importance plot of that sample.\n\n```python\nexplainer.plot()\n```\n![Permutation Feature Importance](https://github.com/MauroLuzzatto/explainy/raw/main/static/permutation_importance.png)\n\nIf your prefer, you can also create another type of plot, as for example a boxplot.\n```python\nexplainer.plot(kind='box')\n```\n![Permutation Feature Importance BoxPlot](https://github.com/MauroLuzzatto/explainy/raw/main/static/permutation_importance_box.png)\n\n\nFinally, you can also look at the importance values of the features (in form of a `pd.DataFrame`).\n\n```python\nfeature_importance = explainer.importance()\nprint(feature_importance)\n```\n\n```python\n  Feature  Importance\n0     bmi        0.15\n1      s5        0.12\n2      bp        0.03\n3     age        0.02\n4      s2       -0.00\n5     sex       -0.00\n6      s3       -0.00\n7      s1       -0.01\n8      s6       -0.01\n9      s4       -0.01\n```\n\n\u003c!-- Finally the result can be saved\n\n```python\nexplainer.save(sample_index)\n``` --\u003e\n\n\u003c!-- \n## Model Explanations\n--\u003e\n\n\n## Features\n- Algorithms for inspecting black-box machine learning models \n- Support for the machine learning frameworks `scikit-learn` and `xgboost`\n- **explainy** offers a standardized API with three core methods `explain()`, `plot()`, `importance()`\n\n## Other Machine Learning Explainability libraries to watch\n- [shap](https://github.com/slundberg/shap): A game theoretic approach to explain the output of any machine learning model\n- [eli5](https://github.com/TeamHG-Memex/eli5): A library for debugging/inspecting machine learning classifiers and explaining their predictions \n- [alibi](https://github.com/SeldonIO/alibi): Algorithms for explaining machine learning models \n- [interpret](https://github.com/interpretml/interpret): Fit interpretable models. Explain blackbox machine learning\n\n\n## Source\n\nMolnar, Christoph. \"Interpretable machine learning. A Guide for Making Black Box Models Explainable\", 2019. https://christophm.github.io/interpretable-ml-book/\n\n## Author\n**Mauro Luzzatto** - [Maurol](https://github.com/MauroLuzzatto)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauroluzzatto%2Fexplainy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmauroluzzatto%2Fexplainy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauroluzzatto%2Fexplainy/lists"}