Kossisoroyce commited on
Commit
5b30785
·
verified ·
1 Parent(s): 83a30f6

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ task_categories:
4
+ - tabular-classification
5
+ language:
6
+ - en
7
+ tags:
8
+ - substandard-falsified-medicines
9
+ - pharmacovigilance
10
+ - adverse-drug-reactions
11
+ - drug-safety
12
+ - VigiFlow
13
+ - synthetic
14
+ - sub-saharan-africa
15
+ pretty_name: Pharmacovigilance & Adverse Drug Reactions (SSA)
16
+ size_categories:
17
+ - 10K<n<100K
18
+ configs:
19
+ - config_name: tertiary_hospital_pv
20
+ data_files: data/pv_tertiary_hospital.csv
21
+ default: true
22
+ - config_name: community_primary_care
23
+ data_files: data/pv_community_primary.csv
24
+ - config_name: mass_treatment_campaign
25
+ data_files: data/pv_mass_treatment.csv
26
+ ---
27
+
28
+ # Pharmacovigilance & Adverse Drug Reactions in Sub-Saharan Africa
29
+
30
+ ## Abstract
31
+
32
+ Synthetic dataset modelling ADR occurrence, reporting cascades, PV system capacity, and medication errors across three healthcare settings in SSA. Massive underreporting exists — <10% of ADRs reported in most SSA countries. Inadequate training and deficient reporting culture are key barriers.
33
+
34
+ ## Parameterization Evidence
35
+
36
+ | Parameter | Value | Source | Year |
37
+ | --- | --- | --- | --- |
38
+ | ADR reporting patterns in Africa | Reporting | PMC4796322 | 2016 |
39
+ | PV systems for medication error reporting | Systems | PLOS ONE | 2022 |
40
+ | ADR report completeness; VigiFlow system | Quality | PMC9900287 | 2023 |
41
+ | West African PV: inadequate training, poor culture | Barriers | CJGH | 2025 |
42
+
43
+ ## Validation
44
+
45
+ ![Validation Report](validation_report.png)
46
+
47
+ ## Usage
48
+
49
+ ```python
50
+ from datasets import load_dataset
51
+ ds = load_dataset("electricsheepafrica/pharmacovigilance-adr", "tertiary_hospital_pv")
52
+ ```
53
+
54
+ ## References
55
+
56
+ 1. PMC4796322. ADR reporting in Africa. 2016.
57
+ 2. PLOS ONE. PV systems for medication errors in Africa. 2022.
58
+ 3. PMC9900287. ADR report completeness in South Africa. 2023.
59
+ 4. CJGH. PV systems in West African countries. 2025.
60
+
61
+ ## Citation
62
+
63
+ ```bibtex
64
+ @dataset{electricsheepafrica_pharmacovigilance_adr_2025,
65
+ title={Pharmacovigilance and Adverse Drug Reactions in Sub-Saharan Africa},
66
+ author={Electric Sheep Africa},
67
+ year={2025},
68
+ publisher={HuggingFace},
69
+ url={https://huggingface.co/datasets/electricsheepafrica/pharmacovigilance-adr}
70
+ }
71
+ ```
72
+
73
+ ## License
74
+
75
+ CC-BY-4.0
data/pv_community_primary.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/pv_mass_treatment.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/pv_tertiary_hospital.csv ADDED
The diff for this file is too large to render. See raw diff
 
generate_dataset.py ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Generate synthetic pharmacovigilance & adverse drug reaction dataset for SSA.
2
+
3
+ Research-based parameterization:
4
+ - PMC4796322: ADR reporting in Africa; targeted spontaneous reporting
5
+ and cohort event monitoring could strengthen PV.
6
+ - PLOS ONE (2022): PV systems for medication error reporting in Africa.
7
+ - PMC9900287: ADR report completeness in South Africa; VigiFlow system.
8
+ - CJGH: West African PV systems; inadequate training, deficient
9
+ reporting culture, underdeveloped regulatory frameworks.
10
+ - SSA context: Massive underreporting; <10% of ADRs reported in most
11
+ countries; limited PV centres; few trained personnel.
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
+ "tertiary_hospital_pv": {
30
+ "setting_probs": {"tertiary_hospital": 0.40, "regional_hospital": 0.30,
31
+ "teaching_hospital": 0.20, "specialist_clinic": 0.10},
32
+ "drug_class_probs": {"antiretroviral": 0.20, "antibiotic": 0.15,
33
+ "antimalarial": 0.12, "NSAID_analgesic": 0.12,
34
+ "antiepileptic": 0.08, "antihypertensive": 0.08,
35
+ "anti_TB": 0.08, "chemotherapy": 0.07,
36
+ "antidiabetic": 0.05, "other": 0.05},
37
+ "adr_reporting_rate": 0.15,
38
+ "serious_adr_pct": 0.25,
39
+ "medication_error_pct": 0.08,
40
+ "vigiflow_reporting": 0.30,
41
+ "pv_trained_staff_pct": 0.20,
42
+ },
43
+ "community_primary_care": {
44
+ "setting_probs": {"health_centre": 0.35, "district_hospital": 0.25,
45
+ "community_pharmacy": 0.25, "private_clinic": 0.15},
46
+ "drug_class_probs": {"antibiotic": 0.25, "antimalarial": 0.20,
47
+ "NSAID_analgesic": 0.15, "antihypertensive": 0.10,
48
+ "contraceptive": 0.08, "antiretroviral": 0.08,
49
+ "antidiabetic": 0.05, "supplement": 0.05,
50
+ "other": 0.04},
51
+ "adr_reporting_rate": 0.03,
52
+ "serious_adr_pct": 0.15,
53
+ "medication_error_pct": 0.12,
54
+ "vigiflow_reporting": 0.05,
55
+ "pv_trained_staff_pct": 0.05,
56
+ },
57
+ "mass_treatment_campaign": {
58
+ "setting_probs": {"community_outreach": 0.35, "school_campaign": 0.20,
59
+ "health_post": 0.25, "mobile_clinic": 0.20},
60
+ "drug_class_probs": {"ivermectin_MDA": 0.25, "praziquantel_MDA": 0.20,
61
+ "albendazole_MDA": 0.15, "azithromycin_MDA": 0.10,
62
+ "antimalarial_SMC": 0.10, "vaccine": 0.10,
63
+ "DEC_MDA": 0.05, "other": 0.05},
64
+ "adr_reporting_rate": 0.08,
65
+ "serious_adr_pct": 0.05,
66
+ "medication_error_pct": 0.06,
67
+ "vigiflow_reporting": 0.10,
68
+ "pv_trained_staff_pct": 0.08,
69
+ },
70
+ }
71
+
72
+ SCENARIO_FILES = {
73
+ "tertiary_hospital_pv": "pv_tertiary_hospital.csv",
74
+ "community_primary_care": "pv_community_primary.csv",
75
+ "mass_treatment_campaign": "pv_mass_treatment.csv",
76
+ }
77
+
78
+
79
+ def _choice(rng, prob_map):
80
+ keys = list(prob_map.keys())
81
+ weights = np.array(list(prob_map.values()), dtype=float)
82
+ weights = weights / weights.sum()
83
+ return rng.choice(keys, p=weights)
84
+
85
+
86
+ def _simulate_scenario(name, params, seed):
87
+ rng = np.random.default_rng(seed)
88
+ records = []
89
+
90
+ for idx in range(N_PER_SCENARIO):
91
+ year = int(rng.choice(YEAR_RANGE, p=YEAR_WEIGHTS))
92
+ setting = _choice(rng, params["setting_probs"])
93
+ age = int(np.clip(rng.normal(30, 18), 0, 80))
94
+ sex = rng.choice(["male", "female"], p=[0.45, 0.55])
95
+ is_child = int(age < 15)
96
+ pregnant = int(sex == "female" and 15 <= age <= 45 and rng.random() < 0.08)
97
+
98
+ drug_class = _choice(rng, params["drug_class_probs"])
99
+ polypharmacy = int(rng.random() < 0.25)
100
+ num_medicines = int(np.clip(rng.poisson(2 if polypharmacy else 1), 1, 10))
101
+
102
+ # ADR occurrence
103
+ adr_occurred = int(rng.random() < 0.10)
104
+ adr_type = rng.choice(["skin_rash", "GI_disturbance", "hepatotoxicity",
105
+ "nephrotoxicity", "haematological", "neurological",
106
+ "anaphylaxis", "Stevens_Johnson", "other"],
107
+ p=[0.25, 0.20, 0.10, 0.08, 0.08, 0.08, 0.03, 0.02, 0.16]) if adr_occurred else "none"
108
+ adr_severity = rng.choice(["mild", "moderate", "severe", "fatal"],
109
+ p=[0.50, 0.30, 0.15, 0.05]) if adr_occurred else "none"
110
+ serious_adr = int(adr_occurred and adr_severity in ("severe", "fatal"))
111
+ hospitalisation_due_adr = int(serious_adr and rng.random() < 0.50)
112
+ death_due_adr = int(adr_severity == "fatal")
113
+
114
+ # Causality
115
+ causality = rng.choice(["certain", "probable", "possible", "unlikely",
116
+ "unassessable", "not_assessed"],
117
+ p=[0.05, 0.20, 0.30, 0.10, 0.10, 0.25]) if adr_occurred else "not_applicable"
118
+
119
+ # Medication error
120
+ medication_error = int(rng.random() < params["medication_error_pct"])
121
+ error_type = rng.choice(["wrong_dose", "wrong_drug", "wrong_route",
122
+ "omission", "wrong_frequency", "dispensing_error"],
123
+ p=[0.30, 0.10, 0.05, 0.25, 0.15, 0.15]) if medication_error else "none"
124
+
125
+ # Reporting (massive underreporting in SSA)
126
+ adr_reported = int(adr_occurred and rng.random() < params["adr_reporting_rate"])
127
+ reported_to_nmra = int(adr_reported and rng.random() < 0.40)
128
+ vigiflow_submitted = int(reported_to_nmra and rng.random() < params["vigiflow_reporting"])
129
+ report_complete = int(adr_reported and rng.random() < 0.35)
130
+ time_to_report_days = int(np.clip(rng.exponential(30), 1, 365)) if adr_reported else 0
131
+
132
+ # Reporter
133
+ reporter_type = rng.choice(["physician", "pharmacist", "nurse", "patient", "other"],
134
+ p=[0.30, 0.25, 0.25, 0.10, 0.10]) if adr_reported else "none"
135
+
136
+ # PV system capacity
137
+ pv_focal_person = int(rng.random() < params["pv_trained_staff_pct"])
138
+ adr_form_available = int(rng.random() < 0.30)
139
+ pv_training_received = int(rng.random() < params["pv_trained_staff_pct"])
140
+ knows_reporting_process = int(rng.random() < 0.15)
141
+
142
+ # Signal detection
143
+ signal_detected = int(adr_reported and rng.random() < 0.05)
144
+ regulatory_action = int(signal_detected and rng.random() < 0.20)
145
+
146
+ record = {
147
+ "record_id": f"{name[:3].upper()}-{idx:05d}",
148
+ "scenario": name,
149
+ "year": year,
150
+ "setting": setting,
151
+ "age": age,
152
+ "sex": sex,
153
+ "is_child": is_child,
154
+ "drug_class": drug_class,
155
+ "polypharmacy": polypharmacy,
156
+ "num_medicines": num_medicines,
157
+ "adr_occurred": adr_occurred,
158
+ "adr_type": adr_type,
159
+ "adr_severity": adr_severity,
160
+ "serious_adr": serious_adr,
161
+ "hospitalisation_due_adr": hospitalisation_due_adr,
162
+ "death_due_adr": death_due_adr,
163
+ "causality": causality,
164
+ "medication_error": medication_error,
165
+ "error_type": error_type,
166
+ "adr_reported": adr_reported,
167
+ "reported_to_nmra": reported_to_nmra,
168
+ "vigiflow_submitted": vigiflow_submitted,
169
+ "report_complete": report_complete,
170
+ "time_to_report_days": time_to_report_days,
171
+ "reporter_type": reporter_type,
172
+ "pv_focal_person": pv_focal_person,
173
+ "adr_form_available": adr_form_available,
174
+ "pv_training_received": pv_training_received,
175
+ "knows_reporting_process": knows_reporting_process,
176
+ "signal_detected": signal_detected,
177
+ "regulatory_action": regulatory_action,
178
+ }
179
+ records.append(record)
180
+
181
+ return pd.DataFrame(records)
182
+
183
+
184
+ def main():
185
+ output_dir = Path("data")
186
+ output_dir.mkdir(parents=True, exist_ok=True)
187
+ for idx, (name, params) in enumerate(SCENARIOS.items()):
188
+ df = _simulate_scenario(name, params, SEED + idx * 211)
189
+ df.to_csv(output_dir / SCENARIO_FILES[name], index=False)
190
+ print(f"Saved {name} -> {SCENARIO_FILES[name]}")
191
+
192
+
193
+ if __name__ == "__main__":
194
+ 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 pharmacovigilance & adverse drug reaction 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
+ "tertiary_hospital_pv": "pv_tertiary_hospital.csv",
12
+ "community_primary_care": "pv_community_primary.csv",
13
+ "mass_treatment_campaign": "pv_mass_treatment.csv",
14
+ }
15
+
16
+ COLORS = {"tertiary_hospital_pv": "#e6550d", "community_primary_care": "#756bb1", "mass_treatment_campaign": "#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
+ adr_cols = ["adr_occurred", "serious_adr", "hospitalisation_due_adr", "death_due_adr"]
32
+ adr = df.groupby("scenario")[adr_cols].mean() * 100
33
+ adr.plot(kind="bar", ax=axes[0])
34
+ axes[0].set_title("ADR Occurrence & Severity (%)")
35
+ axes[0].legend(fontsize=6)
36
+
37
+ rep_cols = ["adr_reported", "reported_to_nmra", "vigiflow_submitted", "report_complete"]
38
+ rep = df.groupby("scenario")[rep_cols].mean() * 100
39
+ rep.plot(kind="bar", ax=axes[1])
40
+ axes[1].set_title("Reporting Cascade (%)")
41
+ axes[1].legend(fontsize=6)
42
+
43
+ adr_df = df[df["adr_occurred"] == 1]
44
+ if len(adr_df) > 0:
45
+ at = adr_df.groupby(["scenario", "adr_type"]).size().groupby(level=0).apply(lambda s: s / s.sum())
46
+ at.unstack().plot(kind="bar", stacked=True, ax=axes[2])
47
+ axes[2].set_title("ADR Type Distribution")
48
+ axes[2].legend(fontsize=4)
49
+
50
+ dc = df.groupby(["scenario", "drug_class"]).size().groupby(level=0).apply(lambda s: s / s.sum())
51
+ dc.unstack().plot(kind="bar", stacked=True, ax=axes[3])
52
+ axes[3].set_title("Drug Class Distribution")
53
+ axes[3].legend(fontsize=4)
54
+
55
+ cap_cols = ["pv_focal_person", "adr_form_available", "pv_training_received", "knows_reporting_process"]
56
+ cap = df.groupby("scenario")[cap_cols].mean() * 100
57
+ cap.plot(kind="bar", ax=axes[4])
58
+ axes[4].set_title("PV System Capacity (%)")
59
+ axes[4].legend(fontsize=6)
60
+
61
+ err_cols = ["medication_error"]
62
+ err = df.groupby("scenario")[err_cols].mean() * 100
63
+ err.plot(kind="bar", ax=axes[5])
64
+ axes[5].set_title("Medication Error Rate (%)")
65
+ axes[5].legend(fontsize=7)
66
+
67
+ if len(adr_df) > 0:
68
+ sev = adr_df.groupby(["scenario", "adr_severity"]).size().groupby(level=0).apply(lambda s: s / s.sum())
69
+ sev.unstack().plot(kind="bar", stacked=True, ax=axes[6])
70
+ axes[6].set_title("ADR Severity Distribution")
71
+ axes[6].legend(fontsize=7)
72
+
73
+ rep_adr = df[df["adr_reported"] == 1]
74
+ if len(rep_adr) > 0:
75
+ rt = rep_adr.groupby(["scenario", "reporter_type"]).size().groupby(level=0).apply(lambda s: s / s.sum())
76
+ rt.unstack().plot(kind="bar", stacked=True, ax=axes[7])
77
+ axes[7].set_title("Reporter Type Distribution")
78
+ axes[7].legend(fontsize=6)
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

  • SHA256: fef5bfbaf1eaf4c5b5092022cac9f96ef717b55fd3062651a86aad658c66ce6a
  • Pointer size: 131 Bytes
  • Size of remote file: 293 kB