Datasets:
Upload folder using huggingface_hub
Browse files- README.md +74 -0
- data/falsified_covid.csv +0 -0
- data/falsified_devices.csv +0 -0
- data/falsified_diagnostics.csv +0 -0
- generate_dataset.py +187 -0
- requirements.txt +3 -0
- validate_dataset.py +89 -0
- validation_report.png +3 -0
README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- tabular-classification
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
tags:
|
| 8 |
+
- substandard-falsified-medicines
|
| 9 |
+
- medical-devices
|
| 10 |
+
- diagnostics
|
| 11 |
+
- RDT
|
| 12 |
+
- COVID-19
|
| 13 |
+
- falsified
|
| 14 |
+
- synthetic
|
| 15 |
+
- sub-saharan-africa
|
| 16 |
+
pretty_name: Falsified Medical Products & Devices (SSA)
|
| 17 |
+
size_categories:
|
| 18 |
+
- 10K<n<100K
|
| 19 |
+
configs:
|
| 20 |
+
- config_name: diagnostics_rdts
|
| 21 |
+
data_files: data/falsified_diagnostics.csv
|
| 22 |
+
default: true
|
| 23 |
+
- config_name: medical_devices_consumables
|
| 24 |
+
data_files: data/falsified_devices.csv
|
| 25 |
+
- config_name: covid_pandemic_products
|
| 26 |
+
data_files: data/falsified_covid.csv
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
# Falsified Medical Products & Devices in Sub-Saharan Africa
|
| 30 |
+
|
| 31 |
+
## Abstract
|
| 32 |
+
|
| 33 |
+
Synthetic dataset modelling falsified medical products including diagnostics, devices, and pandemic supplies across three product categories in SSA. SF medical products extend beyond medicines to RDTs, surgical supplies, PPE, and consumables; COVID-19 accelerated falsified PPE and test kits.
|
| 34 |
+
|
| 35 |
+
## Parameterization Evidence
|
| 36 |
+
|
| 37 |
+
| Parameter | Value | Source | Year |
|
| 38 |
+
| --- | --- | --- | --- |
|
| 39 |
+
| SF products include diagnostics, devices, PPE | Scope | WHO | 2023 |
|
| 40 |
+
| Falsified products trafficking increasing in Africa | Trend | PMC9461548 | 2022 |
|
| 41 |
+
| COVID-19 accelerated falsified PPE and test kits | Pandemic | WHO alerts | 2020-22 |
|
| 42 |
+
|
| 43 |
+
## Validation
|
| 44 |
+
|
| 45 |
+

|
| 46 |
+
|
| 47 |
+
## Usage
|
| 48 |
+
|
| 49 |
+
```python
|
| 50 |
+
from datasets import load_dataset
|
| 51 |
+
ds = load_dataset("electricsheepafrica/falsified-medical-products-devices", "diagnostics_rdts")
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
## References
|
| 55 |
+
|
| 56 |
+
1. WHO. Substandard and falsified medical products. 2023.
|
| 57 |
+
2. PMC9461548. Falsified medicines trafficking in Africa. 2022.
|
| 58 |
+
3. WHO Medical Product Alerts. COVID-19 related SF products. 2020-22.
|
| 59 |
+
|
| 60 |
+
## Citation
|
| 61 |
+
|
| 62 |
+
```bibtex
|
| 63 |
+
@dataset{electricsheepafrica_falsified_medical_products_devices_2025,
|
| 64 |
+
title={Falsified Medical Products and Devices in Sub-Saharan Africa},
|
| 65 |
+
author={Electric Sheep Africa},
|
| 66 |
+
year={2025},
|
| 67 |
+
publisher={HuggingFace},
|
| 68 |
+
url={https://huggingface.co/datasets/electricsheepafrica/falsified-medical-products-devices}
|
| 69 |
+
}
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
## License
|
| 73 |
+
|
| 74 |
+
CC-BY-4.0
|
data/falsified_covid.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/falsified_devices.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/falsified_diagnostics.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
generate_dataset.py
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generate synthetic falsified medical products & devices dataset for SSA.
|
| 2 |
+
|
| 3 |
+
Research-based parameterization:
|
| 4 |
+
- WHO: SF medical products include not only medicines but also
|
| 5 |
+
diagnostics, medical devices, PPE, and surgical supplies.
|
| 6 |
+
- PMC9461548: Falsified products trafficking in Africa; increasing
|
| 7 |
+
burden including devices, diagnostics, consumables.
|
| 8 |
+
- SSA context: Falsified RDTs, condoms, surgical gloves, syringes,
|
| 9 |
+
blood bags, and diagnostics detected; COVID-19 accelerated
|
| 10 |
+
falsified PPE and test kits.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
from __future__ import annotations
|
| 14 |
+
|
| 15 |
+
from pathlib import Path
|
| 16 |
+
|
| 17 |
+
import numpy as np
|
| 18 |
+
import pandas as pd
|
| 19 |
+
|
| 20 |
+
SEED = 42
|
| 21 |
+
N_PER_SCENARIO = 10_000
|
| 22 |
+
|
| 23 |
+
YEAR_RANGE = np.arange(2010, 2025)
|
| 24 |
+
YEAR_WEIGHTS = np.linspace(0.85, 1.3, len(YEAR_RANGE))
|
| 25 |
+
YEAR_WEIGHTS = YEAR_WEIGHTS / YEAR_WEIGHTS.sum()
|
| 26 |
+
|
| 27 |
+
SCENARIOS = {
|
| 28 |
+
"diagnostics_rdts": {
|
| 29 |
+
"setting_probs": {"health_facility": 0.30, "pharmacy": 0.25,
|
| 30 |
+
"community_testing": 0.25, "informal_market": 0.20},
|
| 31 |
+
"product_probs": {"malaria_RDT": 0.25, "HIV_RDT": 0.20,
|
| 32 |
+
"pregnancy_test": 0.15, "COVID_test": 0.15,
|
| 33 |
+
"blood_glucose_strip": 0.10, "hepatitis_test": 0.08,
|
| 34 |
+
"other_diagnostic": 0.07},
|
| 35 |
+
"sf_prevalence": 0.12,
|
| 36 |
+
"false_negative_risk": 0.15,
|
| 37 |
+
"false_positive_risk": 0.05,
|
| 38 |
+
"who_pq_pct": 0.30,
|
| 39 |
+
"nmra_registered_pct": 0.50,
|
| 40 |
+
},
|
| 41 |
+
"medical_devices_consumables": {
|
| 42 |
+
"setting_probs": {"hospital": 0.30, "health_centre": 0.25,
|
| 43 |
+
"private_clinic": 0.20, "market_vendor": 0.25},
|
| 44 |
+
"product_probs": {"surgical_gloves": 0.15, "syringes_needles": 0.15,
|
| 45 |
+
"condoms": 0.12, "sutures": 0.10,
|
| 46 |
+
"blood_bags": 0.08, "IV_giving_sets": 0.10,
|
| 47 |
+
"catheters": 0.08, "surgical_masks": 0.10,
|
| 48 |
+
"PPE_gowns": 0.07, "other_device": 0.05},
|
| 49 |
+
"sf_prevalence": 0.18,
|
| 50 |
+
"false_negative_risk": 0.0,
|
| 51 |
+
"false_positive_risk": 0.0,
|
| 52 |
+
"who_pq_pct": 0.15,
|
| 53 |
+
"nmra_registered_pct": 0.40,
|
| 54 |
+
},
|
| 55 |
+
"covid_pandemic_products": {
|
| 56 |
+
"setting_probs": {"online_seller": 0.30, "pharmacy": 0.20,
|
| 57 |
+
"informal_market": 0.25, "border_crossing": 0.25},
|
| 58 |
+
"product_probs": {"COVID_test_kit": 0.25, "face_mask_N95": 0.15,
|
| 59 |
+
"surgical_mask": 0.12, "hand_sanitiser": 0.12,
|
| 60 |
+
"PPE_gown": 0.10, "pulse_oximeter": 0.08,
|
| 61 |
+
"thermometer": 0.08, "ventilator_parts": 0.05,
|
| 62 |
+
"other_covid": 0.05},
|
| 63 |
+
"sf_prevalence": 0.30,
|
| 64 |
+
"false_negative_risk": 0.20,
|
| 65 |
+
"false_positive_risk": 0.08,
|
| 66 |
+
"who_pq_pct": 0.10,
|
| 67 |
+
"nmra_registered_pct": 0.25,
|
| 68 |
+
},
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
SCENARIO_FILES = {
|
| 72 |
+
"diagnostics_rdts": "falsified_diagnostics.csv",
|
| 73 |
+
"medical_devices_consumables": "falsified_devices.csv",
|
| 74 |
+
"covid_pandemic_products": "falsified_covid.csv",
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def _choice(rng, prob_map):
|
| 79 |
+
keys = list(prob_map.keys())
|
| 80 |
+
weights = np.array(list(prob_map.values()), dtype=float)
|
| 81 |
+
weights = weights / weights.sum()
|
| 82 |
+
return rng.choice(keys, p=weights)
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def _simulate_scenario(name, params, seed):
|
| 86 |
+
rng = np.random.default_rng(seed)
|
| 87 |
+
records = []
|
| 88 |
+
|
| 89 |
+
for idx in range(N_PER_SCENARIO):
|
| 90 |
+
year = int(rng.choice(YEAR_RANGE, p=YEAR_WEIGHTS))
|
| 91 |
+
setting = _choice(rng, params["setting_probs"])
|
| 92 |
+
product = _choice(rng, params["product_probs"])
|
| 93 |
+
|
| 94 |
+
manufacturer_origin = rng.choice(["china", "india", "local", "europe",
|
| 95 |
+
"unknown", "relabelled"],
|
| 96 |
+
p=[0.30, 0.20, 0.15, 0.10, 0.15, 0.10])
|
| 97 |
+
nmra_registered = int(rng.random() < params["nmra_registered_pct"])
|
| 98 |
+
who_pq = int(rng.random() < params["who_pq_pct"])
|
| 99 |
+
ce_marked = int(manufacturer_origin == "europe" or rng.random() < 0.10)
|
| 100 |
+
lot_traceable = int(rng.random() < 0.30)
|
| 101 |
+
|
| 102 |
+
# Quality
|
| 103 |
+
is_sf = int(rng.random() < params["sf_prevalence"])
|
| 104 |
+
is_falsified = int(is_sf and rng.random() < 0.50)
|
| 105 |
+
is_substandard = int(is_sf and not is_falsified)
|
| 106 |
+
counterfeit_packaging = int(is_falsified and rng.random() < 0.60)
|
| 107 |
+
expired = int(rng.random() < 0.06)
|
| 108 |
+
sterility_failed = int(is_sf and product in ("surgical_gloves", "syringes_needles",
|
| 109 |
+
"sutures", "blood_bags", "catheters",
|
| 110 |
+
"IV_giving_sets") and rng.random() < 0.15)
|
| 111 |
+
material_defect = int(is_sf and rng.random() < 0.20)
|
| 112 |
+
|
| 113 |
+
# Diagnostic performance (for RDTs/tests)
|
| 114 |
+
is_diagnostic = int("RDT" in product or "test" in product or "COVID" in product
|
| 115 |
+
or "glucose" in product or "hepatitis" in product
|
| 116 |
+
or "pregnancy" in product)
|
| 117 |
+
false_negative = int(is_diagnostic and is_sf and
|
| 118 |
+
rng.random() < params["false_negative_risk"])
|
| 119 |
+
false_positive = int(is_diagnostic and is_sf and
|
| 120 |
+
rng.random() < params["false_positive_risk"])
|
| 121 |
+
sensitivity_reduced = int(is_diagnostic and is_sf and rng.random() < 0.25)
|
| 122 |
+
|
| 123 |
+
# Health impact
|
| 124 |
+
infection_risk = int(sterility_failed and rng.random() < 0.10)
|
| 125 |
+
misdiagnosis = int(false_negative or false_positive)
|
| 126 |
+
delayed_treatment = int(misdiagnosis and rng.random() < 0.50)
|
| 127 |
+
adverse_event = int(material_defect and rng.random() < 0.08)
|
| 128 |
+
death = int((infection_risk or delayed_treatment) and rng.random() < 0.03)
|
| 129 |
+
|
| 130 |
+
# Detection & enforcement
|
| 131 |
+
visual_inspection_failed = int(is_falsified and rng.random() < 0.30)
|
| 132 |
+
reported_to_nmra = int(is_sf and rng.random() < 0.05)
|
| 133 |
+
recalled = int(reported_to_nmra and rng.random() < 0.20)
|
| 134 |
+
seized_by_customs = int(setting == "border_crossing" and is_sf and rng.random() < 0.10)
|
| 135 |
+
|
| 136 |
+
price_usd = float(np.clip(rng.lognormal(np.log(2), 0.8), 0.10, 100))
|
| 137 |
+
suspiciously_cheap = int(is_falsified and price_usd < 0.80)
|
| 138 |
+
|
| 139 |
+
any_harm = int(infection_risk or misdiagnosis or adverse_event or death)
|
| 140 |
+
|
| 141 |
+
record = {
|
| 142 |
+
"record_id": f"{name[:3].upper()}-{idx:05d}",
|
| 143 |
+
"scenario": name,
|
| 144 |
+
"year": year,
|
| 145 |
+
"setting": setting,
|
| 146 |
+
"product": product,
|
| 147 |
+
"manufacturer_origin": manufacturer_origin,
|
| 148 |
+
"nmra_registered": nmra_registered,
|
| 149 |
+
"who_pq": who_pq,
|
| 150 |
+
"lot_traceable": lot_traceable,
|
| 151 |
+
"is_substandard_falsified": is_sf,
|
| 152 |
+
"is_falsified": is_falsified,
|
| 153 |
+
"counterfeit_packaging": counterfeit_packaging,
|
| 154 |
+
"expired": expired,
|
| 155 |
+
"sterility_failed": sterility_failed,
|
| 156 |
+
"material_defect": material_defect,
|
| 157 |
+
"is_diagnostic": is_diagnostic,
|
| 158 |
+
"false_negative": false_negative,
|
| 159 |
+
"false_positive": false_positive,
|
| 160 |
+
"sensitivity_reduced": sensitivity_reduced,
|
| 161 |
+
"infection_risk": infection_risk,
|
| 162 |
+
"misdiagnosis": misdiagnosis,
|
| 163 |
+
"delayed_treatment": delayed_treatment,
|
| 164 |
+
"adverse_event": adverse_event,
|
| 165 |
+
"death": death,
|
| 166 |
+
"reported_to_nmra": reported_to_nmra,
|
| 167 |
+
"recalled": recalled,
|
| 168 |
+
"seized_by_customs": seized_by_customs,
|
| 169 |
+
"price_usd": round(price_usd, 2),
|
| 170 |
+
"any_harm": any_harm,
|
| 171 |
+
}
|
| 172 |
+
records.append(record)
|
| 173 |
+
|
| 174 |
+
return pd.DataFrame(records)
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
def main():
|
| 178 |
+
output_dir = Path("data")
|
| 179 |
+
output_dir.mkdir(parents=True, exist_ok=True)
|
| 180 |
+
for idx, (name, params) in enumerate(SCENARIOS.items()):
|
| 181 |
+
df = _simulate_scenario(name, params, SEED + idx * 211)
|
| 182 |
+
df.to_csv(output_dir / SCENARIO_FILES[name], index=False)
|
| 183 |
+
print(f"Saved {name} -> {SCENARIO_FILES[name]}")
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
if __name__ == "__main__":
|
| 187 |
+
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,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Validate synthetic falsified medical products & devices 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 |
+
"diagnostics_rdts": "falsified_diagnostics.csv",
|
| 12 |
+
"medical_devices_consumables": "falsified_devices.csv",
|
| 13 |
+
"covid_pandemic_products": "falsified_covid.csv",
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
COLORS = {"diagnostics_rdts": "#e6550d", "medical_devices_consumables": "#756bb1", "covid_pandemic_products": "#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 |
+
sf_cols = ["is_substandard_falsified", "is_falsified", "counterfeit_packaging"]
|
| 32 |
+
sf = df.groupby("scenario")[sf_cols].mean() * 100
|
| 33 |
+
sf.plot(kind="bar", ax=axes[0])
|
| 34 |
+
axes[0].set_title("SF Prevalence (%)")
|
| 35 |
+
axes[0].legend(fontsize=7)
|
| 36 |
+
|
| 37 |
+
prod = df.groupby(["scenario", "product"]).size().groupby(level=0).apply(lambda s: s / s.sum())
|
| 38 |
+
prod.unstack().plot(kind="bar", stacked=True, ax=axes[1])
|
| 39 |
+
axes[1].set_title("Product Distribution")
|
| 40 |
+
axes[1].legend(fontsize=4)
|
| 41 |
+
|
| 42 |
+
diag_cols = ["false_negative", "false_positive", "sensitivity_reduced", "misdiagnosis"]
|
| 43 |
+
diag = df.groupby("scenario")[diag_cols].mean() * 100
|
| 44 |
+
diag.plot(kind="bar", ax=axes[2])
|
| 45 |
+
axes[2].set_title("Diagnostic Performance Issues (%)")
|
| 46 |
+
axes[2].legend(fontsize=6)
|
| 47 |
+
|
| 48 |
+
harm_cols = ["infection_risk", "delayed_treatment", "adverse_event", "death"]
|
| 49 |
+
harm = df.groupby("scenario")[harm_cols].mean() * 100
|
| 50 |
+
harm.plot(kind="bar", ax=axes[3])
|
| 51 |
+
axes[3].set_title("Health Impact (%)")
|
| 52 |
+
axes[3].legend(fontsize=7)
|
| 53 |
+
|
| 54 |
+
qa_cols = ["sterility_failed", "material_defect", "expired"]
|
| 55 |
+
qa = df.groupby("scenario")[qa_cols].mean() * 100
|
| 56 |
+
qa.plot(kind="bar", ax=axes[4])
|
| 57 |
+
axes[4].set_title("Quality Defects (%)")
|
| 58 |
+
axes[4].legend(fontsize=7)
|
| 59 |
+
|
| 60 |
+
reg_cols = ["nmra_registered", "who_pq", "lot_traceable"]
|
| 61 |
+
reg = df.groupby("scenario")[reg_cols].mean() * 100
|
| 62 |
+
reg.plot(kind="bar", ax=axes[5])
|
| 63 |
+
axes[5].set_title("Registration & Traceability (%)")
|
| 64 |
+
axes[5].legend(fontsize=7)
|
| 65 |
+
|
| 66 |
+
orig = df.groupby(["scenario", "manufacturer_origin"]).size().groupby(level=0).apply(lambda s: s / s.sum())
|
| 67 |
+
orig.unstack().plot(kind="bar", stacked=True, ax=axes[6])
|
| 68 |
+
axes[6].set_title("Manufacturer Origin")
|
| 69 |
+
axes[6].legend(fontsize=5)
|
| 70 |
+
|
| 71 |
+
enf_cols = ["reported_to_nmra", "recalled", "seized_by_customs"]
|
| 72 |
+
enf = df.groupby("scenario")[enf_cols].mean() * 100
|
| 73 |
+
enf.plot(kind="bar", ax=axes[7])
|
| 74 |
+
axes[7].set_title("Enforcement Actions (%)")
|
| 75 |
+
axes[7].legend(fontsize=7)
|
| 76 |
+
|
| 77 |
+
plt.tight_layout()
|
| 78 |
+
fig.savefig(output_path, dpi=200)
|
| 79 |
+
plt.close(fig)
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def main() -> None:
|
| 83 |
+
df = load_data()
|
| 84 |
+
plot_validation(df, Path("validation_report.png"))
|
| 85 |
+
print("Saved validation_report.png")
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
if __name__ == "__main__":
|
| 89 |
+
main()
|
validation_report.png
ADDED
|
Git LFS Details
|