# If using git
git clone <repository-url>
cd necessity-sufficiency-xai
# Or extract the zip file
unzip necessity-sufficiency-xai.zip
cd necessity-sufficiency-xaiOn Linux/Mac:
python3 -m venv venv
source venv/bin/activateOn Windows:
python -m venv venv
venv\Scripts\activatepip install --upgrade pip
pip install -r requirements.txtpython -c "import sklearn; import shap; import lime; print('All packages installed successfully!')"cd src
python main.py --dataset breast_cancer --model logisticThis will:
- Load the Breast Cancer dataset
- Train a Logistic Regression model
- Calculate global necessity and sufficiency scores
- Evaluate LIME and SHAP robustness
- Generate visualizations in
../results/
================================================================================
NECESSITY AND SUFFICIENCY ANALYSIS
================================================================================
Dataset: breast_cancer
Model: logistic
Number of samples: 100
Top-k features: 5
================================================================================
LOADING DATA
================================================================================
Dataset shape: (569, 30)
Number of features: 30
Class distribution: [212 357]
================================================================================
TRAINING MODEL
================================================================================
Training accuracy: 0.9497
Test accuracy: 0.9825
================================================================================
CALCULATING GLOBAL NECESSITY AND SUFFICIENCY SCORES
================================================================================
Feature 1/30: mean radius
Calculating necessity for feature 0: 100%|██████████| 100/100
Necessity: 0.4321
Sufficiency: 0.2145
...
================================================================================
XAI ROBUSTNESS EVALUATION
================================================================================
Evaluating LIME necessity robustness...
100%|██████████████████████████████████████| 50/50
Evaluating LIME sufficiency robustness...
100%|██████████████████████████████████████| 50/50
...
================================================================================
ANALYSIS COMPLETE!
================================================================================
All results saved to: ../results
jupyter notebooknotebooks/01_introduction.ipynb- Introduction and conceptsnotebooks/02_toy_example.ipynb- Validation with synthetic datanotebooks/03_full_analysis.ipynb- Complete analysis walkthrough
Solution: Install specific version
pip install shap==0.41.0 --no-cache-dirSolution: Reinstall lime
pip uninstall lime
pip install lime==0.2.0.1Solution: Install backend
pip install PyQt5 # Or: pip install tkSolution: Reduce sample size
python main.py --dataset breast_cancer --model logistic --n_samples 50Solution: This is normal for KernelExplainer. Wait or reduce test samples:
python main.py --dataset breast_cancer --model logistic --n_samples 30conda create -n necessity-xai python=3.8
conda activate necessity-xai
pip install -r requirements.txt# Install in editable mode with dev dependencies
pip install -e .
pip install pytest black flake8 mypyIf using models that benefit from GPU:
pip install torch torchvision # For PyTorch models
# or
pip install tensorflow-gpu # For TensorFlow modelspython -c "
from src.counterfactual_generator import ForwardCounterfactualGenerator
from src.xai_evaluator import XAIRobustnessEvaluator
from src.visualization import NecessitySufficiencyVisualizer
print('All modules imported successfully!')
"cd src
python main.py --dataset iris --model logistic --n_samples 20 --top_k 3Should complete in under 5 minutes.
cd notebooks
jupyter nbconvert --to notebook --execute 02_toy_example.ipynb- Python 3.8 or higher
- 4 GB RAM
- 1 GB disk space
- Python 3.9+
- 8 GB RAM
- 2 GB disk space
- Multi-core CPU for parallelization
- Ubuntu 20.04, 22.04
- macOS 11+
- Windows 10, 11
- Google Colab
- Jupyter Lab
After setup, explore:
- README.md - Overview and quick start
- docs/methodology.md - Detailed methodology
- notebooks/ - Interactive tutorials
- src/main.py - Run complete analysis
If you encounter issues:
- Check the troubleshooting section above
- Review the error message carefully
- Ensure all dependencies are installed:
pip list - Check Python version:
python --version(should be 3.8+) - Open an issue on GitHub with:
- Error message
- Python version
- Operating system
- Steps to reproduce
For questions or support:
- Email: pchowdhury6@gatech.edu
- GitHub Issues: [repository]/issues