Skip to main content

Explaining Machine Learning Classifiers in Python

Project description

PyXAI - Python eXplainable AI

What is PyXAI ?

PyXAI (Python eXplainable AI) is a Python library (version 3.6 or later) allowing to bring explanations of various forms suited to (regression or classification) tree-based ML models (Decision Trees, Random Forests, Boosted Trees, ...). In contrast to many approaches to XAI (SHAP, Lime, ...), PyXAI algorithms are model-specific. Furthermore, PyXAI algorithms guarantee certain properties about the explanations generated, that can be of several types:

  • Abductive explanations for an instance $X$ are intended to explain why $X$ has been classified in the way it has been classified by the ML model (thus, addressing the “Why?” question). For the regression tasks, abductive explanations for $X$ are intended to explain why the regression value on $X$ is in a given interval.
  • Contrastive explanations for $X$ is to explain why $X$ has not been classified by the ML model as the user expected it (thus, addressing the “Why not?” question).

New features in version 1.0.0:

  • Regression for Boosted Trees with XGBoost or LightGBM
  • Adding Theories (knowledge about the dataset)
  • Easier model import (automatic detection of model types)
  • PyXAI's Graphical User Interface (GUI): displaying, loading and saving explanations.
  • Supports multiple image formats for imaging datasets
  • Supports data pre-processing (tool for preparing and cleansing a dataset)
  • Unit Tests with the unittest module
pyxai
PyXAI's main steps for producing explanations.
pyxai pyxai
PyXAI's Graphical User Interface (GUI) for visualizing explanations.

What is the difference between PyXAI and other methods ?

The most popular approaches (SHAP, Lime, ...) to XAI are model-agnostic, but do not offer any guarantees of rigor. A number of works have highlighted several misconceptions about informal approaches to XAI (see the related papers). Contrastingly, PyXAI algorithms rely on logic-based, model-precise approaches for computing explanations. Although formal explainability has a number of drawbacks, particularly in terms of the computational complexity of logical reasoning needed to derive explanations, steady progress has been made since its inception.

Which models can be explained with PyXAI ?

Models are the resulting objects of an experimental ML protocol through a chosen cross-validation method (for example, the result of a training phase on a classifier). Importantly, in PyXAI, there is a complete separation between the learning phase and the explaining phase: you produce/load/save models, and you find explanations for some instances given such models. Currently, with PyXAI, you can use methods to find explanations suited to different ML models for classification or regression tasks:

In addition to finding explanations, PyXAI also provides methods that perform operations (production, saving, loading) on models and instances. Currently, these methods are available for three ML libraries:

  • Scikit-learn: a software machine learning library
  • XGBoost: an optimized distributed gradient boosting library
  • LightGBM: a gradient boosting framework that uses tree based learning algorithms

It is possible to also leverage PyXAI to find explanations suited to models learned using other libraries.

What does this website offer ?

In this website, you can find all what you need to know about PyXAI, with more than 10 Jupyter Notebooks, including:

  • The installation guide and the quick start
  • About obtaining models:
  • About obtaining explanations:
    • The concepts of the PyXAI explainer module: Concepts
    • How to use a time limit? Time Limit
    • The PyXAI library offers the possibility to process user preferences (prefer some explanations to others or exclude some features): Preferences
    • Theories are knowledge about the dataset. PyXAI offers the possibility of encoding a theory when calculating explanations in order to avoid calculating impossible explanations: Theories
    • How to compute explanations for classification tasks? Explaining Classification
    • How to compute explanations for regression tasks? Explaining Regression
  • How to use the PyXAI's Graphical User Interface (GUI) for visualizing explanations?

How to use PyXAI ?

Here is an example (it comes from the Quick Start page):

PyXAI in action

from pyxai import Learning, Explainer

learner = Learning.Scikitlearn("tests/iris.csv", learner_type=Learning.CLASSIFICATION)
model = learner.evaluate(method=Learning.HOLD_OUT, output=Learning.DT)
instance, prediction = learner.get_instances(model, n=1, correct=True, predictions=[0])

explainer = Explainer.initialize(model, instance)
print("instance:", instance)
print("binary representation:", explainer.binary_representation)

sufficient_reason = explainer.sufficient_reason(n=1)
print("sufficient_reason:", sufficient_reason)
print("to_features:", explainer.to_features(sufficient_reason))

instance, prediction = learner.get_instances(model, n=1, correct=False)
explainer.set_instance(instance)
contrastive_reason = explainer.contrastive_reason()
print("contrastive reason", contrastive_reason)
print("to_features:", explainer.to_features(contrastive_reason, contrastive=True))

explainer.show()
pyxai

As illustrated by this example, with a few lines of code, PyXAI allows you to train a model, extract instances, and get explanations about the classifications made.



Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pyxai_experimental-1.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.6 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pyxai_experimental-1.1.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.6 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

pyxai_experimental-1.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.6 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyxai_experimental-1.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.6 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

pyxai_experimental-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.6 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyxai_experimental-1.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.6 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

pyxai_experimental-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.6 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyxai_experimental-1.1.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.6 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

pyxai_experimental-1.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.6 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyxai_experimental-1.1.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.6 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

pyxai_experimental-1.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.6 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pyxai_experimental-1.1.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.6 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

pyxai_experimental-1.1.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.6 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

pyxai_experimental-1.1.2-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.6 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.17+ ARM64

File details

Details for the file pyxai_experimental-1.1.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c9983952c4f7d5fd8a10b4c15e0c7d7c6ff1bcb18c4bceb979ad64cc7e3b15d2
MD5 cc90c5d00a6fb4c2f9860f50a88fead9
BLAKE2b-256 4e11309ce239a0f8142ed2ca19a14372d268c6ee630dbb769f63935eb1b4bb18

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 90603abda40368e76bb8d3a50406d88eb9b9aab86373c27ea91e510d392c35ea
MD5 b2d43058a22f6128dd7dc254a1bae151
BLAKE2b-256 f1bca993f47f8cf57d2f2b4a4417f33567f16b0b4e26115edd0d86c9d1b7a8f0

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 68876d4bd58b10e4f87b240a59f3013c134699efce054b54f8f1b194446fb050
MD5 f69de0327fcf9b3630f1486495227074
BLAKE2b-256 4b96a0347b1f9d096f18f0357b6038ed52b3f6b017baa6fa6f518143a8d37f41

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2454e2316d8809d6a2984c6d2a5719692dfa9e67e3d0013ec0f5c795777f0b11
MD5 a7d63c2d9fce2d4691a22f85ef30f7f8
BLAKE2b-256 ceb1e904bac60a09ade40e9652d3d4ee6ac14f4f307e49f915f8050afa51e790

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1cb1e63d7b331894d7798bb1869752c02ec4b2a2dfbd08d9ff03838bfe018541
MD5 44f3b2544866f3d3a65631aa64dc1627
BLAKE2b-256 aa6b20493918840a6b93859ab7c1a44ae3657f7aea1e74628132c004b8c3fbbe

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6874239ace95772d1ddef8b1002dd306604f8ea93b30c111e26bc2e8751f9d52
MD5 5f4eba6d94ead45eecba1c72f7f3816d
BLAKE2b-256 de00a4d9205475c6a30f6e98de2b3bc327a28301721dc4b3f3b2a0538ba422c3

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7efeea6cb8af4edf7bae9ec50c71e5211eca1b15b60c42aa0e4a119f9b67fcc1
MD5 70178dfcc74cdc8486b350a09fe0dbe7
BLAKE2b-256 872d124ab29006c6da65697c80e544225a82fd635b097712c7068979b2e8d814

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 76a1f0f0925b9c2bbe6b7b3976eaa889f227054b8d9301e5df556f5eb026d78b
MD5 a9cde4690ee843d8a2fe747b88c656ea
BLAKE2b-256 03c684130422199be218a5cd58659ccb21db264b198680635a51c0bd4583bc77

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 26122d15e7709061ca62ec4ebae00179328d08d6cbebda95d94c767946d8c7ed
MD5 546661a763de2bece4d59ca05791df81
BLAKE2b-256 af87ef983ea655d11e389a558cfcc192d0795b314009178cfcdce1dbd17ebb8e

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 951c4d549bfe76bc7481f06e1503e5217d845f5af4ab035be112e65cd5929ab6
MD5 df3603c9735c3498c1c760cbd1992032
BLAKE2b-256 0d689e75b7e2feb2438eb99027f5745da70d0a8cdf66b858c4e269bbf08f2df3

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7432475be1ea7df94d037b98d1acffe181305c2b75bc9269721f5ce4bdd3b456
MD5 15f36f71355cae439521a35fe12c4346
BLAKE2b-256 6dc731c06c532c36c0bc7e582c8c23342a26fc08aeed3de6f8d7994ceec9b578

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f5038fb7bc5b62b9a8c67db4be3838fcb9ff041faba0e705158b1a33a9634294
MD5 37f0193a6739666b7a274d2a3711d49d
BLAKE2b-256 5552f160277a9720e22e7748416d5920815cbeb84f30358d4ea5645adcf1451f

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 09fd1056cf8efe19ccc633a4ad55abc93ded23641b31af1c701e1b6266ba5849
MD5 20b477f24cfdb1f9d580d05b12d42191
BLAKE2b-256 a0871374825392dd84cab3be9aaa76a6df7aa39e6ecd8056fb7db5e8bb46ca61

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 70105907eff9289d15445592310d6ebdb24842f5404576807749109f964ebc1c
MD5 1b7c77d4f5cb2da27b06ae52720ffb1a
BLAKE2b-256 9394b920f1abdcd42659251bcd5cef718842a08348b422faf81abd292d0ce505

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5944a373808b2111504bfcc63432e8d14ec024562983b61e1268512c9efc0307
MD5 5449e29bc7c6cd979945f91a2e7d87e8
BLAKE2b-256 1824b9e4d489c6a122b0ba305553b19839188d04da816545649930a010dbd279

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fdafcb555204074d749bee6e634aa8f1a9a746fccf68c6ec94b6b7ed521f7fbb
MD5 a7673526992774396b40a8a388f8b409
BLAKE2b-256 406fc15648509816ca597b356c34b76e9ec19bfb1fba8306bfe5bfa1be756ece

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba1f8ddb0ef516abb9aa8a1ca36515d4705f7355b410e2ab1991c4d219c5a345
MD5 c2de80850cec760141e875b8bc90014a
BLAKE2b-256 4fdd61b7f5289e9c4ad81f0491c0d771564b7e38f089bf0731a95d1543a19b19

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f8acaa45bef9564e5a13a5f110a356750374aa84cf6197b686b892c344b48014
MD5 a6dff15a7dc2f575a8003168a6166379
BLAKE2b-256 9c3ff7f906e2fbab9a1aa0b3038f290c9b13be1135d43d84bc2327a72abf801f

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 51b0a89b092268e179baf73f95bece0459081d4264e0dbf24127107e76b342cc
MD5 019883b494edf7dd13d81a340a121708
BLAKE2b-256 c6f2a7836f71e754ddcf3324cf13ca304eb7b3cd72c5ce6735af33b9469b2db3

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 96ea5cccbab73d869828252d01f97b3be772ab463efbdc582d60cbe573679484
MD5 87739eeae7f8a2c7381ca9fa9632a288
BLAKE2b-256 a271fc2a1027507a8a68aef42d8ea8353cf71fca4f75f01dd034ae7e5f4fae1f

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab4c0cfa46b3a078dcf69da14937a89fe71915f78ced391c509eeea798099faf
MD5 108b01f85af5672a81675fccc25a7934
BLAKE2b-256 877520bf6f48cb19204c893a3d3d71910811cc388b3225b9f079e3f1349d5d18

See more details on using hashes here.

File details

Details for the file pyxai_experimental-1.1.2-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyxai_experimental-1.1.2-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 386bf1a4b4a0f8b91e6ab3b872fc8c55296781f166f5950d3548fa87274570f0
MD5 d45dadb3f1e2a3f75f09b000cad7d884
BLAKE2b-256 04329294acd4ef257dbfa141f1106ce7f1b8de1dab92068e7578a0d51b61d548

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