Skip to main content

A hermeneutic approach to explainable AI (XAI) with contextual and narrative explanations.

Project description

Hermai: A Hermeneutic Explainable AI Library

License: MIT

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.

Hermai Logo

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

hermai-0.1.7.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hermai-0.1.7-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file hermai-0.1.7.tar.gz.

File metadata

  • Download URL: hermai-0.1.7.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

Hashes for hermai-0.1.7.tar.gz
Algorithm Hash digest
SHA256 741c929301c7d623cbd2187c1253cf3f868731ae978107c137d16a9cf8723762
MD5 f2279668834aab5e8bbdb8e233b1f742
BLAKE2b-256 9fbaf90bd879693f89e0923771215a4619e98b4b174e4e0048bde966d1d661a5

See more details on using hashes here.

File details

Details for the file hermai-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: hermai-0.1.7-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

Hashes for hermai-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 984519292a466ac160a5ae40902a2d43773e7fa24fc16729606c9e1b484f4633
MD5 7870be213eee86971a51498fea5c736f
BLAKE2b-256 f85db6e35142d8f6c1751888abc5d84fef9abc0748a0b336d72611f0da8137ba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page