https://github.com/aliakarma/eagf
EAGF (Ethical Agent Governance Framework)
https://github.com/aliakarma/eagf
cybersecurity ethics-in-ai iot-system renewable-energy
Last synced: 3 months ago
JSON representation
EAGF (Ethical Agent Governance Framework)
- Host: GitHub
- URL: https://github.com/aliakarma/eagf
- Owner: aliakarma
- License: other
- Created: 2026-03-17T21:32:48.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-04-02T19:10:42.000Z (3 months ago)
- Last Synced: 2026-04-03T04:14:35.324Z (3 months ago)
- Topics: cybersecurity, ethics-in-ai, iot-system, renewable-energy
- Language: Python
- Homepage:
- Size: 33.8 MB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Citation: CITATION.cff
Awesome Lists containing this project
README
# EAGF: Ethical AI Governance Framework
> **Joint Optimization of Fairness, Privacy, Explainability & Accountability in AI-Based Cybersecurity**





[](https://colab.research.google.com/github/aliakarma/eagf/blob/main/notebooks/01_eagf_demo.ipynb)
[](https://colab.research.google.com/github/aliakarma/eagf/blob/main/notebooks/02_statistical_analysis.ipynb)
[](https://colab.research.google.com/github/aliakarma/eagf/blob/main/notebooks/03_reiot_fairness.ipynb)
[](https://colab.research.google.com/github/aliakarma/eagf/blob/main/notebooks/04_pareto_front.ipynb)
[](https://colab.research.google.com/github/aliakarma/eagf/blob/main/notebooks/05_trust_index_sensitivity.ipynb)
---
## π Overview
EAGF is a reproducible research framework that combines **differential privacy (DP-SGD)**, **fairness regularization (false positive rate parity)**, **explainability (SHAP)**, and **audit logging** into a unified governance pipeline. Evaluated on the real-world **Edge-IIoTset** (IEEE 2022) for IoT anomaly detection with multi-objective Pareto trade-off analysis.
**Key Focus**: Cybersecurity for IoT networks with resource-constrained devices. EAGF enables governance-aware AI deployment with minimal system overhead.
---
## π― Key Contributions
- π **Real-world dataset integration**: Edge-IIoTset (IEEE 2022, 150K samples, 40 network flow features)
- βοΈ **Multi-objective governance**: Joint optimization of four pillarsβfairness, privacy, clarity, accountability
- π **Trust Index metric**: Composite governance score for model selection and comparison
- π **Pareto trade-off analysis**: Quantify accuracy-fairness-privacy trade-offs with front visualization
- π **Reproducible pipeline**: Deterministic execution, fixed seeds, publication-ready results
---
## π Key Results Summary
**Dataset**: Edge-IIoTset (150K samples, 3 protocol-type protected groups)
**Baselines**: Unregulated + Joint DP+Fair
**Statistical Rigor**: 5 independent seeds with 95% CI
| Metric | Baseline | **EAGF** | Ξ | Improvement |
|--------|----------|----------|-------|-------------|
| **Accuracy** | 0.6481 Β± 0.0251 | **0.6650 Β± 0.0079** | +0.0168 | +2.6% |
| **FPR Parity** | 0.4931 Β± 0.0849 | **0.7709 Β± 0.0573** | +0.2779 | **+56.4%** β |
| **Clarity** | 0.6918 Β± 0.0432 | **0.7390 Β± 0.0548** | +0.0472 | +6.8% |
| **Privacy** | 0.2475 Β± 0.0030 | **0.2482 Β± 0.0025** | +0.0007 | Preserved β |
| **Accountability** | 0.0000 Β± 0.0000 | **0.6667 Β± 0.0000** | +0.6667 | Full coverage β |
| **Trust Index** | 0.3581 Β± 0.0129 | **0.6062 Β± 0.0108** | +0.2481 | **+69.3%** β |
### π¬ Key Findings
β
**Fairness breakthrough**: FPR parity improved +56.4% across protocol-type groups (web, IoT MQTT, misc)
β
**Trust Index surge**: Composite governance metric +69.3%, indicating strong multi-objective alignment
β
**Privacy guarantee**: Differential privacy (Ξ΅=2.4) maintained with negligible DP-Ξ΅ change
β
**Edge deployment ready**: +0.2ms latency (~11%), +5.8MB memoryβsuitable for constrained IoT
β
**Calibration stable**: ECE and Brier comparable (Β±0.05), no metric gaming
---
## π Repository Structure
```
eagf/
βββ π README.md # This file
βββ π requirements.txt # Dependencies (numpy, pandas, scikit-learn, fairlearn, pyyaml)
βββ π§ setup.py # Package setup
β
βββ π run_eagf.py # Single-seed entry point
βββ π run_full_pipeline.py # Multi-seed experiment runner (MAIN)
β
βββ π§ src/
β βββ training/
β β βββ eagf_trainer.py # Main EAGF training loop with governance
β β βββ fairness_loss.py # Fairness penalty (FPR parity)
β β βββ pareto_trainer.py # Pareto front exploration
β β
β βββ evaluation/
β β βββ baseline.py # Unregulated baseline + Joint DP+Fair
β β βββ ablation.py # Single-pillar ablation study
β β βββ report_generator.py # Multi-seed report + statistics
β β βββ audit_logger.py # Compliance audit trail
β β βββ benchmark_suite.py # System metrics (latency, memory, energy)
β β βββ statistics.py # 95% CI, statistical tests
β β
β βββ metrics/
β β βββ fairness.py # FPR parity, recall parity, group metrics
β β βββ privacy.py # DP-SGD evaluation, privacy accounting
β β βββ clarity.py # SHAP-based explainability
β β βββ accountability.py # Audit coverage, compliance scoring
β β βββ trust_index.py # Composite Trust Index aggregation
β β
β βββ utils/
β β βββ data_loader.py # Generic dataset loading
β β βββ edge_iiot_loader.py # Edge-IIoTset specific (protocol_type grouping)
β β βββ real_data_loader.py # Real dataset pipeline
β β βββ preprocessing.py # Feature engineering, normalization
β β βββ reiot_simulator.py # RE-IoT synthetic simulator (optional)
β β βββ ahp.py # Analytic Hierarchy Process (Trust Index weights)
β β βββ visualisation.py # Pareto, Trade-off plots
β β
β βββ baselines/
β βββ aif360_dp_pipeline.py # AIF360 fairness baseline
β βββ joint_dp_fair_baseline.py # Combined DP + fairness baseline
β
βββ βοΈ configs/
β βββ reiot_real.yaml # Main: Edge-IIoTset + EAGF governance (RECOMMENDED)
β βββ reiot_default.yaml # Alternative RE-IoT config
β βββ biometric_default.yaml # Biometric (secondary validation)
β βββ biometric_tuned_auto.yaml # Tuned biometric
β βββ eagf_thresholds.yaml # Governance thresholds
β βββ compliance_checklist*.yaml # Compliance templates
β
βββ π data/
β βββ README.md # Data documentation
β βββ real_iot/
β βββ edge_iiot.csv # Edge-IIoTset (150K rows, 40 features) [USER PROVIDED]
β
βββ π notebooks/
β βββ 01_eagf_demo.ipynb # Quick start demo
β βββ 02_statistical_analysis.ipynb # Multi-seed statistics
β βββ 03_reiot_fairness.ipynb # Fairness deep-dive (protocol_type groups)
β βββ 04_pareto_front.ipynb # Pareto front visualization
β βββ 05_trust_index_sensitivity.ipynb # Sensitivity analysis
β
βββ π¨ figures/
β βββ pareto_front.png # Accuracy vs. Fairness vs. Privacy
β βββ ti_vs_latency.png # Trust Index vs. Inference Latency
β βββ ablation_comparison.png # Single-pillar vs. multi-pillar
β
βββ π docs/
β βββ metric_definitions.md # Detailed metric documentation
β βββ regulatory_mapping.md # Compliance + GDPR/CCPA alignment
β βββ reproducibility.md # Detailed reproducibility steps
β
βββ π§ͺ results/
β βββ final_report.txt # β¨ MAIN DELIVERABLEβaggregated results
β βββ main_results.csv # Baseline, EAGF, Joint metrics (5 seeds)
β βββ pareto_results.csv # Pareto exploration (25 runs)
β βββ [seed-specific subdirs]/ # Individual seed outputs
β
βββ π οΈ scripts/
β βββ run_all.sh # Full pipeline (Edge-IIoT + ablation)
β βββ run_reiot.sh # Edge-IIoTset only
β βββ run_baseline.sh # Baseline only
β βββ run_pareto_search.sh # Pareto front exploration
β βββ sweep_three_stage.py # Hyperparameter sweep
β βββ verify_metrics.py # Metric validation
β
βββ β
tests/
β βββ test_data.py # Data loading & preprocessing
β βββ test_metrics.py # Metric computation
β βββ conftest.py # Pytest fixtures
β βββ run_tests.py # Test runner
β
βββ π³ Dockerfile # Container setup
βββ π environment.yml # Conda environment (optional)
βββ π CONTRIBUTING.md # Contribution guidelines
βββ π LICENSE # MIT License
βββ π CHANGELOG.md # Version history
βββ π CITATION.cff # BibTeX citation metadata
```
---
## πΌοΈ Visualizations & Results
### Figure 1: Pareto Front β Trade-off Analysis
Multi-objective optimization frontier showing EAGF solutions (orange) vs. baseline (blue) across accuracy-fairness-privacy space.
### Figure 2: Trust Index vs. Inference Latency
System efficiency comparison: EAGF maintains high governance (TI=0.61) with minimal latency overhead (+0.2ms/sample).
### Figure 3: Ablation Study β Pillar-by-Pillar Comparison
Impact of each governance pillar on Trust Index. Multi-pillar integration significantly outperforms single-pillar approaches.
---
## π Interactive Notebooks
Run notebooks directly in Google Colab without local setup:
| Notebook | Purpose | Badge |
|----------|---------|-------|
| **01_eagf_demo.ipynb** | 5-minute quick start | [](https://colab.research.google.com/github/aliakarma/eagf/blob/main/notebooks/01_eagf_demo.ipynb) |
| **02_statistical_analysis.ipynb** | Multi-seed statistics, hypothesis tests | [](https://colab.research.google.com/github/aliakarma/eagf/blob/main/notebooks/02_statistical_analysis.ipynb) |
| **03_reiot_fairness.ipynb** | Fairness deep-dive by protocol-type groups | [](https://colab.research.google.com/github/aliakarma/eagf/blob/main/notebooks/03_reiot_fairness.ipynb) |
| **04_pareto_front.ipynb** | Interactive Pareto front exploration | [](https://colab.research.google.com/github/aliakarma/eagf/blob/main/notebooks/04_pareto_front.ipynb) |
| **05_trust_index_sensitivity.ipynb** | Trust Index weight sensitivity analysis | [](https://colab.research.google.com/github/aliakarma/eagf/blob/main/notebooks/05_trust_index_sensitivity.ipynb) |
---
## βοΈ Installation
### Requirements
- Python 3.9+
- pip
### Setup
```bash
git clone https://github.com/aliakarma/eagf.git
cd eagf
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux / macOS
source .venv/bin/activate
pip install -r requirements.txt
```
---
## Dataset Setup
### Edge-IIoTset (Required)
**Dataset**: ML-EdgeIIoT-dataset.csv (real-world IoT anomaly detection)
**Source**: IEEE Access 2022 (Ferrag et al.)
**Size**: ~78 MB (157.8K raw rows)
**Features**: 40 network flow + protocol-specific attributes
**Labels**: Normal vs. Attack (imbalanced: 23.1K vs. 126.9K)
**Note**: EAGF uses real Edge-IIoTset data only. No synthetic fallback.
### Setup Instructions
**Option A: Manual Download (Recommended)**
1. Download `ML-EdgeIIoT-dataset.csv` from [IEEE DataPort](https://dx.doi.org/10.21203/rs.3.rs-1433551/v1)
2. Extract and place at:
```
data/real_iot/edge_iiot.csv
```
**Option B: Verify Existing Data**
If you already have the dataset:
```bash
# Check file size (~78 MB)
ls -lh data/real_iot/edge_iiot.csv
```
---
## π Output Files & Deliverables
| File | Description | Format |
|------|-------------|--------|
| **results/final_report.txt** | β¨ Main deliverableβaggregated metrics, statistics, validation gates | TXT |
| **results/main_results.csv** | Summary table: baseline, EAGF, Joint DP+Fair across all metrics | CSV |
| **results/pareto_results.csv** | Pareto search results (25 multi-objective runs with trade-off scores) | CSV |
| **figures/pareto_front.png** | 3D visualization: accuracy vs. fairness vs. privacy | PNG |
| **figures/ti_vs_latency.png** | 2D scatter: Trust Index vs. inference latency | PNG |
| **figures/ablation_comparison.png** | Bar chart: pillar ablation study (single vs. multi-pillar) | PNG |
| **[seed-specific]/predictions.json** | Per-sample predictions, confidences, fairness group info | JSON |
| **[seed-specific]/metrics.json** | Detailed metrics for each seed | JSON |
---
## π Quick Start (Smoke Test)
Validate the entire pipeline in ~5 minutes using a single seed:
```bash
python run_full_pipeline.py \
--real_dataset edge_iiot \
--config configs/reiot_real.yaml \
--seeds 42 \
--fast
```
**What happens**:
- β Loads Edge-IIoTset and validates data
- β Trains baseline + EAGF + Joint DP+Fair models (1 seed)
- β Computes fairness, privacy, clarity, accountability metrics
- β Generates `results/final_report.txt` with summary
- β Produces figures in `figures/`
**Expected runtime**: ~5 min on CPU (Intel Core i7)
---
## π Full Experiment (Publication Results)
Reproduce final results with 5 independent seeds (statistical rigor):
```bash
python run_full_pipeline.py \
--real_dataset edge_iiot \
--config configs/reiot_real.yaml \
--seeds 42 43 44 45 46
```
**Output**:
- Mean Β± std for all governance metrics
- 95% confidence intervals
- Pareto front visualization (25 multi-objective runs)
- Final report with ablation analysis
- Seed-specific detailed logs
**Expected runtime**: ~10β15 min on CPU
---
## π¬ Advanced: Pareto Front Search
Explore the full accuracy-fairness-privacy trade-off surface:
```bash
python -c "
from src.training.pareto_trainer import ParetoTrainer
from src.utils.edge_iiot_loader import EdgeIIoTLoader
loader = EdgeIIoTLoader('data/real_iot/edge_iiot.csv')
X_train, X_test, y_train, y_test, groups = loader.load()
trainer = ParetoTrainer(X_train, y_train, groups, seed=42)
trainer.search(n_objectives=3, n_runs=25) # Explore 25 configurations
trainer.plot_pareto('figures/pareto_custom.png')
"
```
---
## Key Results
**Dataset**: Edge-IIoTset (150K samples, protocol-type protected groups)
**Baselines**: Unregulated model, Joint DP+Fair
**Seeds**: 5 independent runs
**Metrics**: Accuracy, Fairness (FPR Parity), Clarity, Privacy, Accountability, Trust Index
### Summary (Mean Β± Std)
| Metric | Baseline | **EAGF** | Ξ |
|--------|----------|----------|-----|
| **Accuracy** | 0.6481 Β± 0.0251 | **0.6650 Β± 0.0079** | +0.0168 (+2.6%) |
| **FPR Parity** | 0.4931 Β± 0.0849 | **0.7709 Β± 0.0573** | +0.2779 (+56.4%) |
| **Clarity** | 0.6918 Β± 0.0432 | **0.7390 Β± 0.0548** | +0.0472 (+6.8%) |
| **Privacy** | 0.2475 Β± 0.0030 | **0.2482 Β± 0.0025** | +0.0007 (+0.3%, preserved) |
| **Accountability** | 0.0000 Β± 0.0000 | **0.6667 Β± 0.0000** | +0.6667 β |
| **Trust Index** | 0.3581 Β± 0.0129 | **0.6062 Β± 0.0108** | +0.2481 (+69.3%) |
### Key Findings
- **Fairness via FPR Parity**: EAGF achieves +56.4% improvement in false positive rate fairness across protocol-type groups (web, IoT MQTT, misc). Disparities in false alarm rates reduced from 49.3% to 23% spread.
- **Trust Index**: Composite governance metric improves by +69.3%, indicating strong multi-objective alignment.
- **Privacy Preserved**: Differential privacy (Ξ΅=2.4) maintained with negligible change vs. baseline. No privacy regression.
- **Minimal System Overhead**: Inference latency +0.2ms/sample (~11% increase); memory +5.8 MB. Suitable for edge deployment.
- **Calibration Stability**: ECE and Brier scores comparable (within Β±0.05), no metric gaming.
---
## ποΈ Method Overview
### Four-Pillar Governance Architecture
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β EAGF Framework β
βββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββββββββββββββββ€
β Clarity β Fairness β Privacy β Accountability β
βββββββββββΌβββββββββββΌβββββββββββΌβββββββββββββββββββββββββ€
β SHAP β FPRP β DP-SGD β Audit Logging + Rules β
β Loss β Loss β Gradient β Compliance Coverage β
βββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββββββββββββββββ
β
Trust Index (TI)
Weighted Aggregation via AHP
```
### Key Components
| Pillar | Metric | Implementation | Config |
|--------|--------|-----------------|--------|
| **Fairness** | FPR Parity | `src/metrics/fairness.py` | `lambda_rp: 0.2` |
| **Privacy** | DP Accounting | `src/metrics/privacy.py` | `dp_epsilon: 2.4` |
| **Clarity** | SHAP Sparsity | `src/metrics/clarity.py` | `lambda_c: 0.05` |
| **Accountability** | Audit Coverage | `src/metrics/accountability.py` | Compliance rules |
---
## π Reproducibility & Validation
### Deterministic Execution
- **Fixed seeds**: 42β46 (5 independent runs)
- **Deterministic pipeline**: Reproducible to Β±0.005 variance (NumPy/PyTorch seeds)
- **No hidden preprocessing**: All transformations logged in `audit_logger.py`
- **Hyperparameter justification**: See [configs/reiot_real.yaml](configs/reiot_real.yaml)
### Validation Gates
All experiments must satisfy:
- β FPR Parity EAGF β₯ Baseline + 0.02 (fairness improvement)
- β Privacy EAGF β₯ Baseline (no regression)
- β Accuracy drop β€ 2% (stability requirement)
- β Trust Index EAGF > Baseline (overall improvement)
---
## π Documentation
| File | Purpose |
|------|---------|
| [docs/metric_definitions.md](docs/metric_definitions.md) | Detailed fairness, privacy, clarity, accountability metrics |
| [docs/regulatory_mapping.md](docs/regulatory_mapping.md) | GDPR, CCPA, ISO alignment |
| [docs/reproducibility.md](docs/reproducibility.md) | Step-by-step reproducibility guide |
---
## π Related Work
- **Fairness**: Hardt et al. (2016), Moritz et al. (2020)
- **Privacy**: Abadi et al. (2016) DP-SGD, Kairouz et al. (2021) DP survey
- **Explainability**: Lundberg & Lee (2017) SHAP
- **IoT Security**: Ferrag et al. (2022) Edge-IIoTset
---
## π License
MIT License β See [LICENSE](LICENSE) for full terms.
---
## π€ Contributing
Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
---
## π¬ Support & Issues
For reproducibility help, issues, or questions:
1. **Check diagnostics**: See `results/final_report.txt` for detailed error logs
2. **Verify dataset**: Ensure `data/real_iot/edge_iiot.csv` exists (~78 MB)
3. **Check environment**:
```bash
python -m pip show scikit-learn fairlearn numpy pandas
```
4. **Open issue**: Include OS, Python version, full error trace, and reproducibility steps
---
## π§ Contact
- **Maintainer**: Ali Akarma
- **Email**: [aliakarma974@gmail.com]
- **Issues**: [GitHub Issues](https://github.com/aliakarma/eagf/issues)
---
**Last Updated**: March 2026 | Python 3.9+ | PyTorch 2.0+