Skip to main content

A library for explainable AI methods

Project description

MindXLib

MindXLib is an open toolkit ensemble of algorithmic achievements in XAI (Explainable AI) from the Data Decision Team at Alibaba DAMO Academy's Decision Intelligence Lab.

中文文档

Installation

You can install MindXLib using pip:

pip install mindxlib

pip install git+http://gitlab.alibaba-inc.com/MindXAI/MindXLib.git

Or install from source:

git clone http://gitlab.alibaba-inc.com/MindXAI/MindXLib.git
cd mindxlib
pip install -e .

Quick Start

Feature Attribution with SHAP

import xgboost
import shap # just for retrival of adult dataset
from mindxlib import ShapExplainer

# Load adult dataset
X, y = shap.datasets.adult()

# Train XGBoost classifier
model = xgboost.XGBClassifier()
model.fit(X, y)

# Initialize Tree SHAP explainer
explainer = ShapExplainer(model, method="tree")

# Generate explanations
explanation = explainer.explain(X[:1000], baseline=X, mode="origin")

# Show scatter plot for Age feature
explanation.show('scatter', feature='Age')

Rule Learning with SSRL

import pandas as pd
import numpy as np
from mindxlib import SSRL
from mindxlib.data import tic_tac_toe

# Load tic-tac-toe dataset
X, y = tic_tac_toe()

# Initialize and fit SSRL
explainer = SSRL(cc=10, lambda_1=1, distorted_step=10, 
                categorical_features=X.columns.tolist())
explainer.fit(X, y)

# Show learned rules
explainer.show()

# Make predictions
predictions = explainer.predict(X)
acc = np.sum(predictions.values == y.values) / y.shape[0]
print(f'Training accuracy: {acc:.2f}')

# Example output:
'''
IF 1==o AND 4==o AND 7==o, THEN negative
ELIF 3==o AND 4==o AND 5==o, THEN negative
ELIF 0==o AND 1==o AND 2==o, THEN negative
ELIF 6==o AND 7==o AND 8==o, THEN negative
ELIF 0==o AND 3==o AND 6==o, THEN negative
ELIF 2==o AND 5==o AND 8==o, THEN negative
ELIF 0!=x AND 4!=x AND 8!=x, THEN negative
ELIF 2!=x AND 4!=x AND 6!=x, THEN negative
ELSE positive
Training accuracy: 0.98
'''

Architecture

The algorithm package currently supports the following models:

Rule-based Methods

  1. RuleSet - Rule-based classifier using submodular optimization that supports binary classification
  2. RuleSetImb - Rule-based classifier optimized for imbalanced data that supports binary classification
  3. Diver - Rule discovery through combinatorial optimization that supports binary classification
  4. DrillUp - Pattern detection algorithm for discriminative rules that supports binary classification
  5. SSRL (Scalable Sparse Rule Lists) - Efficient decision rule list learning that supports multi-class classification

Feature Attribution Methods

  1. SHAP - SHapley Additive exPlanations for model interpretation, providing customizable baselines and a user-friendly interface
  2. LIME - Local Interpretable Model-agnostic Explanations
  3. IG (Integrated Gradients) - Path attribution method for deep learning models
  4. GAM - Generalized Additive Models with shape functions

Time Series Explanation

  1. FDTemp - Functional Decomposition Temperature method for explaining temporal black-box models

Related Papers

  1. Efficient Decision Rule List Learning via Unified Sequence Submodular Optimization
  2. SLIM: a Scalable Light-weight Root Cause Analysis for Imbalanced Data in Microservice
  3. Interactive Generalized Additive Models for Electricity Load Forecasting
  4. Learning Interpretable Decision Rule Sets: A Submodular Optimization Approach
  5. Explain temporal black-box models via functional decomposition

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

mindxlib-0.1.0.tar.gz (27.1 MB view details)

Uploaded Source

Built Distribution

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

mindxlib-0.1.0-py3-none-any.whl (27.1 MB view details)

Uploaded Python 3

File details

Details for the file mindxlib-0.1.0.tar.gz.

File metadata

  • Download URL: mindxlib-0.1.0.tar.gz
  • Upload date:
  • Size: 27.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for mindxlib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c7b18b77c9035a43a65799b1834fdbce17c704892b89d6c8047edebad1d2ddf8
MD5 bb9c0749df5c6030bbba60df74376515
BLAKE2b-256 f8111c29bb7a01d729ac5c3b0d8f64028c6a8fd3f723b2ef08b57b2538612587

See more details on using hashes here.

File details

Details for the file mindxlib-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mindxlib-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for mindxlib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f253d907af6e036342f88875a9442ebedea1ed99fde726a5d5d09a59421f8827
MD5 0e106613018f802b64897eb03eb8fcc6
BLAKE2b-256 0c533ccd334975795f8dfa43a8384597f9782b0802ff951ebeecb560e7fa463a

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