A comprehensive web-based platform for analyzing, visualizing, and understanding machine learning models through advanced explainability techniques powered by SHAP, AI explanations, and interactive visualizations.
ExplainableAI provides an intuitive interface for data scientists and machine learning practitioners to:
- Upload and analyze sklearn models (.joblib, .pkl) and ONNX models
- Generate comprehensive insights using SHAP (SHapley Additive exPlanations)
- Visualize feature importance and model behavior through interactive charts
- Perform what-if analysis to understand prediction changes
- Get AI-powered explanations using AWS Bedrock (Claude 3 Sonnet)
- Analyze model performance with ROC curves, confusion matrices, and threshold analysis
- Explore feature dependencies with partial dependence plots and SHAP dependence plots
- Framework: FastAPI with async support
- ML Support: scikit-learn models and ONNX runtime
- Explainability: SHAP library for model interpretability
- AI Explanations: AWS Bedrock integration with Claude 3 Sonnet
- Authentication: Token-based authentication system
- Data Storage: Local file storage for models and datasets
- Framework: React 19 with TypeScript
- Build Tool: Vite for fast development and building
- Styling: Tailwind CSS for responsive design
- Visualizations:
- Plotly.js for interactive charts
- Recharts for data visualization
- React Force Graph for network visualizations
- Navigation: React Router for SPA routing
- Python 3.8+
- Node.js 18+
- npm or yarn
-
Navigate to backend directory
cd backend
-
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set environment variables (Optional - for AI explanations)
export AWS_ACCESS_KEY_ID_LLM="your_aws_access_key" export AWS_SECRET_ACCESS_KEY_LLM="your_aws_secret_key" export AWS_SESSION_TOKEN_LLM="your_aws_session_token" # Optional export REGION_LLM="us-east-1" # Optional
-
Start the server
uvicorn main:app --reload
The API will be available at
http://localhost:8000
-
Navigate to frontend directory
cd frontend
-
Install dependencies
npm install
-
Start development server
npm run dev
The frontend will be available at
http://localhost:5173
- Model Overview: Comprehensive statistics, performance metrics, and metadata
- Classification Stats: Accuracy, precision, recall, F1-score, AUC, confusion matrix
- Feature Importance: SHAP-based and built-in importance rankings
- ROC Analysis: ROC curves with optimal threshold detection
- Threshold Analysis: Performance metrics across different decision thresholds
- Instance Explanations: SHAP values for individual predictions
- Feature Dependence: Partial dependence plots and SHAP dependence plots
- What-If Analysis: Real-time prediction changes with feature modifications
- Feature Interactions: Pairwise feature interaction analysis
- Decision Tree Visualization: Explore ensemble tree structures
- Dataset Comparison: Training vs test dataset statistics and drift detection
- Feature Correlations: Correlation analysis between selected features
- Data Quality: Missing values, duplicates, and health scores
- Interactive Visualizations: Scatter plots, heatmaps, and network graphs
- Natural Language Explanations: AI-generated interpretations of analysis results
- Context-Aware Descriptions: Explanations tailored to different analysis types
- Business Impact: Translation of technical metrics into business insights
All endpoints require a token parameter. For development, use token=dev_token
.
POST /upload/model-and-data
- Upload model and datasetPOST /upload/model-and-separate-datasets
- Upload model with separate train/test dataGET /analysis/overview
- Get model overview and performance metricsGET /analysis/classification-stats
- Get detailed classification statisticsGET /analysis/feature-importance
- Get feature importance rankings
GET /analysis/explain-instance/{instance_idx}
- Explain individual predictionPOST /analysis/what-if
- Perform what-if analysisGET /analysis/feature-dependence/{feature_name}
- Get feature dependencePOST /analysis/explain-with-ai
- Get AI-powered explanations
POST /api/correlation
- Feature correlation analysisPOST /api/roc-analysis
- ROC curve analysisPOST /api/threshold-analysis
- Threshold optimizationPOST /api/partial-dependence
- Partial dependence plotsPOST /api/interaction-network
- Feature interaction network
- scikit-learn:
.joblib
,.pkl
,.pickle
files
- Binary Classification: Logistic Regression, Random Forest, SVM, XGBoost, etc.
- Multiclass Classification: Support for multi-class problems
- Tree-based Models: Enhanced support for decision trees and ensembles
- CSV Files: Training and test datasets
- Features: Numeric and categorical features
- Target: Binary and multiclass labels
# AWS Bedrock Configuration (Optional)
AWS_ACCESS_KEY_ID_LLM=your_access_key
AWS_SECRET_ACCESS_KEY_LLM=your_secret_key
AWS_SESSION_TOKEN_LLM=your_session_token
REGION_LLM=us-east-1
# Storage Configuration
STORAGE_DIR=./storage # Default: backend/storage
- Models must be trained and saved using supported formats
- Feature names should be consistent between training and inference
- Binary classification models should output probabilities for both classes
ExplainableAI/
βββ backend/ # FastAPI Backend
β βββ main.py # Main application entry point
β βββ requirements.txt # Python dependencies
β βββ app/
β β βββ core/ # Core configuration and auth
β β βββ services/ # Business logic services
β β β βββ model_service.py
β β β βββ ai_explanation_service.py
β β βββ storage/ # File storage
β βββ storage/ # Uploaded models and datasets
βββ frontend/ # React Frontend
β βββ package.json # Node.js dependencies
β βββ src/
β β βββ components/ # React components
β β βββ services/ # API services
β β βββ App.tsx # Main application component
β βββ public/ # Static assets
βββ *.csv # Sample datasets
βββ *.joblib # Sample models
βββ test_*.py # Test scripts
The repository includes sample datasets and models for testing:
breast_cancer_dataset.csv
- Binary classification datasetwine_classification_dataset.csv
- Multiclass classification datasetloan_approval_dataset.csv
- Credit approval dataset- Pre-trained models in
.joblib
format
test_upload.py
- Test file upload functionalitytest_multiclass.py
- Test multiclass model supporttest_decision_tree.py
- Test decision tree analysisvalidate_ui_data_display.py
- Validate frontend integration
# Test backend functionality
python test_upload.py
# Test multiclass support
python test_multiclass.py
# Validate API endpoints
python validate_ui_data_display.py
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- SHAP Errors: Ensure your model is compatible with SHAP explainers
- Memory Issues: Use smaller datasets or sample sizes for large models
- AWS Credentials: Set up proper AWS credentials for AI explanations
- FastAPI Docs: Available at
http://localhost:8000/docs
when running - SHAP Documentation: https://shap.readthedocs.io/
- AWS Bedrock: https://docs.aws.amazon.com/bedrock/
- β AI-powered explanations with AWS Bedrock integration
- β Enhanced multiclass classification support
- β Interactive decision tree visualization
- β Feature interaction analysis
- β Data drift detection
- β Comprehensive test coverage
- β ONNX model support
- Model comparison dashboard
- Automated report generation
- Model monitoring and alerting
- Integration with MLflow/Weights & Biases
- Support for regression models
- Advanced feature engineering insights
- Model fairness and bias detection