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.
Metadata
Release files for hermai 0.1.8
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 |
|---|---|---|---|---|
| hermai-0.1.8.tar.gz | 11.3 kB | Without provenance | Details for hermai-0.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hermai-0.1.8-py3-none-any.whl | Python 3 | none | any | Details for hermai-0.1.8-py3-none-any.whl |
Total release size: 24.6 kB
Release files / hermai-0.1.8.tar.gz
| Download URL | hermai-0.1.8.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e830cddaecbe170d151273bf88b3e747cd2112a2c40451ff766ad6b8d9c878f
|
|
BLAKE2b-256 checksum How to use checksums |
82aa18b9c3f7f1ff83f32e78b0e90442c92d8e32fdae5ba462d8efd937abf7e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Release files / hermai-0.1.8-py3-none-any.whl
| Download URL | hermai-0.1.8-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d4010796f2cf9920a0d1a7f325430f72eae22112d101860d4361ddea9c7ac96
|
|
BLAKE2b-256 checksum How to use checksums |
4a2a801754914665afff3079a2c80ebd262cb1d876dc0d7cba0c45ff6b3decd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Security for hermai 0.1.8
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.