Skip to main content

A lightweight package for Explainable AI on ML models

Project description

XAI Easy is a powerful Python package designed to make machine learning models interpretable and explainable. Whether you're working with classification, regression, or clustering models, XAI Easy provides comprehensive tools to understand what your models are doing and why they make specific predictions.

Key Features

  • 🎯 Global Model Explanations - Understand feature importance across your entire dataset
  • 🔍 Local Instance Explanations - Explain individual predictions with precision
  • 📊 Professional Visualizations - Generate publication-ready charts and interactive reports
  • 🎨 Modern HTML Reports - Create stunning, responsive reports with professional branding
  • Model Agnostic - Works with any scikit-learn compatible model
  • 🔧 SHAP Integration - Automatic integration with SHAP when available

🚀 Applications

Real-World Use Cases

  • 🏥 Healthcare: Explain medical diagnosis predictions and treatment recommendations
  • 🏦 Finance: Interpret credit scoring and risk assessment models
  • 🛒 E-commerce: Understand customer behavior and recommendation systems
  • 🏭 Manufacturing: Analyze quality control and predictive maintenance models
  • 📊 Research: Generate publication-ready model interpretability reports

⚡ Quick Installation

pip install xai-easy

� Simple Example Usage

Here's a complete example showing how to use XAI Easy to explain a machine learning model:

Code Example - Professional XAI Easy implementation showing model training and explanation generation Professional implementation example demonstrating XAI Easy's simple yet powerful API for model explainability

Console Output

Console Output - Clean, professional terminal output with structured explanations and success confirmation
Clean console output showing feature importance rankings and successful HTML report generation with professional branding


🎨 Professional Report Visualizations

XAI Easy generates comprehensive HTML reports with modern, responsive design:

1. Report Header & Summary Dashboard

Report Header - Professional gradient header with model analysis summary and key statistics dashboard Modern report header featuring gradient styling, model analysis title, and key performance metrics in an intuitive dashboard layout

2. Global Feature Importance Analysis

Global Feature Importance - Interactive horizontal bar chart showing model-wide feature contributions with gradient colors Interactive feature importance visualization with gradient color coding and precise value labels, showing which features matter most globally

3. Detailed Feature Importance Table

Feature Importance Table - Professional data table with rankings, importance scores, and detailed explanations Comprehensive feature importance table with professional styling, clear rankings, and detailed explanations for stakeholder communication

4. Local Instance Explanation Dashboard

Local Explanation Dashboard - Instance-specific analysis showing positive/negative feature contributions with summary statistics Local explanation dashboard displaying positive and negative feature contributions with summary statistics for specific prediction analysis

5. Local Feature Contributions Chart

Local Feature Contributions - Diverging bar chart showing positive and negative feature impacts on individual predictions Professional diverging bar chart visualizing how individual features positively or negatively influence specific model predictions


� Advanced Usage

Complete Workflow Example

import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import make_classification
from xai_easy import explain_model, explain_instance, save_html_report

# 1. Prepare your data
X, y = make_classification(n_samples=1000, n_features=10, random_state=42)
feature_names = [f"feature_{i+1}" for i in range(X.shape[1])]
X_df = pd.DataFrame(X, columns=feature_names)

# 2. Train your model  
model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X_df, y)

# 3. Generate global explanations
global_explanations = explain_model(
    model, X_df, y, 
    task="classification", 
    top_n=10
)

# 4. Generate local explanations
local_explanations = explain_instance(
    model, X_df, 
    X_df.iloc[0],  # Explain first instance
    feature_names=feature_names
)

# 5. Create professional HTML report
save_html_report(
    global_explanations, 
    local_explanations,
    title="Professional ML Model Analysis Report",
    filename="model_analysis.html"
)

Key Functions

explain_model(model, X, y=None, **kwargs)

  • Purpose: Generate global model explanations
  • Returns: DataFrame with feature importance rankings and explanations
  • Parameters:
    • model: Trained scikit-learn compatible model
    • X: Feature data (DataFrame or array)
    • y: Target labels (optional)
    • top_n: Number of top features (default: 20)

explain_instance(model, X, instance, **kwargs)

  • Purpose: Generate local explanations for specific predictions
  • Returns: DataFrame with feature contributions and explanations
  • Parameters:
    • model: Trained model
    • X: Training data
    • instance: Single instance to explain
    • feature_names: Feature names (optional)

save_html_report(global_df, local_df=None, **kwargs)

  • Purpose: Create professional HTML reports
  • Features: Modern design, responsive layout, interactive elements
  • Parameters:
    • global_df: Global explanations DataFrame
    • local_df: Local explanations DataFrame (optional)
    • title: Report title
    • filename: Output filename

� Report Features

Every generated report includes:

Professional Design Elements

  • Gradient Headers with model analysis branding
  • Summary Statistics dashboard with key metrics
  • Interactive Charts with gradient colors and value labels
  • Responsive Tables with hover effects and clean typography
  • Professional Footer with package attribution and creator recognition

Technical Capabilities

  • Mobile Responsive design for all devices
  • High-Resolution Charts suitable for presentations
  • Structured Data tables for easy interpretation
  • Professional Branding with creator attribution
  • Export Ready HTML format for sharing

📊 Supported Models

XAI Easy works with any scikit-learn compatible model:

  • Tree-based Models: RandomForest, XGBoost, LightGBM, CatBoost
  • Linear Models: LogisticRegression, LinearRegression, Ridge, Lasso
  • Ensemble Models: GradientBoosting, AdaBoost, Voting classifiers
  • SVM Models: SVC, SVR with probability estimates
  • Neural Networks: MLPClassifier, MLPRegressor

🤝 Contributing

Contributions are welcome! Please feel free to submit Pull Requests or open issues for feature requests and bug reports.

Development Setup

git clone https://github.com/PrajwalChopade/xai_easy.git
cd xai_easy
pip install -e .

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


👨‍💻 About the Creator

XAI Easy was created by Prajwal with the vision of making machine learning more transparent and accessible. The package combines cutting-edge explainability techniques with professional-grade visualizations to bridge the gap between complex AI models and human understanding.

Philosophy

"Making artificial intelligence transparent, one explanation at a time."

Connect

  • 🐙 GitHub: @PrajwalChopade
  • 📦 Package: Making ML interpretable for everyone
  • 🎯 Mission: Responsible and explainable AI for all

🌟 Support XAI Easy

If you find XAI Easy useful, please consider:

  • Star this repository on GitHub
  • 🐛 Report bugs and issues
  • 💡 Suggest new features and improvements
  • 📢 Share with your colleagues and community

Built with ❤️ for the AI/ML community by Prajwal

Professional explainable AI made simple and accessible

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

xai_easy-1.1.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

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

xai_easy-1.1.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file xai_easy-1.1.0.tar.gz.

File metadata

  • Download URL: xai_easy-1.1.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for xai_easy-1.1.0.tar.gz
Algorithm Hash digest
SHA256 d3092cb2de7d1253d279a90a12b62af9c54062bb80565f4b2aa25e977e10c913
MD5 bf2eea3600154995933018e630cea8b6
BLAKE2b-256 937a62ef0ab74207f462c17d9bee0c4ecd1f16992a81c0dc12884e8ba2430452

See more details on using hashes here.

File details

Details for the file xai_easy-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: xai_easy-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for xai_easy-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8988ee2062deb20e5bc1c137679a7ca63d8518abb21ee2154ac14f78297a7409
MD5 7b3abde9c5536dcc70b8e93177dfba67
BLAKE2b-256 5da8cca91fe4c71583ecc46a52c641579683aed4313eb931c35f801e6873f318

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