XAI-Libο
XAI-Lib is an integrated Python library for Explainable AI (XAI) that provides a unified interface for various explanation methods. Developed to make machine learning models more interpretable and transparent, XAI-Lib simplifies the process of explaining black-box models across different data types.
This project is part of the XAI Project - a European initiative focused on advancing explainable artificial intelligence research and applications.
β¨ Featuresο
XAI-Lib is designed to be modular, extensible, and easy to use. It provides:
π Unified Interface: Simple, consistent API for multiple explanation methods
π Multiple Data Types: Support for tabular, image, text, and time-series data
π§© Extensible Architecture: Easy integration of new explanation methods
π― Model-Agnostic: Works with any black-box machine learning model
π Well-Documented: Comprehensive documentation and examples
π οΈ Supported Explanation Methodsο
Tabular Dataο
SHAP - SHapley Additive exPlanations
LIME - Local Interpretable Model-agnostic Explanations
Anchors - High-precision model-agnostic explanations
LORE - LOcal Rule-based Explanations
Image Dataο
GradCAM - Gradient-weighted Class Activation Mapping
LIME - Local Interpretable Model-agnostic Explanations
SHAP - SHapley Additive exPlanations
ABELE - Adversarial Black-box Explainer generating Latent Exemplars
Text Dataο
LIME - Local Interpretable Model-agnostic Explanations for text classification
Time Series Dataο
LASTS - Local Agnostic Subsequence-based Time Series explanations
π¦ Installationο
Install from PyPIο
The easiest way to install XAI-Lib is using pip:
pip install XAI-Library
Install from Sourceο
For the latest development version, clone the repository and install in editable mode:
git clone https://github.com/kdd-lab/XAI-Lib.git
cd XAI-Lib
pip install -e .
Recommended: Use a virtual environment to avoid dependency conflicts:
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install XAI-Lib
pip install -e .
π Quick Startο
Hereβs a simple example of using LIME for tabular data explanation:
from xailib.explainers.lime_explainer import LimeXAITabularExplainer
from xailib.models.sklearn_classifier_wrapper import sklearn_classifier_wrapper
# Wrap your scikit-learn model
bb = sklearn_classifier_wrapper(your_trained_model)
# Create and fit the LIME explainer
explainer = LimeXAITabularExplainer(bb)
explainer.fit(df, 'target_column', config={
'discretize_continuous': True,
'feature_selection': 'auto'
})
# Generate explanation for an instance
explanation = explainer.explain(instance, num_samples=1000)
# Visualize feature importance
explanation.plot_features_importance()
For more examples and detailed usage, please check the examples/ directory.
π Documentationο
For detailed documentation, tutorials, and API reference, visit:
GitHub Pages Documentation: https://kdd-lab.github.io/XAI-Lib/
Read the Docs: https://xai-lib.readthedocs.io/
GitHub Repository: https://github.com/kdd-lab/XAI-Lib
Issue Tracker: https://github.com/kdd-lab/XAI-Lib/issues
The documentation includes:
Getting Started Guide: Installation and quick start tutorials
API Reference: Complete documentation of all classes and methods
Examples: Practical examples for tabular, image, and text data
Contributing Guide: How to contribute to the project
π€ Contributingο
We welcome contributions! Please see our Contributing Guide for details on how to:
Report bugs and request features
Submit pull requests
Improve documentation
Add new explanation methods
π Licenseο
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgmentsο
This library is developed as part of the XAI Project (https://xai-project.eu/), a European initiative dedicated to advancing explainable artificial intelligence.
The Xai project focuses on the urgent open challenge of how to construct meaningful explanations of opaque AI/ML systems in the context of ai based decision making, aiming at empowering individual against undesired effects of automated decision making, implementing the right of explanation, helping people make better decisions preserving (and expand) human autonomy.
For more information about the XAI Project, visit https://xai-project.eu/.
π§ Contactο
For questions and support:
Email: rinzivillo@isti.cnr.it
Issue Tracker: https://github.com/kdd-lab/XAI-Lib/issues