Skip to main content

Explainable Artificial Intelligence for dynamic and Incremental models.

Project description

PyPi PyPi_status
  </a>
  <!-- License -->
  <a href= mit_license

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:

pip install ixai

📊 Quickstart

Basic Classification

>>> 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}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ixai-0.1.3.tar.gz (30.3 kB view details)

Uploaded Source

Built Distribution

ixai-0.1.3-py3-none-any.whl (46.8 kB view details)

Uploaded Python 3

File details

Details for the file ixai-0.1.3.tar.gz.

File metadata

  • Download URL: ixai-0.1.3.tar.gz
  • Upload date:
  • Size: 30.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for ixai-0.1.3.tar.gz
Algorithm Hash digest
SHA256 a91b62bb106c66aa01829665189e28dd78242c00102048c3c5c55a58959c3902
MD5 e3db08ba18d50d48190e4a457f52b420
BLAKE2b-256 13ddd40dc8e088706df2dcfd209caf45919a5969e571cc75e3b3d6adacf53f6c

See more details on using hashes here.

File details

Details for the file ixai-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: ixai-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 46.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for ixai-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fa9fb4cda178d642ad5929d36a45752cef367150c64128ebf8c43adf9619eed7
MD5 04b65d080c9385b5dc180ec8ee2dbe6e
BLAKE2b-256 477cd44a59ff2c423e25fd797e3ee48cb60926b7dc927c489192ccecaaf2ee88

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page