Kossisoroyce's picture
Upload folder using huggingface_hub
c562dfd verified
"""Generate synthetic e-waste recycling & occupational health dataset for SSA.
Research-based parameterization:
- Agbogbloshie, Ghana = world's largest informal e-waste recycling site;
Ghana imports ~215,000 tonnes secondhand electronics/yr (Pure Earth).
- E-waste manually dismantled by burning plastic/insulation to extract Cu,
Au; releases Pb, Cd, Cr, Hg, PAHs, dioxins, BFRs (PMC10815197).
- Biomonitoring: 75 Agbogbloshie workers vs 40 controls showed elevated
blood Pb, Cd, Cr, Ni, Hg (PubMed 27858271; PMC8287752).
- Children near e-waste sites: elevated BLL, DNA damage (PMC8392572).
- Respiratory symptoms & reduced lung function in burning workers
(PMC7084368).
- No PPE or environmental protection in informal recycling
(ScienceDirect 2024).
- Most SSA countries lack e-waste legislation; enforcement weak where
laws exist (ScienceDirect 2025 review).
- E-waste ranked Top 10 toxic threats globally (Pure Earth 2013).
"""
from __future__ import annotations
from pathlib import Path
import numpy as np
import pandas as pd
SEED = 42
N_PER_SCENARIO = 10_000
YEAR_RANGE = np.arange(2010, 2025)
YEAR_WEIGHTS = np.linspace(0.85, 1.3, len(YEAR_RANGE))
YEAR_WEIGHTS = YEAR_WEIGHTS / YEAR_WEIGHTS.sum()
SCENARIOS = {
# Agbogbloshie-type mega-site
"mega_site_west_africa": {
"setting_probs": {"urban_dumpsite": 0.50, "peri_urban": 0.30, "urban_market": 0.20},
"role_probs": {"burner": 0.25, "dismantler": 0.25, "collector": 0.15,
"community_resident": 0.20, "child_worker": 0.15},
# Blood Pb elevated: workers ~15-25 µg/dL (Agbogbloshie studies)
"blood_pb_gm_worker": 18.0, "blood_pb_gsd": 2.0,
"blood_pb_gm_community": 6.5,
"blood_cd_gm_worker": 1.5, # µg/L
"blood_cd_gm_community": 0.5,
"urine_cr_gm_worker": 3.0, # µg/L
"ppe_use_pct": 0.05,
"respiratory_symptoms_burner": 0.55,
"skin_symptoms_pct": 0.30,
"ewaste_volume_tonnes_yr": 215000,
},
# Medium informal site (Lagos, Nairobi type)
"medium_site_urban": {
"setting_probs": {"urban_market": 0.45, "peri_urban": 0.35, "urban_dumpsite": 0.20},
"role_probs": {"burner": 0.20, "dismantler": 0.30, "collector": 0.15,
"community_resident": 0.25, "child_worker": 0.10},
"blood_pb_gm_worker": 12.0, "blood_pb_gsd": 1.9,
"blood_pb_gm_community": 5.0,
"blood_cd_gm_worker": 1.0,
"blood_cd_gm_community": 0.4,
"urine_cr_gm_worker": 2.0,
"ppe_use_pct": 0.10,
"respiratory_symptoms_burner": 0.45,
"skin_symptoms_pct": 0.22,
"ewaste_volume_tonnes_yr": 50000,
},
# Small dispersed sites (smaller cities)
"small_dispersed_sites": {
"setting_probs": {"peri_urban": 0.45, "urban_market": 0.30, "rural": 0.25},
"role_probs": {"burner": 0.15, "dismantler": 0.30, "collector": 0.20,
"community_resident": 0.25, "child_worker": 0.10},
"blood_pb_gm_worker": 8.0, "blood_pb_gsd": 1.8,
"blood_pb_gm_community": 4.0,
"blood_cd_gm_worker": 0.7,
"blood_cd_gm_community": 0.3,
"urine_cr_gm_worker": 1.5,
"ppe_use_pct": 0.08,
"respiratory_symptoms_burner": 0.35,
"skin_symptoms_pct": 0.18,
"ewaste_volume_tonnes_yr": 10000,
},
}
SCENARIO_FILES = {
"mega_site_west_africa": "ewaste_mega_site.csv",
"medium_site_urban": "ewaste_medium_urban.csv",
"small_dispersed_sites": "ewaste_small_dispersed.csv",
}
EWASTE_TYPES = {"computers_monitors": 0.25, "mobile_phones": 0.20, "cables_wiring": 0.20,
"appliances": 0.15, "batteries": 0.10, "mixed_other": 0.10}
PROCESSING_METHODS = {"open_burning": 0.35, "manual_dismantling": 0.30, "acid_bath": 0.10,
"hammer_chisel": 0.15, "sorting_only": 0.10}
def _choice(rng, prob_map):
keys = list(prob_map.keys())
weights = np.array(list(prob_map.values()), dtype=float)
weights = weights / weights.sum()
return rng.choice(keys, p=weights)
def _simulate_scenario(name, params, seed):
rng = np.random.default_rng(seed)
records = []
for idx in range(N_PER_SCENARIO):
year = int(rng.choice(YEAR_RANGE, p=YEAR_WEIGHTS))
setting = _choice(rng, params["setting_probs"])
age = int(np.clip(rng.normal(28, 12), 8, 60))
sex = rng.choice(["male", "female"], p=[0.72, 0.28])
role = _choice(rng, params["role_probs"])
is_worker = int(role in ("burner", "dismantler", "collector"))
is_child = int(age < 18)
years_exposure = int(np.clip(rng.normal(5, 3), 0, 25)) if is_worker else int(np.clip(rng.normal(3, 2), 0, 15))
ewaste_type = _choice(rng, EWASTE_TYPES)
processing_method = _choice(rng, PROCESSING_METHODS) if is_worker else "none"
is_burner = int(role == "burner" or processing_method == "open_burning")
ppe_use = int(is_worker and rng.random() < params["ppe_use_pct"])
gloves = int(ppe_use and rng.random() < 0.60)
mask = int(ppe_use and rng.random() < 0.30)
hours_per_day = float(np.clip(rng.normal(8, 2), 2, 14)) if is_worker else 0
# Biomarkers (PubMed 27858271; PMC8287752)
if is_worker:
blood_pb = float(np.clip(
rng.lognormal(np.log(params["blood_pb_gm_worker"]), np.log(params["blood_pb_gsd"])),
1, 100,
))
blood_cd = float(np.clip(
rng.lognormal(np.log(params["blood_cd_gm_worker"]), 0.7), 0.1, 20,
))
urine_cr = float(np.clip(
rng.lognormal(np.log(params["urine_cr_gm_worker"]), 0.6), 0.1, 30,
))
else:
blood_pb = float(np.clip(
rng.lognormal(np.log(params["blood_pb_gm_community"]), np.log(1.7)),
0.5, 50,
))
blood_cd = float(np.clip(
rng.lognormal(np.log(params["blood_cd_gm_community"]), 0.6), 0.05, 10,
))
urine_cr = float(np.clip(
rng.lognormal(np.log(max(params["urine_cr_gm_worker"] * 0.3, 0.3)), 0.5), 0.05, 15,
))
if ppe_use:
blood_pb *= 0.8
blood_cd *= 0.85
elevated_pb = int(blood_pb >= 10)
elevated_cd = int(blood_cd >= 1.0)
# Health outcomes
# Respiratory (PMC7084368: burning workers high risk)
resp_risk = params["respiratory_symptoms_burner"] if is_burner else 0.10
cough_chronic = int(rng.random() < resp_risk * 0.8)
wheeze = int(rng.random() < resp_risk * 0.5)
dyspnoea = int(rng.random() < resp_risk * 0.4)
reduced_fev1 = int(is_burner and rng.random() < 0.25)
any_respiratory = int(cough_chronic or wheeze or dyspnoea or reduced_fev1)
# Skin/dermal (PMC10815197)
skin_rash = int(rng.random() < params["skin_symptoms_pct"])
burns_injury = int(is_burner and rng.random() < 0.15)
eye_irritation = int(is_burner and rng.random() < 0.30)
# Neurological (lead-related)
headache = int(rng.random() < np.clip(0.10 + blood_pb * 0.005, 0, 0.5))
fatigue = int(rng.random() < np.clip(0.15 + blood_pb * 0.004, 0, 0.5))
child_developmental = int(is_child and blood_pb > 5 and rng.random() < 0.20)
# Kidney (Cd-related)
proteinuria = int(blood_cd > 1.0 and rng.random() < 0.15)
# DNA damage (PMC8392572)
dna_damage_risk = int(rng.random() < np.clip(0.05 + years_exposure * 0.01 + is_burner * 0.10, 0, 0.4))
# Legislation & formalization
ewaste_legislation_exists = int(rng.random() < 0.25)
formal_recycler = int(is_worker and rng.random() < 0.05)
health_screening_access = int(rng.random() < 0.08)
record = {
"record_id": f"{name[:3].upper()}-{idx:05d}",
"scenario": name,
"year": year,
"setting": setting,
"age": age,
"sex": sex,
"role": role,
"is_worker": is_worker,
"is_child": is_child,
"years_exposure": years_exposure,
"ewaste_type": ewaste_type,
"processing_method": processing_method,
"is_burner": is_burner,
"ppe_use": ppe_use,
"gloves": gloves,
"mask": mask,
"hours_per_day": round(hours_per_day, 1),
"blood_pb_ugdL": round(blood_pb, 1),
"blood_cd_ugL": round(blood_cd, 2),
"urine_cr_ugL": round(urine_cr, 2),
"elevated_pb": elevated_pb,
"elevated_cd": elevated_cd,
"cough_chronic": cough_chronic,
"wheeze": wheeze,
"dyspnoea": dyspnoea,
"reduced_fev1": reduced_fev1,
"any_respiratory": any_respiratory,
"skin_rash": skin_rash,
"burns_injury": burns_injury,
"eye_irritation": eye_irritation,
"headache": headache,
"fatigue": fatigue,
"child_developmental": child_developmental,
"proteinuria": proteinuria,
"dna_damage_risk": dna_damage_risk,
"ewaste_legislation": ewaste_legislation_exists,
"formal_recycler": formal_recycler,
"health_screening_access": health_screening_access,
}
records.append(record)
return pd.DataFrame(records)
def main():
output_dir = Path("data")
output_dir.mkdir(parents=True, exist_ok=True)
for idx, (name, params) in enumerate(SCENARIOS.items()):
df = _simulate_scenario(name, params, SEED + idx * 211)
df.to_csv(output_dir / SCENARIO_FILES[name], index=False)
print(f"Saved {name} -> {SCENARIO_FILES[name]}")
if __name__ == "__main__":
main()