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:
Professional implementation example demonstrating XAI Easy's simple yet powerful API for model explainability
Console Output
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
Modern report header featuring gradient styling, model analysis title, and key performance metrics in an intuitive dashboard layout
2. Global Feature Importance Analysis
Interactive feature importance visualization with gradient color coding and precise value labels, showing which features matter most globally
3. Detailed Feature Importance Table
Comprehensive feature importance table with professional styling, clear rankings, and detailed explanations for stakeholder communication
4. Local Instance Explanation Dashboard
Local explanation dashboard displaying positive and negative feature contributions with summary statistics for specific prediction analysis
5. Local Feature Contributions Chart
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 modelX: 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 modelX: Training datainstance: Single instance to explainfeature_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 DataFramelocal_df: Local explanations DataFrame (optional)title: Report titlefilename: 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xai_easy-1.1.1.tar.gz.
File metadata
- Download URL: xai_easy-1.1.1.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2612429c728a02f93cb4eaffb6932d62a4ac89200f9574a8c10e573433ec036
|
|
| MD5 |
de584cf088c98103d1b2ce7011799575
|
|
| BLAKE2b-256 |
3fa24c57551eb1c62616f187adfca5aceb0bbb65e706e1fd05913a431345848b
|
File details
Details for the file xai_easy-1.1.1-py3-none-any.whl.
File metadata
- Download URL: xai_easy-1.1.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b3a48525b26d18e103bb6c4be15ea21eeb200b88c59ede2d90b05d4104224dc
|
|
| MD5 |
2894e940eb7c30f2a98404c64b5218da
|
|
| BLAKE2b-256 |
f67ebf48a173fd59375a7b17d1ccf92300195c223801535354cf135a06e09873
|