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.6.tar.gz (11.2 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.6-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hermai-0.1.6.tar.gz
  • Upload date:
  • Size: 11.2 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.6.tar.gz
Algorithm Hash digest
SHA256 17fefd81821a418e31888f8f908e27a433c79e0b18ce966671f7ed9db639ab13
MD5 9de9d03c572d91852cb89b682de78ac6
BLAKE2b-256 51789977f34472dee3061a6b14b035aa58ffc94b068cceb0cc4ef3b420e12227

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hermai-0.1.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 96c415cc74f9c4a4930b955cac0149765d2741edf935e3511814bf185d0c9d36
MD5 2cb484c97aa3b3ac20d0380003aaa522
BLAKE2b-256 9bd285006977b20bc5539d8684658a9d6f8225d401327d0a58aa6cf7d3ee2ab8

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