ixai


Nameixai JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/mmschlk/iXAI
SummaryExplainable Artificial Intelligence for dynamic and Incremental models.
upload_time2023-01-18 15:23:56
maintainer
docs_urlNone
authorMaximilian Muschalik
requires_python>=3.8.0
licenseMIT
keywords python machine learning online learning xai
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
<p align="center">
  <!-- PyPI Version -->
  <a href="https://pypi.org/project/ixai">
    <img src="https://img.shields.io/pypi/v/ixai.svg?color=blue" alt="PyPi">
  </a>
  <!-- PyPI status -->
  <a href="https://pypi.org/project/ixai">
    <img src="https://img.shields.io/pypi/status/ixai.svg?color=blue" alt="PyPi_status
  </a>
  <!-- License -->
  <a href="https://opensource.org/licenses/MIT">
    <img src="https://img.shields.io/badge/License-MIT-brightgreen.svg" alt="mit_license">
  </a>
</p>

# ixai: Incremental Explainable Artificial Intelligence

This is the first iteration of our incremental explanation package.

Currently, it includes two explanation methods: PFI and SAGE.

Please look at the examples in the `examples` directory.

Please help us in improving our work by contributing or pointing to issues. We will update this iteration soon with further information.

## 🛠 Installation
**ixai** is intended to work with **Python 3.8 and above**. Installation can be done via `pip`:

```sh
pip install ixai
```

## 📊 Quickstart

### Basic Classification
```python
>>> from river.metrics import Accuracy
>>> from river.ensemble import AdaptiveRandomForestClassifier
>>> from river.datasets.synth import Agrawal

>>> from ixai.explainer import IncrementalPFI

>>> stream = Agrawal(classification_function=2)
>>> feature_names = list([x_0 for x_0, _ in stream.take(1)][0].keys())

>>> model = AdaptiveRandomForestClassifier(n_models=10, max_depth=10, leaf_prediction='mc')

>>> incremental_pfi = IncrementalPFI(
...     model_function=model.predict_one,
...     loss_function=Accuracy(),
...     feature_names=feature_names,
...     smoothing_alpha=0.001,
...     n_inner_samples=5
... )

>>> training_metric = Accuracy()
>>> for (n, (x, y)) in enumerate(stream, start=1)
...     y_pred = model.predict_one(x)       # inference
...     training_metric.update(y, y_pred)   # update score
...     incremental_pfi.explain_one(x, y)   # explaining
...     model.learn_one(x, y)               # learning
...     if n % 1000 == 0:
...         print(f"{n}: Accuracy: {training_metric.get():.3f}, PFI: {incremental_pfi.importance_values}")

1000: Accuracy: 0.785, PFI: {'age': 0.22, 'elevel': 0.18, 'zipcode': -0.07, 'salary': 0.04, 'commission': 0.05, 'loan': -0.06, 'car': 0.02, 'hyears': 0.03, 'hvalue': 0.03}
2000: Accuracy: 0.841, PFI: {'age': 0.26, 'elevel': 0.21, 'zipcode': -0.01, 'salary': 0.02, 'commission': 0.03, 'loan': -0.02, 'car': 0.02, 'hyears': 0.04, 'hvalue': 0.02}
3000: Accuracy: 0.921, PFI: {'age': 0.28, 'elevel': 0.24, 'zipcode': -0.00, 'salary': 0.00, 'commission': 0.01, 'loan': -0.01, 'car': 0.01, 'hyears': 0.01, 'hvalue': 0.00}

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mmschlk/iXAI",
    "name": "ixai",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.0",
    "maintainer_email": "",
    "keywords": "python,machine learning,online learning,xai",
    "author": "Maximilian Muschalik",
    "author_email": "maximilian.muschalik@ifi.lmu.de",
    "download_url": "https://files.pythonhosted.org/packages/13/dd/d40dc8e088706df2dcfd209caf45919a5969e571cc75e3b3d6adacf53f6c/ixai-0.1.3.tar.gz",
    "platform": null,
    "description": "\n<p align=\"center\">\n  <!-- PyPI Version -->\n  <a href=\"https://pypi.org/project/ixai\">\n    <img src=\"https://img.shields.io/pypi/v/ixai.svg?color=blue\" alt=\"PyPi\">\n  </a>\n  <!-- PyPI status -->\n  <a href=\"https://pypi.org/project/ixai\">\n    <img src=\"https://img.shields.io/pypi/status/ixai.svg?color=blue\" alt=\"PyPi_status\n  </a>\n  <!-- License -->\n  <a href=\"https://opensource.org/licenses/MIT\">\n    <img src=\"https://img.shields.io/badge/License-MIT-brightgreen.svg\" alt=\"mit_license\">\n  </a>\n</p>\n\n# ixai: Incremental Explainable Artificial Intelligence\n\nThis is the first iteration of our incremental explanation package.\n\nCurrently, it includes two explanation methods: PFI and SAGE.\n\nPlease look at the examples in the `examples` directory.\n\nPlease help us in improving our work by contributing or pointing to issues. We will update this iteration soon with further information.\n\n## \ud83d\udee0 Installation\n**ixai** is intended to work with **Python 3.8 and above**. Installation can be done via `pip`:\n\n```sh\npip install ixai\n```\n\n## \ud83d\udcca Quickstart\n\n### Basic Classification\n```python\n>>> from river.metrics import Accuracy\n>>> from river.ensemble import AdaptiveRandomForestClassifier\n>>> from river.datasets.synth import Agrawal\n\n>>> from ixai.explainer import IncrementalPFI\n\n>>> stream = Agrawal(classification_function=2)\n>>> feature_names = list([x_0 for x_0, _ in stream.take(1)][0].keys())\n\n>>> model = AdaptiveRandomForestClassifier(n_models=10, max_depth=10, leaf_prediction='mc')\n\n>>> incremental_pfi = IncrementalPFI(\n...     model_function=model.predict_one,\n...     loss_function=Accuracy(),\n...     feature_names=feature_names,\n...     smoothing_alpha=0.001,\n...     n_inner_samples=5\n... )\n\n>>> training_metric = Accuracy()\n>>> for (n, (x, y)) in enumerate(stream, start=1)\n...     y_pred = model.predict_one(x)       # inference\n...     training_metric.update(y, y_pred)   # update score\n...     incremental_pfi.explain_one(x, y)   # explaining\n...     model.learn_one(x, y)               # learning\n...     if n % 1000 == 0:\n...         print(f\"{n}: Accuracy: {training_metric.get():.3f}, PFI: {incremental_pfi.importance_values}\")\n\n1000: Accuracy: 0.785, PFI: {'age': 0.22, 'elevel': 0.18, 'zipcode': -0.07, 'salary': 0.04, 'commission': 0.05, 'loan': -0.06, 'car': 0.02, 'hyears': 0.03, 'hvalue': 0.03}\n2000: Accuracy: 0.841, PFI: {'age': 0.26, 'elevel': 0.21, 'zipcode': -0.01, 'salary': 0.02, 'commission': 0.03, 'loan': -0.02, 'car': 0.02, 'hyears': 0.04, 'hvalue': 0.02}\n3000: Accuracy: 0.921, PFI: {'age': 0.28, 'elevel': 0.24, 'zipcode': -0.00, 'salary': 0.00, 'commission': 0.01, 'loan': -0.01, 'car': 0.01, 'hyears': 0.01, 'hvalue': 0.00}\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Explainable Artificial Intelligence for dynamic and Incremental models.",
    "version": "0.1.3",
    "split_keywords": [
        "python",
        "machine learning",
        "online learning",
        "xai"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "477cd44a59ff2c423e25fd797e3ee48cb60926b7dc927c489192ccecaaf2ee88",
                "md5": "04b65d080c9385b5dc180ec8ee2dbe6e",
                "sha256": "fa9fb4cda178d642ad5929d36a45752cef367150c64128ebf8c43adf9619eed7"
            },
            "downloads": -1,
            "filename": "ixai-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "04b65d080c9385b5dc180ec8ee2dbe6e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.0",
            "size": 46757,
            "upload_time": "2023-01-18T15:23:54",
            "upload_time_iso_8601": "2023-01-18T15:23:54.368531Z",
            "url": "https://files.pythonhosted.org/packages/47/7c/d44a59ff2c423e25fd797e3ee48cb60926b7dc927c489192ccecaaf2ee88/ixai-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "13ddd40dc8e088706df2dcfd209caf45919a5969e571cc75e3b3d6adacf53f6c",
                "md5": "e3db08ba18d50d48190e4a457f52b420",
                "sha256": "a91b62bb106c66aa01829665189e28dd78242c00102048c3c5c55a58959c3902"
            },
            "downloads": -1,
            "filename": "ixai-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "e3db08ba18d50d48190e4a457f52b420",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.0",
            "size": 30292,
            "upload_time": "2023-01-18T15:23:56",
            "upload_time_iso_8601": "2023-01-18T15:23:56.059818Z",
            "url": "https://files.pythonhosted.org/packages/13/dd/d40dc8e088706df2dcfd209caf45919a5969e571cc75e3b3d6adacf53f6c/ixai-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-18 15:23:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "mmschlk",
    "github_project": "iXAI",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ixai"
}
        
Elapsed time: 0.03456s