A hermeneutic approach to explainable AI (XAI) with contextual and narrative explanations.
Project description
Hermai: A Hermeneutic Explainable AI Library
Hermai is a Python library for explainable AI (XAI) that focuses on providing contextual, narrative, and actionable explanations for machine learning models. Inspired by hermeneutics, it aims to create a dialogue between the user and the model's decision-making process.
Key Features
- Contextual Perturbations: Generates realistic "what-if" scenarios that respect the correlations in your data.
- Local Explanations: Explains individual predictions by identifying key feature contributions and generating counterfactuals.
- General Explanations: Approximates the overall behavior of a complex model with a simple, interpretable surrogate model (like a decision tree).
- Narrative Summaries: Presents explanations in human-readable text.
Installation
You can install Hermai directly from GitHub:
pip install hermai
Quick Usage
Here's a quick example of how to get local and general explanations for a RandomForest model trained on the Titanic dataset.
import pandas as pd
import seaborn as sns
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from hermai.perturbations.tabular import TabularPerturbationGenerator
from hermai.explainers import LocalExplainer, GeneralExplainer
# Load and prepare data (assuming X_train, black_box_model are ready)
# ...
# --- Local Explanation ---
generator = TabularPerturbationGenerator(categorical_features=['pclass', 'sex', 'embarked'])
generator.fit(X_train)
local_explainer = LocalExplainer(black_box_model, generator)
instance = X_test.iloc[0]
local_explanation = local_explainer.explain(instance)
print(local_explanation.narrative())
local_explanation.plot()
# --- General Model Explanation ---
general_explainer = GeneralExplainer(black_box_model)
general_explanation = general_explainer.explain(X_train)
general_explanation.plot_feature_importance()
general_explanation.plot_surrogate_tree()
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
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 hermai-0.1.8.tar.gz.
File metadata
- Download URL: hermai-0.1.8.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e830cddaecbe170d151273bf88b3e747cd2112a2c40451ff766ad6b8d9c878f
|
|
| MD5 |
c7687c75cfb1ca0dc6b23fbf9bf8ef94
|
|
| BLAKE2b-256 |
82aa18b9c3f7f1ff83f32e78b0e90442c92d8e32fdae5ba462d8efd937abf7e5
|
File details
Details for the file hermai-0.1.8-py3-none-any.whl.
File metadata
- Download URL: hermai-0.1.8-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d4010796f2cf9920a0d1a7f325430f72eae22112d101860d4361ddea9c7ac96
|
|
| MD5 |
5ca970575808bf9dd19fdb640087a920
|
|
| BLAKE2b-256 |
4a2a801754914665afff3079a2c80ebd262cb1d876dc0d7cba0c45ff6b3decd9
|