AffectLog's Trustworthy AI: Tools for model transparency, explainability, and regulatory compliance.
Project description
Table of Contents
Installation and Usage
altai can be installed from:
- PyPI or GitHub source (using
pip) - Anaconda (using
conda/mamba)
With pip
-
To install altai from PyPI:
pip install altai
-
Alternatively, install the development version:
pip install git+https://github.com/roy-saurabh/altai.git
-
For distributed computation support (with ray):
pip install altai[ray]
-
For SHAP support:
pip install altai[shap]
Usage
The altai explanation API is inspired by scikit-learn’s style, using distinct initialize, fit, and explain steps:
from affectlog_tai.explainers import AnchorTabular
# Initialize and fit the explainer with your prediction function and data
explainer = AnchorTabular(predict_fn, feature_names=feature_names, categorical_names=category_map)
explainer.fit(X_train)
# Explain an instance
explanation = explainer.explain(x)
The returned Explanation object contains meta (metadata and hyperparameters) and data (the computed explanation). For AnchorTabular, for example, you can access the anchor conditions via explanation.data['anchor'].
Supported Methods
Model Explanations
| Method | Models | Explanations | Classification | Regression | Tabular | Text | Images | Categorical features | Train set required | Distributed |
|---|---|---|---|---|---|---|---|---|---|---|
| ALE | BB | global | ✔ | ✔ | ✔ | |||||
| Partial Dependence | BB WB | global | ✔ | ✔ | ✔ | ✔ | ||||
| PD Variance | BB WB | global | ✔ | ✔ | ✔ | ✔ | ||||
| Permutation Importance | BB | global | ✔ | ✔ | ✔ | ✔ | ||||
| Anchors | BB | local | ✔ | ✔ | ✔ | ✔ | ✔ | For Tabular | ||
| CEM | BB* TF/Keras | local | ✔ | ✔ | ✔ | Optional | ||||
| Counterfactuals | BB* TF/Keras | local | ✔ | ✔ | ✔ | No | ||||
| Prototype Counterfactuals | BB* TF/Keras | local | ✔ | ✔ | ✔ | ✔ | Optional | |||
| Counterfactuals with RL | BB | local | ✔ | ✔ | ✔ | ✔ | ✔ | |||
| Integrated Gradients | TF/Keras | local | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | Optional | |
| Kernel SHAP | BB | local/global | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ||
| Tree SHAP | WB | local/global | ✔ | ✔ | ✔ | ✔ | Optional | |||
| Similarity explanations | WB | local | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
Model Confidence
These methods provide instance-specific scores that measure the model’s confidence.
| Method | Models | Classification | Regression | Tabular | Text | Images | Categorical Features | Train set required |
|---|---|---|---|---|---|---|---|---|
| Trust Scores | BB | ✔ | ✔ | ✔(1) | ✔(2) | Yes | ||
| Linearity Measure | BB | ✔ | ✔ | ✔ | ✔ | Optional |
Key:
- BB – Black-box (only require a prediction function)
- BB* – Black-box but assume model is differentiable
- WB – White-box (access to model internals)
- TF/Keras – TensorFlow models via the Keras API
- Local – Explains a single prediction
- Global – Explains overall model behavior
- (1) and (2) – Model-dependent requirements
Prototypes
These methods distill a dataset into a 1-KNN interpretable classifier.
| Method | Classification | Regression | Tabular | Text | Images | Categorical Features | Train set labels |
|---|---|---|---|---|---|---|---|
| ProtoSelect | ✔ | ✔ | ✔ | ✔ | ✔ | Optional |
References and Examples
-
Accumulated Local Effects (ALE):
- Documentation
- Examples: California housing dataset, Iris dataset
-
Partial Dependence:
- Documentation
- Example: Bike rental
-
Permutation Importance:
- Documentation
- Example: Who's Going to Leave Next?
-
Anchors:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file altai-0.9.7.dev0.tar.gz.
File metadata
- Download URL: altai-0.9.7.dev0.tar.gz
- Upload date:
- Size: 462.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ac6ad639c5f9afb535fce4ecdf153b6301c48ace8b6707244861ac22f0ad6d3
|
|
| MD5 |
61f58834555fdc08924ef3f4d3134398
|
|
| BLAKE2b-256 |
8c2c0c492f2cdcfd2ffee50732dfa4d11c5588477824c48e83465accb3910833
|
File details
Details for the file altai-0.9.7.dev0-py3-none-any.whl.
File metadata
- Download URL: altai-0.9.7.dev0-py3-none-any.whl
- Upload date:
- Size: 517.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84982d83ff7474114315f7049d6c6f74988360a75ee250d6cbdc3a107b5675fa
|
|
| MD5 |
0bf052475603fc579fd5270765a54d57
|
|
| BLAKE2b-256 |
1a62d8db84f93a94d87c2a6025561f3c227f4eafe4abcddeb25a7dd748ba80ba
|