{"id":13639494,"url":"https://github.com/MI2DataLab/pyBreakDown","last_synced_at":"2025-04-19T22:32:51.645Z","repository":{"id":40987017,"uuid":"126232161","full_name":"MI2DataLab/pyBreakDown","owner":"MI2DataLab","description":"Python implementation of R package breakDown","archived":false,"fork":false,"pushed_at":"2023-07-06T21:18:41.000Z","size":477,"stargazers_count":41,"open_issues_count":5,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-08-03T01:14:57.083Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MI2DataLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2018-03-21T19:46:53.000Z","updated_at":"2023-09-12T10:49:51.000Z","dependencies_parsed_at":"2024-01-17T22:13:09.796Z","dependency_job_id":"ef56fc35-b7ad-4bb8-9c1f-670edfbcf9bf","html_url":"https://github.com/MI2DataLab/pyBreakDown","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MI2DataLab%2FpyBreakDown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MI2DataLab%2FpyBreakDown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MI2DataLab%2FpyBreakDown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MI2DataLab%2FpyBreakDown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MI2DataLab","download_url":"https://codeload.github.com/MI2DataLab/pyBreakDown/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223810454,"owners_count":17206773,"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":[],"created_at":"2024-08-02T01:01:01.410Z","updated_at":"2024-11-09T09:31:05.971Z","avatar_url":"https://github.com/MI2DataLab.png","language":"Python","readme":"\n\n# pyBreakDown\n\n**Please note that the Break Down method is moved to the [dalex](http://dalex.drwhy.ai/) Python package which is actively maintained. If you will experience any problem with pyBreakDown please consider the [dalex](http://dalex.drwhy.ai/) implementation at https://dalex.drwhy.ai/python/api/.**\n\n\nPython implementation of breakDown package (https://github.com/pbiecek/breakDown).\n\nDocs: https://pybreakdown.readthedocs.io.\n\n## Requirements\n\nNothing fancy, just python 3.5.2+ and pip.\n\n## Installation\n\nInstall directly from github\n```\n    git clone https://github.com/bondyra/pyBreakDown\n    cd ./pyBreakDown\n    python3 setup.py install  # (or use pip install . instead)\n```\n\n## Basic usage\n\n### Load dataset\n\n\n```python\nfrom sklearn import datasets\n```\n\n\n```python\nx = datasets.load_boston()\n```\n\n\n```python\ndata = x.data\n```\n\n\n```python\nfeature_names = x.feature_names\n```\n\n\n```python\ny = x.target\n```\n\n### Prepare model\n\n\n```python\nimport numpy as np\n```\n\n\n```python\nfrom sklearn import tree\n```\n\n\n```python\nmodel = tree.DecisionTreeRegressor()\n```\n\n### Train model\n\n\n```python\ntrain_data = data[1:300,:]\ntrain_labels=y[1:300]\n```\n\n\n```python\nmodel = model.fit(train_data,y=train_labels)\n```\n\n### Explain predictions on test data\n\n\n```python\n#necessary imports\nfrom pyBreakDown.explainer import Explainer\nfrom pyBreakDown.explanation import Explanation\n```\n\n\n```python\n#make explainer object\nexp = Explainer(clf=model, data=train_data, colnames=feature_names)\n```\n\n\n```python\n#make explanation object that contains all information\nexplanation = exp.explain(observation=data[302,:],direction=\"up\")\n```\n\n### Text form of explanations\n\n\n```python\n#get information in text form\nexplanation.text()\n```\n\n    Feature                  Contribution        Cumulative          \n    Intercept = 1            29.1                29.1                \n    RM = 6.495               -1.98               27.12               \n    TAX = 329.0              -0.2                26.92               \n    B = 383.61               -0.12               26.79               \n    CHAS = 0.0               -0.07               26.72               \n    NOX = 0.433              -0.02               26.7                \n    RAD = 7.0                0.0                 26.7                \n    INDUS = 6.09             0.01                26.71               \n    DIS = 5.4917             -0.04               26.66               \n    ZN = 34.0                0.01                26.67               \n    PTRATIO = 16.1           0.04                26.71               \n    AGE = 18.4               0.06                26.77               \n    CRIM = 0.09266           1.33                28.11               \n    LSTAT = 8.67             4.6                 32.71               \n    Final prediction                             32.71               \n    Baseline = 0\n\n\n\n```python\n#customized text form\nexplanation.text(fwidth=40, contwidth=40, cumulwidth = 40, digits=4)\n```\n\n    Feature                                 Contribution                            Cumulative                              \n    Intercept = 1                           29.1                                    29.1                                    \n    RM = 6.495                              -1.9826                                 27.1174                                 \n    TAX = 329.0                             -0.2                                    26.9174                                 \n    B = 383.61                              -0.1241                                 26.7933                                 \n    CHAS = 0.0                              -0.0686                                 26.7247                                 \n    NOX = 0.433                             -0.0241                                 26.7007                                 \n    RAD = 7.0                               0.0                                     26.7007                                 \n    INDUS = 6.09                            0.0074                                  26.708                                  \n    DIS = 5.4917                            -0.0438                                 26.6642                                 \n    ZN = 34.0                               0.0077                                  26.6719                                 \n    PTRATIO = 16.1                          0.0385                                  26.7104                                 \n    AGE = 18.4                              0.0619                                  26.7722                                 \n    CRIM = 0.09266                          1.3344                                  28.1067                                 \n    LSTAT = 8.67                            4.6037                                  32.7104                                 \n    Final prediction                                                                32.7104                                 \n    Baseline = 0\n\n\n### Visual form of explanations\n\n\n```python\nexplanation.visualize()\n```\n\n\n![png](misc/output_22_0.png)\n\n\n\n```python\n#customize height, width and dpi of plot\nexplanation.visualize(figsize=(8,5),dpi=100)\n```\n\n\n![png](misc/output_23_0.png)\n\n\n\n```python\n#for different baselines than zero\nexplanation = exp.explain(observation=data[302,:],direction=\"up\",useIntercept=True)  # baseline==intercept\nexplanation.visualize(figsize=(8,5),dpi=100)\n```\n\n\n![png](misc/output_24_0.png)\n\n","funding_links":[],"categories":["Explaining Black Box Models and Datasets","Technical Resources"],"sub_categories":["Open Source/Access Responsible AI Software Packages"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMI2DataLab%2FpyBreakDown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMI2DataLab%2FpyBreakDown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMI2DataLab%2FpyBreakDown/lists"}