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.

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 git+[https://github.com/](https://github.com/)bilgisayarkavramlari/hermai.git

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: hermai-0.1.5.tar.gz
  • Upload date:
  • Size: 11.1 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.5.tar.gz
Algorithm Hash digest
SHA256 b786b1740836d907e364ec1c74991822ad39ed18a222bbc785b9f6fbd522e370
MD5 d8070a760ec921b1fda92e3d8ea79585
BLAKE2b-256 52c8b1343545215b6fe4cb9626abb04883f8125aaf1011bbc65e09e2ca1cb5a7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hermai-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ddde5305c34284ae2a35014a638a27f5dec3156b8e79dd23f4f560f57c4a392e
MD5 05a805bd7dd4908dd43904a22dd6f73d
BLAKE2b-256 4ecf4883ee82b510a3442839a69d2511fc1b60c756ba9bd54097ecf14e9c7ca6

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