Kossisoroyce commited on
Commit
065c8ec
·
verified ·
1 Parent(s): 20ab5d3

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ task_categories:
4
+ - tabular-classification
5
+ language:
6
+ - en
7
+ tags:
8
+ - substandard-falsified-medicines
9
+ - online-pharmacy
10
+ - unregistered-medicines
11
+ - e-commerce
12
+ - synthetic
13
+ - sub-saharan-africa
14
+ pretty_name: Online Pharmacy & Unregistered Medicines (SSA)
15
+ size_categories:
16
+ - 10K<n<100K
17
+ configs:
18
+ - config_name: social_media_marketplace
19
+ data_files: data/online_social_media.csv
20
+ default: true
21
+ - config_name: dedicated_online_pharmacy
22
+ data_files: data/online_dedicated.csv
23
+ - config_name: cross_border_ecommerce
24
+ data_files: data/online_cross_border.csv
25
+ ---
26
+
27
+ # Online Pharmacy & Unregistered Medicines in Sub-Saharan Africa
28
+
29
+ ## Abstract
30
+
31
+ Synthetic dataset modelling online pharmaceutical sales, unregistered medicine prevalence, and health outcomes across social media, dedicated e-pharmacies, and cross-border e-commerce in SSA. WHO estimates 50% of medicines from illegal online sites are falsified.
32
+
33
+ ## Parameterization Evidence
34
+
35
+ | Parameter | Value | Source | Year |
36
+ | --- | --- | --- | --- |
37
+ | 50% of online medicines from illegal sites falsified | Prevalence | WHO | 2018 |
38
+ | Most counterfeited: analgesics, antibiotics, ARVs, stimulants | Products | SAHPRA | 2023 |
39
+ | Growing e-pharmacy and social media sales in Africa | Trend | Literature review | 2024 |
40
+
41
+ ## Validation
42
+
43
+ ![Validation Report](validation_report.png)
44
+
45
+ ## Usage
46
+
47
+ ```python
48
+ from datasets import load_dataset
49
+ ds = load_dataset("electricsheepafrica/online-pharmacy-unregistered", "social_media_marketplace")
50
+ ```
51
+
52
+ ## References
53
+
54
+ 1. WHO. Substandard and falsified medical products. 2018.
55
+ 2. SAHPRA. Fake medicines are a dangerous threat in Africa. 2023.
56
+
57
+ ## Citation
58
+
59
+ ```bibtex
60
+ @dataset{electricsheepafrica_online_pharmacy_unregistered_2025,
61
+ title={Online Pharmacy and Unregistered Medicines in Sub-Saharan Africa},
62
+ author={Electric Sheep Africa},
63
+ year={2025},
64
+ publisher={HuggingFace},
65
+ url={https://huggingface.co/datasets/electricsheepafrica/online-pharmacy-unregistered}
66
+ }
67
+ ```
68
+
69
+ ## License
70
+
71
+ CC-BY-4.0
data/online_cross_border.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/online_dedicated.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/online_social_media.csv ADDED
The diff for this file is too large to render. See raw diff
 
generate_dataset.py ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Generate synthetic online pharmacy & unregistered medicines dataset for SSA.
2
+
3
+ Research-based parameterization:
4
+ - WHO: 50% of medicines purchased online from illegal sites are
5
+ falsified; growing e-pharmacy market in Africa.
6
+ - SAHPRA: Fake medicines common; painkillers, antibiotics, antimalarials,
7
+ ARVs, sexual stimulants most counterfeited online.
8
+ - SSA context: Limited regulation of online pharmacies; social media
9
+ sales; WhatsApp/Facebook marketplace; cross-border e-commerce.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ from pathlib import Path
15
+
16
+ import numpy as np
17
+ import pandas as pd
18
+
19
+ SEED = 42
20
+ N_PER_SCENARIO = 10_000
21
+
22
+ YEAR_RANGE = np.arange(2010, 2025)
23
+ YEAR_WEIGHTS = np.linspace(0.85, 1.3, len(YEAR_RANGE))
24
+ YEAR_WEIGHTS = YEAR_WEIGHTS / YEAR_WEIGHTS.sum()
25
+
26
+ SCENARIOS = {
27
+ "social_media_marketplace": {
28
+ "setting_probs": {"whatsapp": 0.30, "facebook_marketplace": 0.25,
29
+ "instagram": 0.20, "telegram": 0.15, "tiktok": 0.10},
30
+ "product_probs": {"sexual_stimulant": 0.20, "weight_loss": 0.15,
31
+ "antibiotic": 0.15, "analgesic": 0.12,
32
+ "skin_lightening": 0.10, "supplement": 0.10,
33
+ "antimalarial": 0.08, "other": 0.10},
34
+ "sf_prevalence": 0.45,
35
+ "unregistered_pct": 0.70,
36
+ "no_prescription_pct": 0.95,
37
+ "pharmacist_involved_pct": 0.02,
38
+ "verified_seller_pct": 0.05,
39
+ },
40
+ "dedicated_online_pharmacy": {
41
+ "setting_probs": {"dedicated_website": 0.35, "mobile_app": 0.25,
42
+ "aggregator_platform": 0.20, "telemedicine_linked": 0.20},
43
+ "product_probs": {"antibiotic": 0.15, "antihypertensive": 0.12,
44
+ "antidiabetic": 0.10, "analgesic": 0.12,
45
+ "contraceptive": 0.08, "ARV": 0.05,
46
+ "supplement": 0.15, "sexual_stimulant": 0.10,
47
+ "other": 0.13},
48
+ "sf_prevalence": 0.20,
49
+ "unregistered_pct": 0.40,
50
+ "no_prescription_pct": 0.60,
51
+ "pharmacist_involved_pct": 0.25,
52
+ "verified_seller_pct": 0.30,
53
+ },
54
+ "cross_border_ecommerce": {
55
+ "setting_probs": {"alibaba_aliexpress": 0.30, "jumia_marketplace": 0.20,
56
+ "international_website": 0.25, "dark_web": 0.10,
57
+ "unknown_platform": 0.15},
58
+ "product_probs": {"antibiotic": 0.15, "sexual_stimulant": 0.15,
59
+ "controlled_substance": 0.10, "weight_loss": 0.10,
60
+ "supplement": 0.12, "antimalarial": 0.08,
61
+ "skin_lightening": 0.10, "other": 0.20},
62
+ "sf_prevalence": 0.50,
63
+ "unregistered_pct": 0.80,
64
+ "no_prescription_pct": 0.90,
65
+ "pharmacist_involved_pct": 0.01,
66
+ "verified_seller_pct": 0.03,
67
+ },
68
+ }
69
+
70
+ SCENARIO_FILES = {
71
+ "social_media_marketplace": "online_social_media.csv",
72
+ "dedicated_online_pharmacy": "online_dedicated.csv",
73
+ "cross_border_ecommerce": "online_cross_border.csv",
74
+ }
75
+
76
+
77
+ def _choice(rng, prob_map):
78
+ keys = list(prob_map.keys())
79
+ weights = np.array(list(prob_map.values()), dtype=float)
80
+ weights = weights / weights.sum()
81
+ return rng.choice(keys, p=weights)
82
+
83
+
84
+ def _simulate_scenario(name, params, seed):
85
+ rng = np.random.default_rng(seed)
86
+ records = []
87
+
88
+ for idx in range(N_PER_SCENARIO):
89
+ year = int(rng.choice(YEAR_RANGE, p=YEAR_WEIGHTS))
90
+ platform = _choice(rng, params["setting_probs"])
91
+ product = _choice(rng, params["product_probs"])
92
+ age = int(np.clip(rng.normal(28, 10), 15, 65))
93
+ sex = rng.choice(["male", "female"], p=[0.50, 0.50])
94
+
95
+ no_prescription = int(rng.random() < params["no_prescription_pct"])
96
+ self_medication = int(no_prescription and rng.random() < 0.80)
97
+ pharmacist_involved = int(rng.random() < params["pharmacist_involved_pct"])
98
+ verified_seller = int(rng.random() < params["verified_seller_pct"])
99
+
100
+ # Registration status
101
+ unregistered = int(rng.random() < params["unregistered_pct"])
102
+ nmra_approved = int(not unregistered and rng.random() < 0.60)
103
+ manufacturer_known = int(rng.random() < 0.40)
104
+ batch_traceable = int(manufacturer_known and rng.random() < 0.30)
105
+
106
+ # Quality
107
+ is_sf = int(rng.random() < params["sf_prevalence"])
108
+ is_falsified = int(is_sf and rng.random() < 0.50)
109
+ is_substandard = int(is_sf and not is_falsified)
110
+ no_active_ingredient = int(is_falsified and rng.random() < 0.30)
111
+ wrong_ingredient = int(is_falsified and rng.random() < 0.15)
112
+ contaminated = int(is_sf and rng.random() < 0.10)
113
+
114
+ # Delivery
115
+ delivery_method = rng.choice(["courier", "postal", "pickup", "rider"],
116
+ p=[0.30, 0.20, 0.20, 0.30])
117
+ cold_chain_needed = int(product in ("vaccine", "ARV") and rng.random() < 0.30)
118
+ cold_chain_maintained = int(cold_chain_needed and rng.random() < 0.10)
119
+ delivery_days = int(np.clip(rng.exponential(5), 1, 30))
120
+
121
+ # Health outcomes
122
+ adr_occurred = int(is_sf and rng.random() < 0.08)
123
+ treatment_failure = int(is_sf and rng.random() < 0.12)
124
+ hospitalisation = int((adr_occurred or treatment_failure) and rng.random() < 0.10)
125
+ delayed_care = int(self_medication and rng.random() < 0.15)
126
+
127
+ # Regulation & enforcement
128
+ reported_to_nmra = int(is_sf and rng.random() < 0.02)
129
+ platform_removed = int(is_sf and rng.random() < 0.05)
130
+ consumer_aware_risk = int(rng.random() < 0.10)
131
+ checked_registration = int(rng.random() < 0.05)
132
+ price_usd = float(np.clip(rng.lognormal(np.log(3), 0.8), 0.20, 100))
133
+
134
+ any_adverse = int(adr_occurred or treatment_failure or delayed_care)
135
+
136
+ record = {
137
+ "record_id": f"{name[:3].upper()}-{idx:05d}",
138
+ "scenario": name,
139
+ "year": year,
140
+ "platform": platform,
141
+ "product": product,
142
+ "age": age,
143
+ "sex": sex,
144
+ "no_prescription": no_prescription,
145
+ "self_medication": self_medication,
146
+ "pharmacist_involved": pharmacist_involved,
147
+ "verified_seller": verified_seller,
148
+ "unregistered": unregistered,
149
+ "nmra_approved": nmra_approved,
150
+ "manufacturer_known": manufacturer_known,
151
+ "batch_traceable": batch_traceable,
152
+ "is_substandard_falsified": is_sf,
153
+ "is_falsified": is_falsified,
154
+ "no_active_ingredient": no_active_ingredient,
155
+ "wrong_ingredient": wrong_ingredient,
156
+ "contaminated": contaminated,
157
+ "delivery_method": delivery_method,
158
+ "delivery_days": delivery_days,
159
+ "adr_occurred": adr_occurred,
160
+ "treatment_failure": treatment_failure,
161
+ "hospitalisation": hospitalisation,
162
+ "delayed_care": delayed_care,
163
+ "reported_to_nmra": reported_to_nmra,
164
+ "consumer_aware_risk": consumer_aware_risk,
165
+ "price_usd": round(price_usd, 2),
166
+ "any_adverse": any_adverse,
167
+ }
168
+ records.append(record)
169
+
170
+ return pd.DataFrame(records)
171
+
172
+
173
+ def main():
174
+ output_dir = Path("data")
175
+ output_dir.mkdir(parents=True, exist_ok=True)
176
+ for idx, (name, params) in enumerate(SCENARIOS.items()):
177
+ df = _simulate_scenario(name, params, SEED + idx * 211)
178
+ df.to_csv(output_dir / SCENARIO_FILES[name], index=False)
179
+ print(f"Saved {name} -> {SCENARIO_FILES[name]}")
180
+
181
+
182
+ if __name__ == "__main__":
183
+ 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 online pharmacy & unregistered medicines 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
+ "social_media_marketplace": "online_social_media.csv",
12
+ "dedicated_online_pharmacy": "online_dedicated.csv",
13
+ "cross_border_ecommerce": "online_cross_border.csv",
14
+ }
15
+
16
+ COLORS = {"social_media_marketplace": "#e6550d", "dedicated_online_pharmacy": "#756bb1", "cross_border_ecommerce": "#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", "unregistered"]
32
+ sf = df.groupby("scenario")[sf_cols].mean() * 100
33
+ sf.plot(kind="bar", ax=axes[0])
34
+ axes[0].set_title("SF & Unregistered Prevalence (%)")
35
+ axes[0].legend(fontsize=7)
36
+
37
+ plat = df.groupby(["scenario", "platform"]).size().groupby(level=0).apply(lambda s: s / s.sum())
38
+ plat.unstack().plot(kind="bar", stacked=True, ax=axes[1])
39
+ axes[1].set_title("Platform Distribution")
40
+ axes[1].legend(fontsize=5)
41
+
42
+ prod = df.groupby(["scenario", "product"]).size().groupby(level=0).apply(lambda s: s / s.sum())
43
+ prod.unstack().plot(kind="bar", stacked=True, ax=axes[2])
44
+ axes[2].set_title("Product Distribution")
45
+ axes[2].legend(fontsize=4)
46
+
47
+ use_cols = ["no_prescription", "self_medication", "pharmacist_involved", "verified_seller"]
48
+ use = df.groupby("scenario")[use_cols].mean() * 100
49
+ use.plot(kind="bar", ax=axes[3])
50
+ axes[3].set_title("Purchase Patterns (%)")
51
+ axes[3].legend(fontsize=6)
52
+
53
+ out_cols = ["adr_occurred", "treatment_failure", "hospitalisation", "delayed_care"]
54
+ out = df.groupby("scenario")[out_cols].mean() * 100
55
+ out.plot(kind="bar", ax=axes[4])
56
+ axes[4].set_title("Health Outcomes (%)")
57
+ axes[4].legend(fontsize=7)
58
+
59
+ reg_cols = ["nmra_approved", "manufacturer_known", "batch_traceable"]
60
+ reg = df.groupby("scenario")[reg_cols].mean() * 100
61
+ reg.plot(kind="bar", ax=axes[5])
62
+ axes[5].set_title("Traceability & Registration (%)")
63
+ axes[5].legend(fontsize=7)
64
+
65
+ enf_cols = ["reported_to_nmra", "consumer_aware_risk"]
66
+ enf = df.groupby("scenario")[enf_cols].mean() * 100
67
+ enf.plot(kind="bar", ax=axes[6])
68
+ axes[6].set_title("Reporting & Awareness (%)")
69
+ axes[6].legend(fontsize=7)
70
+
71
+ for s in SCENARIO_FILES:
72
+ subset = df[df["scenario"] == s]
73
+ axes[7].hist(subset["price_usd"], bins=30, alpha=0.5, color=COLORS[s], label=s, range=(0, 30))
74
+ axes[7].set_title("Price Distribution (USD)")
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

  • SHA256: 8714056c3454fce34d98dba2a3ac0d8d61eb076017dcd94bc034c56a21b88baa
  • Pointer size: 131 Bytes
  • Size of remote file: 357 kB