Datasets:
Upload folder using huggingface_hub
Browse files- README.md +89 -0
- data/noise_megacity.csv +0 -0
- data/noise_periurban.csv +0 -0
- data/noise_secondary_city.csv +0 -0
- generate_dataset.py +180 -0
- requirements.txt +3 -0
- validate_dataset.py +92 -0
- validation_report.png +3 -0
README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- tabular-classification
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
tags:
|
| 8 |
+
- environmental-health
|
| 9 |
+
- noise-pollution
|
| 10 |
+
- urban-health
|
| 11 |
+
- hearing-loss
|
| 12 |
+
- cardiovascular
|
| 13 |
+
- synthetic
|
| 14 |
+
- sub-saharan-africa
|
| 15 |
+
pretty_name: Noise Pollution & Urban Health (SSA)
|
| 16 |
+
size_categories:
|
| 17 |
+
- 10K<n<100K
|
| 18 |
+
configs:
|
| 19 |
+
- config_name: megacity_traffic
|
| 20 |
+
data_files: data/noise_megacity.csv
|
| 21 |
+
default: true
|
| 22 |
+
- config_name: secondary_city_mixed
|
| 23 |
+
data_files: data/noise_secondary_city.csv
|
| 24 |
+
- config_name: periurban_emerging
|
| 25 |
+
data_files: data/noise_periurban.csv
|
| 26 |
+
---
|
| 27 |
+
|
| 28 |
+
# Noise Pollution & Urban Health in Sub-Saharan Africa
|
| 29 |
+
|
| 30 |
+
## Abstract
|
| 31 |
+
|
| 32 |
+
Synthetic dataset modelling environmental noise exposure and health outcomes across three urban settings in SSA. WHO identifies noise as a major environmental health risk causing hearing loss, cardiovascular disease, sleep disturbance, and cognitive impairment. Most African cities exceed WHO guidelines (53 dB Lden, 45 dB Lnight) from traffic, generators, industry, and entertainment.
|
| 33 |
+
|
| 34 |
+
### Scenarios
|
| 35 |
+
|
| 36 |
+
- **Megacity Traffic**: Lagos/Nairobi-type megacity with mean Lden ~72 dB.
|
| 37 |
+
- **Secondary City Mixed**: Medium cities with generators, entertainment; Lden ~65 dB.
|
| 38 |
+
- **Peri-Urban Emerging**: Growing peri-urban areas; Lden ~58 dB.
|
| 39 |
+
|
| 40 |
+
## Parameterization Evidence
|
| 41 |
+
|
| 42 |
+
| Parameter | Value | Source | Year |
|
| 43 |
+
| --- | --- | --- | --- |
|
| 44 |
+
| Noise causes CVD, mental health, sleep disturbance | Health effects | WHO | 2024 |
|
| 45 |
+
| WHO guidelines: 53 dB Lden, 45 dB Lnight | Standard | WHO Environmental Noise Guidelines | 2018 |
|
| 46 |
+
| Traffic noise quantified in South African cities | City data | Nature Scientific Reports | 2022 |
|
| 47 |
+
| Annoyance, stress, hearing loss from noise in Nigeria | SSA data | PMC11221953 | 2024 |
|
| 48 |
+
| Most developing countries lack noise legislation | Regulation gap | IntechOpen | 2022 |
|
| 49 |
+
|
| 50 |
+
## Validation
|
| 51 |
+
|
| 52 |
+

|
| 53 |
+
|
| 54 |
+
## Usage
|
| 55 |
+
|
| 56 |
+
```python
|
| 57 |
+
from datasets import load_dataset
|
| 58 |
+
ds = load_dataset("electricsheepafrica/noise-pollution-urban-health", "megacity_traffic")
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
## Limitations
|
| 62 |
+
|
| 63 |
+
- Synthetic data; not for clinical decision-making.
|
| 64 |
+
- Noise levels modelled as normal distribution; real urban noise varies by time of day.
|
| 65 |
+
- Does not capture occupational noise exposure in detail.
|
| 66 |
+
|
| 67 |
+
## References
|
| 68 |
+
|
| 69 |
+
1. WHO. Environmental noise guidelines for the European Region. 2018.
|
| 70 |
+
2. WHO. Updated disability weights for environmental noise. 2024.
|
| 71 |
+
3. Nature Scientific Reports. Traffic noise in South African cities. 2022.
|
| 72 |
+
4. PMC11221953. Noise levels and health perceptions in Nigeria. 2024.
|
| 73 |
+
5. IntechOpen. Environmental noise management in developing countries. 2022.
|
| 74 |
+
|
| 75 |
+
## Citation
|
| 76 |
+
|
| 77 |
+
```bibtex
|
| 78 |
+
@dataset{electricsheepafrica_noise_pollution_urban_health_2025,
|
| 79 |
+
title={Noise Pollution and Urban Health in Sub-Saharan Africa},
|
| 80 |
+
author={Electric Sheep Africa},
|
| 81 |
+
year={2025},
|
| 82 |
+
publisher={HuggingFace},
|
| 83 |
+
url={https://huggingface.co/datasets/electricsheepafrica/noise-pollution-urban-health}
|
| 84 |
+
}
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
## License
|
| 88 |
+
|
| 89 |
+
CC-BY-4.0
|
data/noise_megacity.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/noise_periurban.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/noise_secondary_city.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
generate_dataset.py
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generate synthetic noise pollution & urban health dataset for SSA.
|
| 2 |
+
|
| 3 |
+
Research-based parameterization:
|
| 4 |
+
- WHO (2024): Environmental noise causes cardiovascular, mental health,
|
| 5 |
+
sleep disturbance; updated disability weights for noise exposure.
|
| 6 |
+
- WHO guidelines: 53 dB Lden road traffic; 45 dB Lnight for sleep.
|
| 7 |
+
- Nature (2022): Traffic noise quantified in South African cities.
|
| 8 |
+
- PMC11221953: Nigerian noise levels and health perceptions - annoyance,
|
| 9 |
+
mental stress, sleep disturbance, hearing loss, cardiovascular effects.
|
| 10 |
+
- IntechOpen (2022): Noise policy challenges in developing countries;
|
| 11 |
+
most lack enforceable legislation.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
from __future__ import annotations
|
| 15 |
+
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
|
| 18 |
+
import numpy as np
|
| 19 |
+
import pandas as pd
|
| 20 |
+
|
| 21 |
+
SEED = 42
|
| 22 |
+
N_PER_SCENARIO = 10_000
|
| 23 |
+
|
| 24 |
+
YEAR_RANGE = np.arange(2010, 2025)
|
| 25 |
+
YEAR_WEIGHTS = np.linspace(0.85, 1.3, len(YEAR_RANGE))
|
| 26 |
+
YEAR_WEIGHTS = YEAR_WEIGHTS / YEAR_WEIGHTS.sum()
|
| 27 |
+
|
| 28 |
+
SCENARIOS = {
|
| 29 |
+
"megacity_traffic": {
|
| 30 |
+
"setting_probs": {"commercial_road": 0.35, "residential_road": 0.30,
|
| 31 |
+
"industrial": 0.15, "market": 0.20},
|
| 32 |
+
"noise_source_probs": {"road_traffic": 0.40, "generators": 0.20, "industry": 0.15,
|
| 33 |
+
"entertainment": 0.10, "construction": 0.10, "religious": 0.05},
|
| 34 |
+
"lden_mean": 72, "lden_sd": 10,
|
| 35 |
+
"lnight_mean": 58, "lnight_sd": 8,
|
| 36 |
+
"hearing_loss_prev": 0.12,
|
| 37 |
+
"hypertension_noise_pct": 0.08,
|
| 38 |
+
"sleep_disturbance_pct": 0.35,
|
| 39 |
+
"noise_regulation": 0.15,
|
| 40 |
+
},
|
| 41 |
+
"secondary_city_mixed": {
|
| 42 |
+
"setting_probs": {"commercial_road": 0.30, "residential": 0.35,
|
| 43 |
+
"market": 0.20, "industrial": 0.15},
|
| 44 |
+
"noise_source_probs": {"road_traffic": 0.30, "generators": 0.25, "entertainment": 0.15,
|
| 45 |
+
"religious": 0.10, "construction": 0.10, "industry": 0.10},
|
| 46 |
+
"lden_mean": 65, "lden_sd": 10,
|
| 47 |
+
"lnight_mean": 52, "lnight_sd": 8,
|
| 48 |
+
"hearing_loss_prev": 0.08,
|
| 49 |
+
"hypertension_noise_pct": 0.05,
|
| 50 |
+
"sleep_disturbance_pct": 0.25,
|
| 51 |
+
"noise_regulation": 0.08,
|
| 52 |
+
},
|
| 53 |
+
"periurban_emerging": {
|
| 54 |
+
"setting_probs": {"residential": 0.40, "market": 0.25,
|
| 55 |
+
"peri_urban_road": 0.20, "industrial_fringe": 0.15},
|
| 56 |
+
"noise_source_probs": {"road_traffic": 0.25, "generators": 0.20, "entertainment": 0.15,
|
| 57 |
+
"religious": 0.15, "agriculture": 0.10, "construction": 0.15},
|
| 58 |
+
"lden_mean": 58, "lden_sd": 10,
|
| 59 |
+
"lnight_mean": 45, "lnight_sd": 8,
|
| 60 |
+
"hearing_loss_prev": 0.05,
|
| 61 |
+
"hypertension_noise_pct": 0.03,
|
| 62 |
+
"sleep_disturbance_pct": 0.15,
|
| 63 |
+
"noise_regulation": 0.05,
|
| 64 |
+
},
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
SCENARIO_FILES = {
|
| 68 |
+
"megacity_traffic": "noise_megacity.csv",
|
| 69 |
+
"secondary_city_mixed": "noise_secondary_city.csv",
|
| 70 |
+
"periurban_emerging": "noise_periurban.csv",
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def _choice(rng, prob_map):
|
| 75 |
+
keys = list(prob_map.keys())
|
| 76 |
+
weights = np.array(list(prob_map.values()), dtype=float)
|
| 77 |
+
weights = weights / weights.sum()
|
| 78 |
+
return rng.choice(keys, p=weights)
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def _simulate_scenario(name, params, seed):
|
| 82 |
+
rng = np.random.default_rng(seed)
|
| 83 |
+
records = []
|
| 84 |
+
|
| 85 |
+
for idx in range(N_PER_SCENARIO):
|
| 86 |
+
year = int(rng.choice(YEAR_RANGE, p=YEAR_WEIGHTS))
|
| 87 |
+
setting = _choice(rng, params["setting_probs"])
|
| 88 |
+
age = int(np.clip(rng.normal(32, 15), 5, 75))
|
| 89 |
+
sex = rng.choice(["male", "female"], p=[0.50, 0.50])
|
| 90 |
+
is_child = int(age < 15)
|
| 91 |
+
occupation = rng.choice(["outdoor_worker", "indoor_worker", "student", "homemaker", "vendor"],
|
| 92 |
+
p=[0.25, 0.20, 0.20, 0.20, 0.15])
|
| 93 |
+
|
| 94 |
+
noise_source = _choice(rng, params["noise_source_probs"])
|
| 95 |
+
distance_to_source_m = float(np.clip(rng.exponential(50), 5, 500))
|
| 96 |
+
proximity_factor = max(0.5, 1.0 - distance_to_source_m / 200)
|
| 97 |
+
|
| 98 |
+
lden = float(np.clip(
|
| 99 |
+
rng.normal(params["lden_mean"] * proximity_factor, params["lden_sd"]), 35, 110))
|
| 100 |
+
lnight = float(np.clip(
|
| 101 |
+
rng.normal(params["lnight_mean"] * proximity_factor, params["lnight_sd"]), 25, 90))
|
| 102 |
+
|
| 103 |
+
exceeds_who_lden = int(lden > 53)
|
| 104 |
+
exceeds_who_lnight = int(lnight > 45)
|
| 105 |
+
exceeds_85db = int(lden > 85)
|
| 106 |
+
|
| 107 |
+
exposure_years = int(np.clip(rng.normal(8, 5), 0, 30))
|
| 108 |
+
daily_exposure_hours = float(np.clip(rng.normal(8, 3), 1, 16))
|
| 109 |
+
|
| 110 |
+
uses_hearing_protection = int(rng.random() < 0.05)
|
| 111 |
+
|
| 112 |
+
risk_mult = lden / 53
|
| 113 |
+
hearing_loss = int(rng.random() < np.clip(
|
| 114 |
+
params["hearing_loss_prev"] * risk_mult * (exposure_years / 10), 0, 0.35))
|
| 115 |
+
tinnitus = int(rng.random() < np.clip(0.05 + risk_mult * 0.04, 0, 0.25))
|
| 116 |
+
|
| 117 |
+
hypertension = int(age >= 25 and rng.random() < np.clip(
|
| 118 |
+
params["hypertension_noise_pct"] * risk_mult, 0, 0.20))
|
| 119 |
+
cardiovascular = int(age >= 35 and hypertension and rng.random() < 0.15)
|
| 120 |
+
|
| 121 |
+
sleep_disturbance = int(rng.random() < np.clip(
|
| 122 |
+
params["sleep_disturbance_pct"] * (lnight / 45), 0, 0.60))
|
| 123 |
+
annoyance = int(rng.random() < np.clip(0.20 + risk_mult * 0.15, 0, 0.70))
|
| 124 |
+
stress_anxiety = int(rng.random() < np.clip(0.10 + risk_mult * 0.08, 0, 0.35))
|
| 125 |
+
concentration_difficulty = int(rng.random() < np.clip(0.08 + risk_mult * 0.06, 0, 0.30))
|
| 126 |
+
|
| 127 |
+
child_learning = int(is_child and rng.random() < np.clip(risk_mult * 0.08, 0, 0.20))
|
| 128 |
+
|
| 129 |
+
noise_complaint = int(annoyance and rng.random() < 0.10)
|
| 130 |
+
noise_regulation = int(rng.random() < params["noise_regulation"])
|
| 131 |
+
noise_monitoring = int(rng.random() < 0.05)
|
| 132 |
+
|
| 133 |
+
record = {
|
| 134 |
+
"record_id": f"{name[:3].upper()}-{idx:05d}",
|
| 135 |
+
"scenario": name,
|
| 136 |
+
"year": year,
|
| 137 |
+
"setting": setting,
|
| 138 |
+
"age": age,
|
| 139 |
+
"sex": sex,
|
| 140 |
+
"is_child": is_child,
|
| 141 |
+
"occupation": occupation,
|
| 142 |
+
"noise_source": noise_source,
|
| 143 |
+
"distance_to_source_m": round(distance_to_source_m, 0),
|
| 144 |
+
"lden_db": round(lden, 1),
|
| 145 |
+
"lnight_db": round(lnight, 1),
|
| 146 |
+
"exceeds_who_lden_53": exceeds_who_lden,
|
| 147 |
+
"exceeds_who_lnight_45": exceeds_who_lnight,
|
| 148 |
+
"exceeds_85db": exceeds_85db,
|
| 149 |
+
"exposure_years": exposure_years,
|
| 150 |
+
"daily_exposure_hours": round(daily_exposure_hours, 1),
|
| 151 |
+
"uses_hearing_protection": uses_hearing_protection,
|
| 152 |
+
"hearing_loss": hearing_loss,
|
| 153 |
+
"tinnitus": tinnitus,
|
| 154 |
+
"hypertension": hypertension,
|
| 155 |
+
"cardiovascular": cardiovascular,
|
| 156 |
+
"sleep_disturbance": sleep_disturbance,
|
| 157 |
+
"annoyance": annoyance,
|
| 158 |
+
"stress_anxiety": stress_anxiety,
|
| 159 |
+
"concentration_difficulty": concentration_difficulty,
|
| 160 |
+
"child_learning": child_learning,
|
| 161 |
+
"noise_complaint": noise_complaint,
|
| 162 |
+
"noise_regulation": noise_regulation,
|
| 163 |
+
"noise_monitoring": noise_monitoring,
|
| 164 |
+
}
|
| 165 |
+
records.append(record)
|
| 166 |
+
|
| 167 |
+
return pd.DataFrame(records)
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
def main():
|
| 171 |
+
output_dir = Path("data")
|
| 172 |
+
output_dir.mkdir(parents=True, exist_ok=True)
|
| 173 |
+
for idx, (name, params) in enumerate(SCENARIOS.items()):
|
| 174 |
+
df = _simulate_scenario(name, params, SEED + idx * 211)
|
| 175 |
+
df.to_csv(output_dir / SCENARIO_FILES[name], index=False)
|
| 176 |
+
print(f"Saved {name} -> {SCENARIO_FILES[name]}")
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
if __name__ == "__main__":
|
| 180 |
+
main()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
numpy>=1.24
|
| 2 |
+
pandas>=2.0
|
| 3 |
+
matplotlib>=3.7
|
validate_dataset.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Validate synthetic noise pollution & urban health dataset."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
import matplotlib.pyplot as plt
|
| 8 |
+
import pandas as pd
|
| 9 |
+
|
| 10 |
+
SCENARIO_FILES = {
|
| 11 |
+
"megacity_traffic": "noise_megacity.csv",
|
| 12 |
+
"secondary_city_mixed": "noise_secondary_city.csv",
|
| 13 |
+
"periurban_emerging": "noise_periurban.csv",
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
COLORS = {"megacity_traffic": "#e6550d", "secondary_city_mixed": "#756bb1", "periurban_emerging": "#31a354"}
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def load_data() -> pd.DataFrame:
|
| 20 |
+
frames = []
|
| 21 |
+
for scenario, filename in SCENARIO_FILES.items():
|
| 22 |
+
df = pd.read_csv(Path("data") / filename)
|
| 23 |
+
frames.append(df)
|
| 24 |
+
return pd.concat(frames, ignore_index=True)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def plot_validation(df: pd.DataFrame, output_path: Path) -> None:
|
| 28 |
+
fig, axes = plt.subplots(4, 2, figsize=(14, 16))
|
| 29 |
+
axes = axes.flatten()
|
| 30 |
+
|
| 31 |
+
for s in SCENARIO_FILES:
|
| 32 |
+
subset = df[df["scenario"] == s]
|
| 33 |
+
axes[0].hist(subset["lden_db"], bins=40, alpha=0.5, color=COLORS[s], label=s)
|
| 34 |
+
axes[0].axvline(53, color="red", ls="--", lw=1, label="WHO 53 dB")
|
| 35 |
+
axes[0].set_title("Lden Noise Distribution (dB)")
|
| 36 |
+
axes[0].legend(fontsize=6)
|
| 37 |
+
|
| 38 |
+
exc_cols = ["exceeds_who_lden_53", "exceeds_who_lnight_45", "exceeds_85db"]
|
| 39 |
+
exc = df.groupby("scenario")[exc_cols].mean() * 100
|
| 40 |
+
exc.plot(kind="bar", ax=axes[1])
|
| 41 |
+
axes[1].set_title("WHO Guideline Exceedance (%)")
|
| 42 |
+
axes[1].legend(fontsize=7)
|
| 43 |
+
|
| 44 |
+
health_cols = ["hearing_loss", "tinnitus", "hypertension", "cardiovascular"]
|
| 45 |
+
health = df.groupby("scenario")[health_cols].mean() * 100
|
| 46 |
+
health.plot(kind="bar", ax=axes[2])
|
| 47 |
+
axes[2].set_title("Physical Health Outcomes (%)")
|
| 48 |
+
axes[2].legend(fontsize=7)
|
| 49 |
+
|
| 50 |
+
mental_cols = ["sleep_disturbance", "annoyance", "stress_anxiety", "concentration_difficulty"]
|
| 51 |
+
mental = df.groupby("scenario")[mental_cols].mean() * 100
|
| 52 |
+
mental.plot(kind="bar", ax=axes[3])
|
| 53 |
+
axes[3].set_title("Mental Health & Wellbeing (%)")
|
| 54 |
+
axes[3].legend(fontsize=6)
|
| 55 |
+
|
| 56 |
+
src = df.groupby(["scenario", "noise_source"]).size().groupby(level=0).apply(lambda s: s / s.sum())
|
| 57 |
+
src.unstack().plot(kind="bar", stacked=True, ax=axes[4])
|
| 58 |
+
axes[4].set_title("Noise Source Distribution")
|
| 59 |
+
axes[4].legend(fontsize=5)
|
| 60 |
+
|
| 61 |
+
for s in SCENARIO_FILES:
|
| 62 |
+
subset = df[df["scenario"] == s]
|
| 63 |
+
axes[5].scatter(subset["lden_db"], subset["hearing_loss"],
|
| 64 |
+
s=4, alpha=0.05, color=COLORS[s], label=s)
|
| 65 |
+
axes[5].set_title("Lden vs Hearing Loss")
|
| 66 |
+
axes[5].legend(fontsize=7)
|
| 67 |
+
|
| 68 |
+
reg_cols = ["noise_regulation", "noise_monitoring", "uses_hearing_protection", "noise_complaint"]
|
| 69 |
+
reg = df.groupby("scenario")[reg_cols].mean() * 100
|
| 70 |
+
reg.plot(kind="bar", ax=axes[6])
|
| 71 |
+
axes[6].set_title("Regulation & Protection (%)")
|
| 72 |
+
axes[6].legend(fontsize=6)
|
| 73 |
+
|
| 74 |
+
child = df[df["is_child"] == 1]
|
| 75 |
+
if len(child) > 0:
|
| 76 |
+
cl = child.groupby("scenario")["child_learning"].mean() * 100
|
| 77 |
+
cl.plot(kind="bar", ax=axes[7], color=[COLORS[s] for s in cl.index])
|
| 78 |
+
axes[7].set_title("Child Learning Impairment (%)")
|
| 79 |
+
|
| 80 |
+
plt.tight_layout()
|
| 81 |
+
fig.savefig(output_path, dpi=200)
|
| 82 |
+
plt.close(fig)
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def main() -> None:
|
| 86 |
+
df = load_data()
|
| 87 |
+
plot_validation(df, Path("validation_report.png"))
|
| 88 |
+
print("Saved validation_report.png")
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
if __name__ == "__main__":
|
| 92 |
+
main()
|
validation_report.png
ADDED
|
Git LFS Details
|