A comprehensive package for Explainable AI and model interpretation
Project description
ExplainableAI
ExplainableAI is a Python package that provides tools for creating interpretable machine learning models. It combines various explainable AI techniques with LLM-powered explanations to make model predictions more understandable for both technical and non-technical users.
Features
- Automated Exploratory Data Analysis (EDA)
- Model performance evaluation
- Feature importance calculation
- SHAP (SHapley Additive exPlanations) value calculation
- Visualization of model insights
- LLM-powered explanations of model results and individual predictions
- Automated report generation
- Easy-to-use interface for model fitting, analysis, and prediction
Installation
You can install explainableai using pip:
pip install explainableai
Environment Variables
To run this project, you will need to add the following environment variables to your .env file
GEMINI_API_KEY
Usage/Examples
Here's a basic example of how to use ExplainableAI:
from explainableai import XAIWrapper
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from xgboost import XGBClassifier
from sklearn.neural_network import MLPClassifier
import pandas as pd
# Load your dataset
df = pd.read_csv('your_dataset.csv')
X = df.drop(columns=['target_column'])
y = df['target_column']
# Perform EDA
XAIWrapper.perform_eda(df)
# Create models
models = {
'Random Forest': RandomForestClassifier(n_estimators=100, random_state=42),
'Logistic Regression': LogisticRegression(max_iter=1000),
'XGBoost': XGBClassifier(n_estimators=100, random_state=42),
'Neural Network': MLPClassifier(hidden_layer_sizes=(100, 50), max_iter=1000, random_state=42)
}
# Create XAIWrapper instance
xai = XAIWrapper()
# Fit the models and run XAI analysis
xai.fit(models, X, y)
results = xai.analyze()
# Print LLM explanation of results
print(results['llm_explanation'])
# Generate a comprehensive report
xai.generate_report('xai_report.pdf')
# Make a prediction with explanation
new_data = {...} # Dictionary of feature values
prediction, probabilities, explanation = xai.explain_prediction(new_data)
print(f"Prediction: {prediction}")
print(f"Probabilities: {probabilities}")
print(f"Explanation: {explanation}")
Run Locally
Clone the project
git clone https://github.com/ombhojane/explainableai
Go to the project directory
cd explainableai
Install dependencies
pip install -r requirements.txt
Environment Values: Add Google's Gemini API key in .env as GOOGLE_API_KEY
Get Started with data.csv dataset or you can have any dataset
python main.py [dataset] [Target_column]
Contributing
Contributions are always welcome!
See contributing.md
for ways to get started.
Please adhere to this project's code of conduct
.
Acknowledgements
- This package uses various open-source libraries including scikit-learn, shap, and matplotlib.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file explainableai-0.1.8.tar.gz
.
File metadata
- Download URL: explainableai-0.1.8.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b16aac207b0f6ecd751b31a560c965cdaa3cc9165f49f87a47e1f35a6e818b5 |
|
MD5 | 4b6218743a0841331e3394987f8b24ce |
|
BLAKE2b-256 | b838aea6dd58ad79771e508fe9808efb0005491e9714e17feff165a4ca2fdfdc |
Provenance
File details
Details for the file explainableai-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: explainableai-0.1.8-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ec2b79c20e33b3b3560dfa828e17fe10ff568ae8106172c34d1fa8a1a6fa3e6 |
|
MD5 | 98f8355bc988a1f7dcdaaa88da20e88c |
|
BLAKE2b-256 | 6d89e7d876ba36ab44044032ba7150aa922138ffcb7eb283406507cea0b81297 |