Generic explainability architecture for text machine learning models
Project description
A generic explainability architecture for explaining text machine learning models.
Marcel Robeer, 2021
Installation
See installation.md for an extended installation guide.
Method | Instructions |
---|---|
pip |
Install from PyPI via pip3 install text_explainability . |
Local | Clone this repository and install via pip3 install -e . or locally run python3 setup.py install . |
Documentation
Full documentation of the latest version is provided at https://marcelrobeer.github.io/text_explainability/.
Example usage
See example_usage.md to see an example of how the package can be used, or run the lines in example_usage.py
to do explore it interactively.
Explanation methods included
text_explainability
includes methods for model-agnostic local explanation and global explanation. Each of these methods can be fully customized to fit the explainees' needs.
Type | Explanation method | Description | Paper/link |
---|---|---|---|
Local explanation | LIME |
Calculate feature attribution with Local Intepretable Model-Agnostic Explanations (LIME). | [Ribeiro2016], interpretable-ml/lime |
KernelSHAP |
Calculate feature attribution with Shapley Additive Explanations (SHAP). | [Lundberg2017], interpretable-ml/shap | |
LocalTree |
Fit a local decision tree around a single decision. | [Guidotti2018] | |
LocalRules |
Fit a local sparse set of label-specific rules using SkopeRules . |
github/skope-rules | |
FoilTree |
Fit a local contrastive/counterfactual decision tree around a single decision. | [Robeer2018] | |
Global explanation | TokenFrequency |
Show the top-k number of tokens for each ground-truth or predicted label. | |
TokenInformation |
Show the top-k token mutual information for a dataset or model. | wikipedia/mutual_information | |
KMedoids |
Embed instances and find top-n prototypes (can also be performed for each label using LabelwiseKMedoids ). |
interpretable-ml/prototypes | |
MMDCritic |
Embed instances and find top-n prototypes and top-n criticisms (can also be performed for each label using LabelwiseMMDCritic ). |
[Kim2016], interpretable-ml/prototypes |
Releases
text_explainability
is officially released through PyPI.
See CHANGELOG.md for a full overview of the changes for each version.
Extensions
text_explainability
can be extended to also perform sensitivity testing, checking for machine learning model robustness and fairness.
The text_sensitivity
package is available through PyPI and fully documented at https://marcelrobeer.github.io/text_sensitivity/.
Citation
@misc{text_explainability,
title = {Python package text_explainability},
author = {Marcel Robeer},
howpublished = {https://git.science.uu.nl/m.j.robeer/text_explainability},
year = {2021}
}
Maintenance
Contributors
- Marcel Robeer (
@m.j.robeer
) - Michiel Bron (
@mpbron-phd
)
Todo
Tasks yet to be done:
- Implement local post-hoc explanations:
- Implement Anchors
- Implement global post-hoc explanations:
- Representative subset
- Add support for regression models
- More complex data augmentation
- Top-k replacement (e.g. according to LM / WordNet)
- Tokens to exclude from being changed
- Bag-of-words style replacements
- Add rule-based return type
- Write more tests
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
Hashes for text_explainability-0.4.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b4dcbf5b50866d44312e5bc749b790efa39215e1f4ab899de57584be5be7c73 |
|
MD5 | 929c7329c618926552c1451ff26a6258 |
|
BLAKE2b-256 | 8da6f00551ae0e6974bc8cf8c404170fe8a03f7be32066826e3292e4fb9f30a9 |
Hashes for text_explainability-0.4.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 012f6069094c9a75f7b0513d44cd0c26e8737c154e2eba6aedc68c2f2e847bf2 |
|
MD5 | a97b577b57d6cbc86df30d1fcdf59c5f |
|
BLAKE2b-256 | 3b3c02ae396acd703457af0970e6e57fdf5ab688cbf854029b0c41d6b84cd0e4 |