Datasets:
Upload folder using huggingface_hub
Browse files- README.md +17 -0
- generate_dataset.py +126 -0
- poverty_headcount_high_burden.csv +0 -0
- poverty_headcount_low_burden.csv +0 -0
- poverty_headcount_moderate.csv +0 -0
README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- tabular-classification
|
| 5 |
+
- tabular-regression
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
tags:
|
| 9 |
+
- poverty
|
| 10 |
+
- social-protection
|
| 11 |
+
- africa
|
| 12 |
+
- synthetic-data
|
| 13 |
+
- sub-saharan-africa
|
| 14 |
+
- poverty-headcount
|
| 15 |
+
size_categories:
|
| 16 |
+
- 10K<n<100K
|
| 17 |
+
---
|
generate_dataset.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Poverty Headcount Africa Dataset Generator
|
| 3 |
+
|
| 4 |
+
Parameter Evidence Table:
|
| 5 |
+
| Parameter | Source | Value | Notes |
|
| 6 |
+
|-----------|--------|-------|-------|
|
| 7 |
+
| $2.15/day poverty line | World Bank | $2.15 | Extreme poverty threshold |
|
| 8 |
+
| $3.00/day | World Bank 2024 | 46% of SSA | Current poverty rate |
|
| 9 |
+
| $3.65/day | World Bank | - | Working poverty threshold |
|
| 10 |
+
| $6.85/day | World Bank | - | Upper middle-income threshold |
|
| 11 |
+
|
| 12 |
+
Countries: 15 African nations
|
| 13 |
+
Years: 2018-2025
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
import numpy as np
|
| 17 |
+
import pandas as pd
|
| 18 |
+
from pathlib import Path
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
COUNTRIES = [
|
| 22 |
+
"Nigeria", "Ethiopia", "Tanzania", "Kenya", "Uganda",
|
| 23 |
+
"Mozambique", "Ghana", "Cote d'Ivoire", "Cameroon", "Senegal",
|
| 24 |
+
"Zambia", "Malawi", "Rwanda", "Burkina Faso", "Mali"
|
| 25 |
+
]
|
| 26 |
+
|
| 27 |
+
YEARS = list(range(2018, 2026))
|
| 28 |
+
|
| 29 |
+
BASE_RATES = {
|
| 30 |
+
"below_2.15": 0.28,
|
| 31 |
+
"below_3.00": 0.46,
|
| 32 |
+
"below_3.65": 0.58,
|
| 33 |
+
"below_6.85": 0.82
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
COUNTRY_ADJUSTMENTS = {
|
| 37 |
+
"Nigeria": {"below_2.15": 1.3, "below_3.00": 1.2, "below_3.65": 1.15, "below_6.85": 1.1},
|
| 38 |
+
"Ethiopia": {"below_2.15": 0.9, "below_3.00": 0.85, "below_3.65": 0.9, "below_6.85": 0.95},
|
| 39 |
+
"Tanzania": {"below_2.15": 0.85, "below_3.00": 0.9, "below_3.65": 0.9, "below_6.85": 0.9},
|
| 40 |
+
"Kenya": {"below_2.15": 0.6, "below_3.00": 0.55, "below_3.65": 0.5, "below_6.85": 0.45},
|
| 41 |
+
"Uganda": {"below_2.15": 0.75, "below_3.00": 0.8, "below_3.65": 0.85, "below_6.85": 0.9},
|
| 42 |
+
"Mozambique": {"below_2.15": 1.1, "below_3.00": 1.05, "below_3.65": 1.0, "below_6.85": 1.0},
|
| 43 |
+
"Ghana": {"below_2.15": 0.5, "below_3.00": 0.45, "below_3.65": 0.4, "below_6.85": 0.35},
|
| 44 |
+
"Cote d'Ivoire": {"below_2.15": 0.7, "below_3.00": 0.65, "below_3.65": 0.6, "below_6.85": 0.55},
|
| 45 |
+
"Cameroon": {"below_2.15": 0.8, "below_3.00": 0.75, "below_3.65": 0.7, "below_6.85": 0.65},
|
| 46 |
+
"Senegal": {"below_2.15": 0.65, "below_3.00": 0.6, "below_3.65": 0.55, "below_6.85": 0.5},
|
| 47 |
+
"Zambia": {"below_2.15": 0.9, "below_3.00": 0.85, "below_3.65": 0.8, "below_6.85": 0.75},
|
| 48 |
+
"Malawi": {"below_2.15": 1.0, "below_3.00": 0.95, "below_3.65": 0.9, "below_6.85": 0.85},
|
| 49 |
+
"Rwanda": {"below_2.15": 0.7, "below_3.00": 0.65, "below_3.65": 0.6, "below_6.85": 0.55},
|
| 50 |
+
"Burkina Faso": {"below_2.15": 0.85, "below_3.00": 0.8, "below_3.65": 0.75, "below_6.85": 0.7},
|
| 51 |
+
"Mali": {"below_2.15": 0.95, "below_3.00": 0.9, "below_3.65": 0.85, "below_6.85": 0.8}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def dag_sample(probabilities, n_samples, rng):
|
| 56 |
+
"""DAG-based sampling with probability weighting."""
|
| 57 |
+
indices = rng.choice(len(probabilities), size=n_samples, p=probabilities, replace=True)
|
| 58 |
+
unique, counts = np.unique(indices, return_counts=True)
|
| 59 |
+
return dict(zip(unique, counts))
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def generate_dataset(scenario: str, seed: int) -> pd.DataFrame:
|
| 63 |
+
"""Generate poverty headcount dataset for Africa."""
|
| 64 |
+
np.random.seed(seed)
|
| 65 |
+
rng = np.random.default_rng(seed)
|
| 66 |
+
|
| 67 |
+
scenario_config = {
|
| 68 |
+
"low_burden": {"n": 4000, "variance_scale": 0.8},
|
| 69 |
+
"moderate": {"n": 5000, "variance_scale": 1.0},
|
| 70 |
+
"high_burden": {"n": 6000, "variance_scale": 1.2}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
config = scenario_config[scenario]
|
| 74 |
+
n = config["n"]
|
| 75 |
+
scale = config["variance_scale"]
|
| 76 |
+
|
| 77 |
+
records = []
|
| 78 |
+
|
| 79 |
+
for year in YEARS:
|
| 80 |
+
year_factor = 1.0 - (year - 2018) * 0.015
|
| 81 |
+
|
| 82 |
+
for country in COUNTRIES:
|
| 83 |
+
adj = COUNTRY_ADJUSTMENTS[country]
|
| 84 |
+
|
| 85 |
+
for threshold in ["below_2.15", "below_3.00", "below_3.65", "below_6.85"]:
|
| 86 |
+
base_rate = BASE_RATES[threshold]
|
| 87 |
+
adjusted_rate = min(0.99, base_rate * adj[threshold] * year_factor * scale)
|
| 88 |
+
adjusted_rate = max(0.01, adjusted_rate)
|
| 89 |
+
|
| 90 |
+
n_country_year = n // (len(YEARS) * len(COUNTRIES))
|
| 91 |
+
poverty_count = int(n_country_year * adjusted_rate)
|
| 92 |
+
|
| 93 |
+
for _ in range(n_country_year):
|
| 94 |
+
records.append({
|
| 95 |
+
"country": country,
|
| 96 |
+
"year": year,
|
| 97 |
+
"poverty_line": threshold,
|
| 98 |
+
"headcount_ratio": adjusted_rate + rng.normal(0, 0.02 * scale),
|
| 99 |
+
"population_below": poverty_count * 1000,
|
| 100 |
+
"total_population": n_country_year * 1000
|
| 101 |
+
})
|
| 102 |
+
|
| 103 |
+
df = pd.DataFrame(records)
|
| 104 |
+
df["headcount_ratio"] = df["headcount_ratio"].clip(0, 1)
|
| 105 |
+
|
| 106 |
+
return df
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def main():
|
| 110 |
+
output_dir = Path(__file__).parent
|
| 111 |
+
output_dir.mkdir(parents=True, exist_ok=True)
|
| 112 |
+
|
| 113 |
+
scenarios = {
|
| 114 |
+
"low_burden": 42,
|
| 115 |
+
"moderate": 43,
|
| 116 |
+
"high_burden": 44
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
for scenario, seed in scenarios.items():
|
| 120 |
+
df = generate_dataset(scenario, seed)
|
| 121 |
+
df.to_csv(output_dir / f"poverty_headcount_{scenario}.csv", index=False)
|
| 122 |
+
print(f"Generated {scenario}: {len(df)} rows, seed={seed}")
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
if __name__ == "__main__":
|
| 126 |
+
main()
|
poverty_headcount_high_burden.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
poverty_headcount_low_burden.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
poverty_headcount_moderate.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|