This release is a pre-release and may not be stable for production use.
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:
Metadata
Release files for altai 0.9.7.dev0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| altai-0.9.7.dev0.tar.gz | 462.6 kB | Without provenance | Details for altai-0.9.7.dev0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| altai-0.9.7.dev0-py3-none-any.whl | Python 3 | none | any | Details for altai-0.9.7.dev0-py3-none-any.whl |
Total release size: 980.3 kB
Release files / altai-0.9.7.dev0.tar.gz
| Download URL | altai-0.9.7.dev0.tar.gz |
|---|---|
| Size | 462.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9ac6ad639c5f9afb535fce4ecdf153b6301c48ace8b6707244861ac22f0ad6d3
|
|
BLAKE2b-256 checksum How to use checksums |
8c2c0c492f2cdcfd2ffee50732dfa4d11c5588477824c48e83465accb3910833
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.7
|
Release files / altai-0.9.7.dev0-py3-none-any.whl
| Download URL | altai-0.9.7.dev0-py3-none-any.whl |
|---|---|
| Size | 517.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
84982d83ff7474114315f7049d6c6f74988360a75ee250d6cbdc3a107b5675fa
|
|
BLAKE2b-256 checksum How to use checksums |
1a62d8db84f93a94d87c2a6025561f3c227f4eafe4abcddeb25a7dd748ba80ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.7
|
Security for altai 0.9.7.dev0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.