FedLIME combines Federated Learning with LIME (Local Interpretable Model-agnostic Explanations) to provide interpretable machine learning in distributed settings. It trains models across multiple clients, then aggregates local LIME explanations to understand global feature importance while preserving privacy through Local Differential Privacy.
- Python 3.8+
- pip
- Clone the repository:
git clone <repository-url>- Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate- Install dependencies:
pip install -r requirements.txtManual Implementation:
python fedlime_newaggmethod.py \
--dataset_name adult \
--num_clients 3 \
--communication_rounds 50 \
--epochs 15 \
--batch_size 128 \
--lr 0.001 \
--lime_action all \
--lime_instances 100 \
--lime_noise_std 0.01 \
--out_dir my_experimentFlower Framework:
python fedlime_flower.py \
--dataset_name adult \
--num_clients 3 \
--num_rounds 50 \
--epochs 15 \
--batch_size 128 \
--lr 0.001 \
--lime_action all \
--lime_instances 100 \
--lime_noise_std 0.01 \
--out_dir my_experiment_flowerCentralized Baseline:
python global_model_only.py \
--dataset_name adult \
--epochs 750 \
--batch_size 128 \
--lr 0.001 \
--run_lime yesManual Implementation (9 federated + 3 centralized):
./run_all_experiments.shFlower Framework (9 federated):
./run_flower_experiments.shpython visualize_lime_results.py --result_dir results/adult/iid_adult_3clients_ldp --save| Parameter | Description | Default |
|---|---|---|
--dataset_name |
Dataset to use (adult, bank, law, etc.) | bank |
--num_clients |
Number of federated clients | 3 |
--num_rounds / --communication_rounds |
FL rounds | 5 / 50 |
--epochs |
Local training epochs per round | 2 / 15 |
--lime_action |
LIME analysis (none, all, rank, bins) | all |
--lime_instances |
Instances to explain per client | 100 |
--lime_noise_std |
Local DP noise std deviation | 0.0 |
--out_dir |
Output directory name | - |
The project supports three datasets:
- Adult Census: Income prediction
- Bank Marketing: Marketing campaign success
- Law School: Bar passage prediction
Datasets are located in the datasets/ directory.
Each experiment creates:
acc_curve.npy- Accuracy over roundsbal_acc_curve.npy- Balanced accuracy over roundsauprc_curve.npy- AUPRC over roundslime_global_mean_abs.npy- Global feature importancelime_client_mean_abs.npy- Per-client feature importancelime_similarity.npy- Client similarity matrixlime_client_fidelity.npy- Per-client fidelity scoreslime_global_fidelity.npy- Global fidelity scorelime_feature_ranking.csv- Top-K features (human-readable)lime_feature_bins.csv- Feature importance binsplots/- Visualizations (if generated)