Datasets:
Upload folder using huggingface_hub
Browse files- README.md +99 -0
- data/baseline.csv +0 -0
- data/strengthened_enforcement.csv +0 -0
- data/weakened_accountability.csv +0 -0
- generate_dataset.py +352 -0
- plots/diagnostic_panels.png +3 -0
- requirements.txt +4 -0
- validate_dataset.py +251 -0
README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- tabular-classification
|
| 5 |
+
- regression
|
| 6 |
+
tags:
|
| 7 |
+
- governance
|
| 8 |
+
- anti-corruption
|
| 9 |
+
- accountability
|
| 10 |
+
- sub-saharan-africa
|
| 11 |
+
- synthetic
|
| 12 |
+
- lmic
|
| 13 |
+
- transparency
|
| 14 |
+
- enforcement
|
| 15 |
+
- public-sector
|
| 16 |
+
pretty_name: African Anti-Corruption Enforcement
|
| 17 |
+
size_categories:
|
| 18 |
+
- 10K<n<100K
|
| 19 |
+
configs:
|
| 20 |
+
- config_name: baseline
|
| 21 |
+
data_files: data/baseline.csv
|
| 22 |
+
- config_name: strengthened_enforcement
|
| 23 |
+
data_files: data/strengthened_enforcement.csv
|
| 24 |
+
- config_name: weakened_accountability
|
| 25 |
+
data_files: data/weakened_accountability.csv
|
| 26 |
+
---
|
| 27 |
+
|
| 28 |
+
# African Anti-Corruption Enforcement
|
| 29 |
+
|
| 30 |
+
Synthetic dataset modelling anti-corruption enforcement outcomes across 12 Sub-Saharan African countries under three policy scenarios. Parameters are anchored to real-world statistics from Transparency International, the EFCC (Nigeria), SIU/Zondo Commission (South Africa), EACC (Kenya), the African Union's Common African Position on Asset Recovery, and the G20 2025 Accountability Report on Whistleblower Protection.
|
| 31 |
+
|
| 32 |
+
## Dataset Summary
|
| 33 |
+
|
| 34 |
+
| Property | Value |
|
| 35 |
+
|---|---|
|
| 36 |
+
| Total records | 30,000 (10,000 per scenario) |
|
| 37 |
+
| Countries | 12 SSA nations |
|
| 38 |
+
| Variables | 15 per record |
|
| 39 |
+
| Scenarios | baseline, strengthened_enforcement, weakened_accountability |
|
| 40 |
+
|
| 41 |
+
## Scenarios
|
| 42 |
+
|
| 43 |
+
- **baseline** – Calibrated to observed 2023–2025 enforcement statistics. Median prosecution rate ~25%, median asset recovery rate ~7%.
|
| 44 |
+
- **strengthened_enforcement** – Simulates higher agency independence (+18), stronger whistleblower protection (+20), increased prosecution (+45%), doubled asset recovery, and +8 CPI points.
|
| 45 |
+
- **weakened_accountability** – Models institutional erosion: agency independence −15, whistleblower protection −15, prosecution −40%, asset recovery −60%, and −10 CPI points.
|
| 46 |
+
|
| 47 |
+
## Countries
|
| 48 |
+
|
| 49 |
+
Nigeria, South Africa, Kenya, Ghana, Tanzania, Uganda, Ethiopia, Senegal, Mozambique, Zambia, Rwanda, Botswana.
|
| 50 |
+
|
| 51 |
+
## Variables
|
| 52 |
+
|
| 53 |
+
| Variable | Type | Description |
|
| 54 |
+
|---|---|---|
|
| 55 |
+
| `country` | str | Country name |
|
| 56 |
+
| `scenario` | str | Policy scenario |
|
| 57 |
+
| `corruption_perception_index` | float | TI CPI score (0–100, higher = cleaner) |
|
| 58 |
+
| `cases_investigated` | int | Number of corruption cases under investigation |
|
| 59 |
+
| `cases_prosecuted` | int | Cases forwarded to prosecution |
|
| 60 |
+
| `prosecution_rate` | float | cases_prosecuted / cases_investigated |
|
| 61 |
+
| `convictions` | int | Number of convictions secured |
|
| 62 |
+
| `conviction_rate` | float | convictions / cases_prosecuted |
|
| 63 |
+
| `assets_confiscated_usd_millions` | float | Value of confiscated assets (USD millions) |
|
| 64 |
+
| `asset_recovery_rate` | float | Fraction of estimated stolen assets recovered |
|
| 65 |
+
| `whistleblower_reports` | int | Number of whistleblower submissions |
|
| 66 |
+
| `whistleblower_protection_score` | float | Protection framework quality (0–100) |
|
| 67 |
+
| `agency_independence_score` | float | Anti-corruption agency independence (0–100) |
|
| 68 |
+
| `enforcement_effectiveness_score` | float | Composite effectiveness index (0–100) |
|
| 69 |
+
| `enforcement_class` | str | strong / moderate / weak |
|
| 70 |
+
|
| 71 |
+
## Research Sources
|
| 72 |
+
|
| 73 |
+
1. **Transparency International CPI 2025** – SSA average score 32/100; Seychelles (68) highest, Somalia/South Sudan (9) lowest.
|
| 74 |
+
2. **EFCC Nigeria 2024** – 15,724 petitions → 12,928 investigated → 5,083 prosecuted → 4,111 convictions; $214.5M recovered.
|
| 75 |
+
3. **South Africa SIU 2023/24** – 1,919 investigations closed, 583 criminal referrals, R8B saved, ~80% conviction rate in commercial cases.
|
| 76 |
+
4. **Kenya EACC 2023/24** – 5,171 reports, 534 files under probe, 26.7% conviction rate, Ksh2.9B recovered.
|
| 77 |
+
5. **AU Common African Position on Asset Recovery** – Africa loses ~$150B annually through illicit financial flows; asset recovery typically <10%.
|
| 78 |
+
6. **G20 2025 Accountability Report on Whistleblower Protection** – Most SSA countries lack dedicated whistleblower legislation; protection gaps in developing countries.
|
| 79 |
+
|
| 80 |
+
## Usage
|
| 81 |
+
|
| 82 |
+
```python
|
| 83 |
+
from datasets import load_dataset
|
| 84 |
+
|
| 85 |
+
ds = load_dataset("electricsheepafrica/african-anti-corruption-enforcement", "baseline")
|
| 86 |
+
df = ds["train"].to_pandas()
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
## Generation & Validation
|
| 90 |
+
|
| 91 |
+
```bash
|
| 92 |
+
pip install -r requirements.txt
|
| 93 |
+
python generate_dataset.py --scenario all --n-records 10000
|
| 94 |
+
python validate_dataset.py --data-dir data --plot-dir plots
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
## License
|
| 98 |
+
|
| 99 |
+
CC-BY-4.0
|
data/baseline.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/strengthened_enforcement.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/weakened_accountability.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
generate_dataset.py
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
African Anti-Corruption Enforcement Dataset Generator
|
| 4 |
+
|
| 5 |
+
Generates synthetic records for 12 Sub-Saharan African countries across
|
| 6 |
+
three enforcement scenarios. Parameters are informed by:
|
| 7 |
+
- Transparency International CPI 2025 (SSA avg=32, range 9-68)
|
| 8 |
+
- EFCC Nigeria 2024 statistics (12,928 investigated, 5,083 prosecuted,
|
| 9 |
+
4,111 convictions, ~$214M recovered)
|
| 10 |
+
- South Africa SIU 2023/24 (1,919 investigations, 583 referrals,
|
| 11 |
+
R8B saved, ~80% conviction rate in commercial cases)
|
| 12 |
+
- Kenya EACC 2023/24 (5,171 reports, 534 under probe, 26.7% conviction
|
| 13 |
+
rate, Ksh2.9B recovered)
|
| 14 |
+
- AU Common African Position on Asset Recovery (asset recovery <10%)
|
| 15 |
+
- G20 2025 Accountability Report on Whistleblower Protection
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
import os
|
| 19 |
+
import argparse
|
| 20 |
+
import numpy as np
|
| 21 |
+
import pandas as pd
|
| 22 |
+
from scipy import stats
|
| 23 |
+
|
| 24 |
+
RNG_SEED = 42
|
| 25 |
+
|
| 26 |
+
# ── Country parameters ──────────────────────────────────────────────
|
| 27 |
+
# Based on TI CPI 2025, population, anti-corruption agency capacity,
|
| 28 |
+
# whistleblower protection maturity, and typical caseload volumes.
|
| 29 |
+
COUNTRIES = {
|
| 30 |
+
"Nigeria": {
|
| 31 |
+
"cpi_mean": 32, "cpi_std": 2.0,
|
| 32 |
+
"pop_millions": 220,
|
| 33 |
+
"agency_independence_mean": 42, "agency_independence_std": 8,
|
| 34 |
+
"whistleblower_protection_mean": 33, "whistleblower_protection_std": 7,
|
| 35 |
+
"cases_investigated_range": (10000, 18000), # EFCC 12,928 in 2024
|
| 36 |
+
"prosecution_rate_base": 0.35, # EFCC: 5,083/12,928 ≈ 39%
|
| 37 |
+
"conviction_rate_base": 0.72, # EFCC high conviction capacity
|
| 38 |
+
"asset_recovery_rate_base": 0.08,
|
| 39 |
+
"assets_usd_millions_range": (80, 250), # EFCC $214M in 2024
|
| 40 |
+
},
|
| 41 |
+
"South Africa": {
|
| 42 |
+
"cpi_mean": 43, "cpi_std": 2.5,
|
| 43 |
+
"pop_millions": 60,
|
| 44 |
+
"agency_independence_mean": 55, "agency_independence_std": 10,
|
| 45 |
+
"whistleblower_protection_mean": 48, "whistleblower_protection_std": 9,
|
| 46 |
+
"cases_investigated_range": (1800, 2800), # SIU 1,919 closed in 2023/24
|
| 47 |
+
"prosecution_rate_base": 0.28, # SIU 583 referrals from 1,919
|
| 48 |
+
"conviction_rate_base": 0.75, # NPA ~80% in commercial cases
|
| 49 |
+
"asset_recovery_rate_base": 0.12,
|
| 50 |
+
"assets_usd_millions_range": (100, 350), # SIU R8B ≈ $430M
|
| 51 |
+
},
|
| 52 |
+
"Kenya": {
|
| 53 |
+
"cpi_mean": 30, "cpi_std": 2.0,
|
| 54 |
+
"pop_millions": 55,
|
| 55 |
+
"agency_independence_mean": 38, "agency_independence_std": 7,
|
| 56 |
+
"whistleblower_protection_mean": 30, "whistleblower_protection_std": 6,
|
| 57 |
+
"cases_investigated_range": (4000, 6000), # EACC 5,171 reports
|
| 58 |
+
"prosecution_rate_base": 0.22, # EACC forwards to ODPP
|
| 59 |
+
"conviction_rate_base": 0.45, # EACC 26.7% (2023/24), improving
|
| 60 |
+
"asset_recovery_rate_base": 0.06,
|
| 61 |
+
"assets_usd_millions_range": (15, 40),
|
| 62 |
+
},
|
| 63 |
+
"Ghana": {
|
| 64 |
+
"cpi_mean": 43, "cpi_std": 2.5,
|
| 65 |
+
"pop_millions": 34,
|
| 66 |
+
"agency_independence_mean": 50, "agency_independence_std": 8,
|
| 67 |
+
"whistleblower_protection_mean": 40, "whistleblower_protection_std": 7,
|
| 68 |
+
"cases_investigated_range": (800, 1500),
|
| 69 |
+
"prosecution_rate_base": 0.30,
|
| 70 |
+
"conviction_rate_base": 0.55,
|
| 71 |
+
"asset_recovery_rate_base": 0.07,
|
| 72 |
+
"assets_usd_millions_range": (8, 30),
|
| 73 |
+
},
|
| 74 |
+
"Tanzania": {
|
| 75 |
+
"cpi_mean": 38, "cpi_std": 2.0,
|
| 76 |
+
"pop_millions": 65,
|
| 77 |
+
"agency_independence_mean": 35, "agency_independence_std": 7,
|
| 78 |
+
"whistleblower_protection_mean": 25, "whistleblower_protection_std": 6,
|
| 79 |
+
"cases_investigated_range": (2000, 4000),
|
| 80 |
+
"prosecution_rate_base": 0.25,
|
| 81 |
+
"conviction_rate_base": 0.60,
|
| 82 |
+
"asset_recovery_rate_base": 0.05,
|
| 83 |
+
"assets_usd_millions_range": (10, 35),
|
| 84 |
+
},
|
| 85 |
+
"Uganda": {
|
| 86 |
+
"cpi_mean": 26, "cpi_std": 2.0,
|
| 87 |
+
"pop_millions": 48,
|
| 88 |
+
"agency_independence_mean": 30, "agency_independence_std": 7,
|
| 89 |
+
"whistleblower_protection_mean": 22, "whistleblower_protection_std": 5,
|
| 90 |
+
"cases_investigated_range": (1500, 3000),
|
| 91 |
+
"prosecution_rate_base": 0.18,
|
| 92 |
+
"conviction_rate_base": 0.40,
|
| 93 |
+
"asset_recovery_rate_base": 0.04,
|
| 94 |
+
"assets_usd_millions_range": (5, 20),
|
| 95 |
+
},
|
| 96 |
+
"Ethiopia": {
|
| 97 |
+
"cpi_mean": 30, "cpi_std": 2.5,
|
| 98 |
+
"pop_millions": 120,
|
| 99 |
+
"agency_independence_mean": 28, "agency_independence_std": 8,
|
| 100 |
+
"whistleblower_protection_mean": 18, "whistleblower_protection_std": 5,
|
| 101 |
+
"cases_investigated_range": (1000, 2500),
|
| 102 |
+
"prosecution_rate_base": 0.15,
|
| 103 |
+
"conviction_rate_base": 0.50,
|
| 104 |
+
"asset_recovery_rate_base": 0.04,
|
| 105 |
+
"assets_usd_millions_range": (5, 25),
|
| 106 |
+
},
|
| 107 |
+
"Senegal": {
|
| 108 |
+
"cpi_mean": 46, "cpi_std": 2.0,
|
| 109 |
+
"pop_millions": 18,
|
| 110 |
+
"agency_independence_mean": 55, "agency_independence_std": 8,
|
| 111 |
+
"whistleblower_protection_mean": 42, "whistleblower_protection_std": 7,
|
| 112 |
+
"cases_investigated_range": (600, 1200),
|
| 113 |
+
"prosecution_rate_base": 0.32,
|
| 114 |
+
"conviction_rate_base": 0.55,
|
| 115 |
+
"asset_recovery_rate_base": 0.08,
|
| 116 |
+
"assets_usd_millions_range": (5, 20),
|
| 117 |
+
},
|
| 118 |
+
"Mozambique": {
|
| 119 |
+
"cpi_mean": 21, "cpi_std": 2.0,
|
| 120 |
+
"pop_millions": 33,
|
| 121 |
+
"agency_independence_mean": 22, "agency_independence_std": 6,
|
| 122 |
+
"whistleblower_protection_mean": 15, "whistleblower_protection_std": 4,
|
| 123 |
+
"cases_investigated_range": (300, 800),
|
| 124 |
+
"prosecution_rate_base": 0.12,
|
| 125 |
+
"conviction_rate_base": 0.35,
|
| 126 |
+
"asset_recovery_rate_base": 0.03,
|
| 127 |
+
"assets_usd_millions_range": (2, 10),
|
| 128 |
+
},
|
| 129 |
+
"Zambia": {
|
| 130 |
+
"cpi_mean": 33, "cpi_std": 2.0,
|
| 131 |
+
"pop_millions": 20,
|
| 132 |
+
"agency_independence_mean": 40, "agency_independence_std": 7,
|
| 133 |
+
"whistleblower_protection_mean": 28, "whistleblower_protection_std": 6,
|
| 134 |
+
"cases_investigated_range": (500, 1200),
|
| 135 |
+
"prosecution_rate_base": 0.20,
|
| 136 |
+
"conviction_rate_base": 0.45,
|
| 137 |
+
"asset_recovery_rate_base": 0.05,
|
| 138 |
+
"assets_usd_millions_range": (3, 15),
|
| 139 |
+
},
|
| 140 |
+
"Rwanda": {
|
| 141 |
+
"cpi_mean": 58, "cpi_std": 2.5,
|
| 142 |
+
"pop_millions": 14,
|
| 143 |
+
"agency_independence_mean": 65, "agency_independence_std": 8,
|
| 144 |
+
"whistleblower_protection_mean": 55, "whistleblower_protection_std": 8,
|
| 145 |
+
"cases_investigated_range": (400, 900),
|
| 146 |
+
"prosecution_rate_base": 0.45,
|
| 147 |
+
"conviction_rate_base": 0.70,
|
| 148 |
+
"asset_recovery_rate_base": 0.15,
|
| 149 |
+
"assets_usd_millions_range": (3, 12),
|
| 150 |
+
},
|
| 151 |
+
"Botswana": {
|
| 152 |
+
"cpi_mean": 58, "cpi_std": 2.5,
|
| 153 |
+
"pop_millions": 2.6,
|
| 154 |
+
"agency_independence_mean": 62, "agency_independence_std": 8,
|
| 155 |
+
"whistleblower_protection_mean": 50, "whistleblower_protection_std": 8,
|
| 156 |
+
"cases_investigated_range": (200, 500),
|
| 157 |
+
"prosecution_rate_base": 0.40,
|
| 158 |
+
"conviction_rate_base": 0.65,
|
| 159 |
+
"asset_recovery_rate_base": 0.12,
|
| 160 |
+
"assets_usd_millions_range": (2, 8),
|
| 161 |
+
},
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
SCENARIOS = {
|
| 165 |
+
"baseline": {
|
| 166 |
+
"cpi_shift": 0,
|
| 167 |
+
"agency_shift": 0,
|
| 168 |
+
"whistleblower_shift": 0,
|
| 169 |
+
"prosecution_multiplier": 1.0,
|
| 170 |
+
"conviction_multiplier": 1.0,
|
| 171 |
+
"asset_recovery_multiplier": 1.0,
|
| 172 |
+
"investigated_multiplier": 1.0,
|
| 173 |
+
},
|
| 174 |
+
"strengthened_enforcement": {
|
| 175 |
+
"cpi_shift": 8, # +8 points on CPI
|
| 176 |
+
"agency_shift": 18, # +18 on independence score
|
| 177 |
+
"whistleblower_shift": 20, # +20 on protection score
|
| 178 |
+
"prosecution_multiplier": 1.45,
|
| 179 |
+
"conviction_multiplier": 1.15,
|
| 180 |
+
"asset_recovery_multiplier": 2.0,
|
| 181 |
+
"investigated_multiplier": 1.25,
|
| 182 |
+
},
|
| 183 |
+
"weakened_accountability": {
|
| 184 |
+
"cpi_shift": -10,
|
| 185 |
+
"agency_shift": -15,
|
| 186 |
+
"whistleblower_shift": -15,
|
| 187 |
+
"prosecution_multiplier": 0.60,
|
| 188 |
+
"conviction_multiplier": 0.80,
|
| 189 |
+
"asset_recovery_multiplier": 0.40,
|
| 190 |
+
"investigated_multiplier": 0.70,
|
| 191 |
+
},
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
def clamp(x, lo, hi):
|
| 196 |
+
return np.clip(x, lo, hi)
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
def generate_country_scenario(country_name, params, scenario_name, scenario_params, n_records, rng):
|
| 200 |
+
"""Generate n_records for one country under one scenario."""
|
| 201 |
+
|
| 202 |
+
# ── Scores derived from scenario ──
|
| 203 |
+
cpi = rng.normal(
|
| 204 |
+
params["cpi_mean"] + scenario_params["cpi_shift"],
|
| 205 |
+
params["cpi_std"], n_records
|
| 206 |
+
)
|
| 207 |
+
cpi = clamp(cpi, 0, 100)
|
| 208 |
+
|
| 209 |
+
agency_independence = rng.normal(
|
| 210 |
+
params["agency_independence_mean"] + scenario_params["agency_shift"],
|
| 211 |
+
params["agency_independence_std"], n_records
|
| 212 |
+
)
|
| 213 |
+
agency_independence = clamp(agency_independence, 0, 100)
|
| 214 |
+
|
| 215 |
+
whistleblower_protection = rng.normal(
|
| 216 |
+
params["whistleblower_protection_mean"] + scenario_params["whistleblower_shift"],
|
| 217 |
+
params["whistleblower_protection_std"], n_records
|
| 218 |
+
)
|
| 219 |
+
whistleblower_protection = clamp(whistleblower_protection, 0, 100)
|
| 220 |
+
|
| 221 |
+
# ── Cases investigated (population-scaled) ──
|
| 222 |
+
pop_scale = params["pop_millions"] / 60 # normalise to SA baseline
|
| 223 |
+
inv_lo, inv_hi = params["cases_investigated_range"]
|
| 224 |
+
inv_base = rng.uniform(inv_lo * pop_scale, inv_hi * pop_scale, n_records)
|
| 225 |
+
cases_investigated = np.round(
|
| 226 |
+
inv_base * scenario_params["investigated_multiplier"]
|
| 227 |
+
).astype(int)
|
| 228 |
+
cases_investigated = np.maximum(cases_investigated, 10)
|
| 229 |
+
|
| 230 |
+
# ── Prosecution rate (correlated with agency independence) ──
|
| 231 |
+
prot_base = params["prosecution_rate_base"] * scenario_params["prosecution_multiplier"]
|
| 232 |
+
# Agency independence boosts prosecution rate
|
| 233 |
+
agency_effect = (agency_independence - 50) / 500 # ±0.1 shift
|
| 234 |
+
prosecution_rate = prot_base + agency_effect + rng.normal(0, 0.04, n_records)
|
| 235 |
+
prosecution_rate = clamp(prosecution_rate, 0.02, 0.85)
|
| 236 |
+
|
| 237 |
+
cases_prosecuted = np.round(cases_investigated * prosecution_rate).astype(int)
|
| 238 |
+
cases_prosecuted = np.minimum(cases_prosecuted, cases_investigated)
|
| 239 |
+
cases_prosecuted = np.maximum(cases_prosecuted, 0)
|
| 240 |
+
|
| 241 |
+
# ── Conviction rate ─���
|
| 242 |
+
conv_base = params["conviction_rate_base"] * scenario_params["conviction_multiplier"]
|
| 243 |
+
conv_rate = conv_base + rng.normal(0, 0.06, n_records)
|
| 244 |
+
conv_rate = clamp(conv_rate, 0.05, 0.95)
|
| 245 |
+
|
| 246 |
+
convictions = np.round(cases_prosecuted * conv_rate).astype(int)
|
| 247 |
+
convictions = np.minimum(convictions, cases_prosecuted)
|
| 248 |
+
convictions = np.maximum(convictions, 0)
|
| 249 |
+
|
| 250 |
+
# ── Asset confiscation ──
|
| 251 |
+
asset_lo, asset_hi = params["assets_usd_millions_range"]
|
| 252 |
+
assets_confiscated = rng.uniform(asset_lo, asset_hi, n_records) * scenario_params["asset_recovery_multiplier"]
|
| 253 |
+
assets_confiscated = np.maximum(assets_confiscated, 0.1)
|
| 254 |
+
|
| 255 |
+
asset_recovery_rate = params["asset_recovery_rate_base"] * scenario_params["asset_recovery_multiplier"]
|
| 256 |
+
asset_recovery_rate = clamp(
|
| 257 |
+
asset_recovery_rate + rng.normal(0, 0.02, n_records), 0.01, 0.50
|
| 258 |
+
)
|
| 259 |
+
|
| 260 |
+
# ── Whistleblower reports ──
|
| 261 |
+
wb_base = cases_investigated * rng.uniform(0.3, 0.8, n_records)
|
| 262 |
+
wb_effect = 1 + (whistleblower_protection - 30) / 100
|
| 263 |
+
whistleblower_reports = np.round(wb_base * wb_effect).astype(int)
|
| 264 |
+
whistleblower_reports = np.maximum(whistleblower_reports, 0)
|
| 265 |
+
|
| 266 |
+
# ── Enforcement effectiveness composite ──
|
| 267 |
+
enforcement_effectiveness = (
|
| 268 |
+
0.25 * (prosecution_rate / 0.5) +
|
| 269 |
+
0.25 * (conv_rate / 0.8) +
|
| 270 |
+
0.20 * (asset_recovery_rate / 0.15) +
|
| 271 |
+
0.15 * (agency_independence / 100) +
|
| 272 |
+
0.15 * (whistleblower_protection / 100)
|
| 273 |
+
) * 100
|
| 274 |
+
enforcement_effectiveness = clamp(enforcement_effectiveness, 0, 100)
|
| 275 |
+
|
| 276 |
+
# ── Enforcement class ──
|
| 277 |
+
enforcement_class = np.where(
|
| 278 |
+
enforcement_effectiveness >= 60, "strong",
|
| 279 |
+
np.where(enforcement_effectiveness >= 35, "moderate", "weak")
|
| 280 |
+
)
|
| 281 |
+
|
| 282 |
+
# ── Build DataFrame ──
|
| 283 |
+
df = pd.DataFrame({
|
| 284 |
+
"country": country_name,
|
| 285 |
+
"scenario": scenario_name,
|
| 286 |
+
"corruption_perception_index": np.round(cpi, 1),
|
| 287 |
+
"cases_investigated": cases_investigated,
|
| 288 |
+
"cases_prosecuted": cases_prosecuted,
|
| 289 |
+
"prosecution_rate": np.round(prosecution_rate, 4),
|
| 290 |
+
"convictions": convictions,
|
| 291 |
+
"conviction_rate": np.round(conv_rate, 4),
|
| 292 |
+
"assets_confiscated_usd_millions": np.round(assets_confiscated, 2),
|
| 293 |
+
"asset_recovery_rate": np.round(asset_recovery_rate, 4),
|
| 294 |
+
"whistleblower_reports": whistleblower_reports,
|
| 295 |
+
"whistleblower_protection_score": np.round(whistleblower_protection, 1),
|
| 296 |
+
"agency_independence_score": np.round(agency_independence, 1),
|
| 297 |
+
"enforcement_effectiveness_score": np.round(enforcement_effectiveness, 1),
|
| 298 |
+
"enforcement_class": enforcement_class,
|
| 299 |
+
})
|
| 300 |
+
return df
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
def generate_dataset(scenario, n_per_country=834, seed=RNG_SEED):
|
| 304 |
+
"""Generate full dataset for one scenario across all 12 countries."""
|
| 305 |
+
rng = np.random.default_rng(seed)
|
| 306 |
+
scenario_params = SCENARIOS[scenario]
|
| 307 |
+
frames = []
|
| 308 |
+
for country_name, params in COUNTRIES.items():
|
| 309 |
+
df = generate_country_scenario(
|
| 310 |
+
country_name, params, scenario, scenario_params, n_per_country, rng
|
| 311 |
+
)
|
| 312 |
+
frames.append(df)
|
| 313 |
+
full = pd.concat(frames, ignore_index=True)
|
| 314 |
+
# Shuffle
|
| 315 |
+
full = full.sample(frac=1, random_state=seed).reset_index(drop=True)
|
| 316 |
+
return full
|
| 317 |
+
|
| 318 |
+
|
| 319 |
+
def main():
|
| 320 |
+
parser = argparse.ArgumentParser(description="Generate anti-corruption enforcement dataset")
|
| 321 |
+
parser.add_argument("--scenario", type=str, default="all",
|
| 322 |
+
choices=list(SCENARIOS.keys()) + ["all"])
|
| 323 |
+
parser.add_argument("--n-records", type=int, default=10000,
|
| 324 |
+
help="Total records per scenario (split across 12 countries)")
|
| 325 |
+
parser.add_argument("--output-dir", type=str, default="data")
|
| 326 |
+
args = parser.parse_args()
|
| 327 |
+
|
| 328 |
+
os.makedirs(args.output_dir, exist_ok=True)
|
| 329 |
+
scenarios = list(SCENARIOS.keys()) if args.scenario == "all" else [args.scenario]
|
| 330 |
+
|
| 331 |
+
for scen in scenarios:
|
| 332 |
+
n_per_country = args.n_records // len(COUNTRIES)
|
| 333 |
+
remainder = args.n_records - n_per_country * len(COUNTRIES)
|
| 334 |
+
df = generate_dataset(scen, n_per_country=n_per_country)
|
| 335 |
+
# Add extra records to first country to hit exact count
|
| 336 |
+
if remainder > 0:
|
| 337 |
+
rng = np.random.default_rng(RNG_SEED + 99)
|
| 338 |
+
extra = generate_country_scenario(
|
| 339 |
+
list(COUNTRIES.keys())[0],
|
| 340 |
+
COUNTRIES[list(COUNTRIES.keys())[0]],
|
| 341 |
+
scen, SCENARIOS[scen], remainder, rng
|
| 342 |
+
)
|
| 343 |
+
df = pd.concat([df, extra], ignore_index=True)
|
| 344 |
+
df = df.sample(frac=1, random_state=RNG_SEED).reset_index(drop=True)
|
| 345 |
+
|
| 346 |
+
out_path = os.path.join(args.output_dir, f"{scen}.csv")
|
| 347 |
+
df.to_csv(out_path, index=False)
|
| 348 |
+
print(f"Generated {len(df)} records → {out_path}")
|
| 349 |
+
|
| 350 |
+
|
| 351 |
+
if __name__ == "__main__":
|
| 352 |
+
main()
|
plots/diagnostic_panels.png
ADDED
|
Git LFS Details
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
numpy>=1.24
|
| 2 |
+
pandas>=2.0
|
| 3 |
+
scipy>=1.10
|
| 4 |
+
matplotlib>=3.7
|
validate_dataset.py
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Validate African Anti-Corruption Enforcement dataset.
|
| 4 |
+
|
| 5 |
+
Runs plausibility checks and produces 8-panel diagnostic plots.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import os
|
| 9 |
+
import sys
|
| 10 |
+
import argparse
|
| 11 |
+
import numpy as np
|
| 12 |
+
import pandas as pd
|
| 13 |
+
import matplotlib
|
| 14 |
+
matplotlib.use("Agg")
|
| 15 |
+
import matplotlib.pyplot as plt
|
| 16 |
+
|
| 17 |
+
DATA_DIR = "data"
|
| 18 |
+
PLOT_DIR = "plots"
|
| 19 |
+
|
| 20 |
+
SCENARIOS = ["baseline", "strengthened_enforcement", "weakened_accountability"]
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def load_data(data_dir):
|
| 24 |
+
frames = {}
|
| 25 |
+
for scen in SCENARIOS:
|
| 26 |
+
path = os.path.join(data_dir, f"{scen}.csv")
|
| 27 |
+
if not os.path.exists(path):
|
| 28 |
+
print(f"WARNING: {path} not found, skipping")
|
| 29 |
+
continue
|
| 30 |
+
frames[scen] = pd.read_csv(path)
|
| 31 |
+
return frames
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
# ── Plausibility checks ─────────────────────────────────────────────
|
| 35 |
+
|
| 36 |
+
def run_checks(frames):
|
| 37 |
+
issues = []
|
| 38 |
+
for scen, df in frames.items():
|
| 39 |
+
n = len(df)
|
| 40 |
+
print(f"\n{'='*60}")
|
| 41 |
+
print(f"Scenario: {scen} ({n} records)")
|
| 42 |
+
print(f"{'='*60}")
|
| 43 |
+
|
| 44 |
+
# 1. Record count
|
| 45 |
+
assert n == 10000, f"Expected 10000 records, got {n}"
|
| 46 |
+
print(f" [OK] Record count: {n}")
|
| 47 |
+
|
| 48 |
+
# 2. Country coverage
|
| 49 |
+
countries = df["country"].nunique()
|
| 50 |
+
assert countries == 12, f"Expected 12 countries, got {countries}"
|
| 51 |
+
print(f" [OK] Country coverage: {countries}")
|
| 52 |
+
|
| 53 |
+
# 3. CPI range
|
| 54 |
+
cpi_ok = df["corruption_perception_index"].between(0, 100).all()
|
| 55 |
+
print(f" [{'OK' if cpi_ok else 'FAIL'}] CPI in [0,100]: "
|
| 56 |
+
f"{df['corruption_perception_index'].min():.1f} – "
|
| 57 |
+
f"{df['corruption_perception_index'].max():.1f}")
|
| 58 |
+
if not cpi_ok:
|
| 59 |
+
issues.append(f"{scen}: CPI out of range")
|
| 60 |
+
|
| 61 |
+
# 4. Rates in [0, 1]
|
| 62 |
+
for col in ["prosecution_rate", "conviction_rate", "asset_recovery_rate"]:
|
| 63 |
+
r_ok = df[col].between(0, 1).all()
|
| 64 |
+
print(f" [{'OK' if r_ok else 'FAIL'}] {col} in [0,1]: "
|
| 65 |
+
f"{df[col].min():.4f} – {df[col].max():.4f}")
|
| 66 |
+
if not r_ok:
|
| 67 |
+
issues.append(f"{scen}: {col} out of range")
|
| 68 |
+
|
| 69 |
+
# 5. Scores in [0, 100]
|
| 70 |
+
for col in ["whistleblower_protection_score", "agency_independence_score",
|
| 71 |
+
"enforcement_effectiveness_score"]:
|
| 72 |
+
s_ok = df[col].between(0, 100).all()
|
| 73 |
+
print(f" [{'OK' if s_ok else 'FAIL'}] {col} in [0,100]: "
|
| 74 |
+
f"{df[col].min():.1f} – {df[col].max():.1f}")
|
| 75 |
+
if not s_ok:
|
| 76 |
+
issues.append(f"{scen}: {col} out of range")
|
| 77 |
+
|
| 78 |
+
# 6. Monotonicity: prosecuted <= investigated
|
| 79 |
+
mono_ok = (df["cases_prosecuted"] <= df["cases_investigated"]).all()
|
| 80 |
+
print(f" [{'OK' if mono_ok else 'FAIL'}] cases_prosecuted <= cases_investigated")
|
| 81 |
+
if not mono_ok:
|
| 82 |
+
issues.append(f"{scen}: prosecution > investigation")
|
| 83 |
+
|
| 84 |
+
# 7. convictions <= cases_prosecuted
|
| 85 |
+
conv_ok = (df["convictions"] <= df["cases_prosecuted"]).all()
|
| 86 |
+
print(f" [{'OK' if conv_ok else 'FAIL'}] convictions <= cases_prosecuted")
|
| 87 |
+
if not conv_ok:
|
| 88 |
+
issues.append(f"{scen}: convictions > prosecuted")
|
| 89 |
+
|
| 90 |
+
# 8. Enforcement class consistency
|
| 91 |
+
class_ok = set(df["enforcement_class"].unique()) <= {"strong", "moderate", "weak"}
|
| 92 |
+
print(f" [{'OK' if class_ok else 'FAIL'}] enforcement_class values valid")
|
| 93 |
+
|
| 94 |
+
# 9. SSA-typical prosecution rate (<60% for most)
|
| 95 |
+
median_prosec = df["prosecution_rate"].median()
|
| 96 |
+
print(f" [INFO] Median prosecution rate: {median_prosec:.3f}")
|
| 97 |
+
|
| 98 |
+
# 10. SSA-typical asset recovery (<30%)
|
| 99 |
+
median_asset = df["asset_recovery_rate"].median()
|
| 100 |
+
print(f" [INFO] Median asset recovery rate: {median_asset:.3f}")
|
| 101 |
+
|
| 102 |
+
# 11. Summary stats by country
|
| 103 |
+
print(f"\n Country-level median CPI:")
|
| 104 |
+
for c, g in df.groupby("country"):
|
| 105 |
+
print(f" {c:15s} CPI={g['corruption_perception_index'].median():5.1f} "
|
| 106 |
+
f"prosec_rate={g['prosecution_rate'].median():.3f} "
|
| 107 |
+
f"conv_rate={g['conviction_rate'].median():.3f}")
|
| 108 |
+
|
| 109 |
+
if issues:
|
| 110 |
+
print(f"\n{'!'*60}")
|
| 111 |
+
print(f"ISSUES FOUND ({len(issues)}):")
|
| 112 |
+
for iss in issues:
|
| 113 |
+
print(f" - {iss}")
|
| 114 |
+
else:
|
| 115 |
+
print(f"\n{'='*60}")
|
| 116 |
+
print("ALL CHECKS PASSED")
|
| 117 |
+
return issues
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
# ── Diagnostic plots ────────────────────────────────────────────────
|
| 121 |
+
|
| 122 |
+
def make_plots(frames, plot_dir):
|
| 123 |
+
os.makedirs(plot_dir, exist_ok=True)
|
| 124 |
+
fig, axes = plt.subplots(2, 4, figsize=(24, 12))
|
| 125 |
+
fig.suptitle("African Anti-Corruption Enforcement – Diagnostic Plots",
|
| 126 |
+
fontsize=16, fontweight="bold", y=1.01)
|
| 127 |
+
|
| 128 |
+
palette = {"baseline": "#2166ac",
|
| 129 |
+
"strengthened_enforcement": "#1a9641",
|
| 130 |
+
"weakened_accountability": "#d73027"}
|
| 131 |
+
|
| 132 |
+
# ── Panel 1: CPI distribution by scenario ──
|
| 133 |
+
ax = axes[0, 0]
|
| 134 |
+
for scen, df in frames.items():
|
| 135 |
+
ax.hist(df["corruption_perception_index"], bins=40, alpha=0.5,
|
| 136 |
+
label=scen.replace("_", " "), color=palette[scen], density=True)
|
| 137 |
+
ax.set_xlabel("Corruption Perception Index")
|
| 138 |
+
ax.set_ylabel("Density")
|
| 139 |
+
ax.set_title("(a) CPI Distribution")
|
| 140 |
+
ax.legend(fontsize=7)
|
| 141 |
+
|
| 142 |
+
# ── Panel 2: Prosecution rate by country ──
|
| 143 |
+
ax = axes[0, 1]
|
| 144 |
+
country_order = sorted(frames["baseline"]["country"].unique())
|
| 145 |
+
data_baseline = [frames["baseline"].loc[frames["baseline"]["country"] == c,
|
| 146 |
+
"prosecution_rate"].values for c in country_order]
|
| 147 |
+
bp = ax.boxplot(data_baseline, labels=[c[:6] for c in country_order],
|
| 148 |
+
patch_artist=True, showfliers=False)
|
| 149 |
+
for patch in bp["boxes"]:
|
| 150 |
+
patch.set_facecolor("#abd9e9")
|
| 151 |
+
ax.set_ylabel("Prosecution Rate")
|
| 152 |
+
ax.set_title("(b) Prosecution Rate (Baseline)")
|
| 153 |
+
ax.tick_params(axis="x", rotation=45)
|
| 154 |
+
|
| 155 |
+
# ── Panel 3: Conviction rate by scenario ──
|
| 156 |
+
ax = axes[0, 2]
|
| 157 |
+
conv_data = []
|
| 158 |
+
labels = []
|
| 159 |
+
for scen in SCENARIOS:
|
| 160 |
+
if scen in frames:
|
| 161 |
+
conv_data.append(frames[scen]["conviction_rate"].values)
|
| 162 |
+
labels.append(scen.replace("_", "\n"))
|
| 163 |
+
bp2 = ax.boxplot(conv_data, labels=labels, patch_artist=True, showfliers=False)
|
| 164 |
+
colors = [palette[s] for s in SCENARIOS if s in frames]
|
| 165 |
+
for patch, color in zip(bp2["boxes"], colors):
|
| 166 |
+
patch.set_facecolor(color)
|
| 167 |
+
patch.set_alpha(0.6)
|
| 168 |
+
ax.set_ylabel("Conviction Rate")
|
| 169 |
+
ax.set_title("(c) Conviction Rate by Scenario")
|
| 170 |
+
|
| 171 |
+
# ── Panel 4: Asset recovery vs CPI ──
|
| 172 |
+
ax = axes[0, 3]
|
| 173 |
+
for scen, df in frames.items():
|
| 174 |
+
sample = df.sample(min(2000, len(df)), random_state=42)
|
| 175 |
+
ax.scatter(sample["corruption_perception_index"],
|
| 176 |
+
sample["asset_recovery_rate"] * 100,
|
| 177 |
+
alpha=0.15, s=8, color=palette[scen], label=scen.replace("_", " "))
|
| 178 |
+
ax.set_xlabel("CPI")
|
| 179 |
+
ax.set_ylabel("Asset Recovery Rate (%)")
|
| 180 |
+
ax.set_title("(d) Asset Recovery vs CPI")
|
| 181 |
+
ax.legend(fontsize=7)
|
| 182 |
+
|
| 183 |
+
# ── Panel 5: Enforcement effectiveness by country ──
|
| 184 |
+
ax = axes[1, 0]
|
| 185 |
+
means = frames["baseline"].groupby("country")["enforcement_effectiveness_score"].mean()
|
| 186 |
+
means = means.sort_values()
|
| 187 |
+
bars = ax.barh([c[:10] for c in means.index], means.values, color="#4393c3")
|
| 188 |
+
ax.set_xlabel("Mean Enforcement Effectiveness Score")
|
| 189 |
+
ax.set_title("(e) Enforcement Effectiveness (Baseline)")
|
| 190 |
+
|
| 191 |
+
# ── Panel 6: Whistleblower reports vs protection score ──
|
| 192 |
+
ax = axes[1, 1]
|
| 193 |
+
for scen, df in frames.items():
|
| 194 |
+
sample = df.sample(min(2000, len(df)), random_state=42)
|
| 195 |
+
ax.scatter(sample["whistleblower_protection_score"],
|
| 196 |
+
sample["whistleblower_reports"],
|
| 197 |
+
alpha=0.12, s=8, color=palette[scen])
|
| 198 |
+
ax.set_xlabel("Whistleblower Protection Score")
|
| 199 |
+
ax.set_ylabel("Whistleblower Reports")
|
| 200 |
+
ax.set_title("(f) WB Reports vs Protection")
|
| 201 |
+
|
| 202 |
+
# ── Panel 7: Prosecution pipeline (log scale) ──
|
| 203 |
+
ax = axes[1, 2]
|
| 204 |
+
for scen, df in frames.items():
|
| 205 |
+
med = df[["cases_investigated", "cases_prosecuted", "convictions"]].median()
|
| 206 |
+
ax.plot(["Investigated", "Prosecuted", "Convicted"],
|
| 207 |
+
med.values, marker="o", linewidth=2,
|
| 208 |
+
color=palette[scen], label=scen.replace("_", " "))
|
| 209 |
+
ax.set_ylabel("Median Cases (log)")
|
| 210 |
+
ax.set_yscale("log")
|
| 211 |
+
ax.set_title("(g) Prosecution Pipeline")
|
| 212 |
+
ax.legend(fontsize=7)
|
| 213 |
+
|
| 214 |
+
# ── Panel 8: Agency independence vs prosecution rate ──
|
| 215 |
+
ax = axes[1, 3]
|
| 216 |
+
for scen, df in frames.items():
|
| 217 |
+
sample = df.sample(min(2000, len(df)), random_state=42)
|
| 218 |
+
ax.scatter(sample["agency_independence_score"],
|
| 219 |
+
sample["prosecution_rate"] * 100,
|
| 220 |
+
alpha=0.12, s=8, color=palette[scen])
|
| 221 |
+
ax.set_xlabel("Agency Independence Score")
|
| 222 |
+
ax.set_ylabel("Prosecution Rate (%)")
|
| 223 |
+
ax.set_title("(h) Agency Independence vs Prosecution")
|
| 224 |
+
|
| 225 |
+
plt.tight_layout()
|
| 226 |
+
out_path = os.path.join(plot_dir, "diagnostic_panels.png")
|
| 227 |
+
fig.savefig(out_path, dpi=150, bbox_inches="tight")
|
| 228 |
+
plt.close(fig)
|
| 229 |
+
print(f"\nDiagnostic plots saved → {out_path}")
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
def main():
|
| 233 |
+
parser = argparse.ArgumentParser()
|
| 234 |
+
parser.add_argument("--data-dir", default=DATA_DIR)
|
| 235 |
+
parser.add_argument("--plot-dir", default=PLOT_DIR)
|
| 236 |
+
args = parser.parse_args()
|
| 237 |
+
|
| 238 |
+
frames = load_data(args.data_dir)
|
| 239 |
+
if not frames:
|
| 240 |
+
print("No data files found. Run generate_dataset.py first.")
|
| 241 |
+
sys.exit(1)
|
| 242 |
+
|
| 243 |
+
issues = run_checks(frames)
|
| 244 |
+
make_plots(frames, args.plot_dir)
|
| 245 |
+
|
| 246 |
+
if issues:
|
| 247 |
+
sys.exit(1)
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
if __name__ == "__main__":
|
| 251 |
+
main()
|