Kossisoroyce commited on
Commit
f332b66
·
verified ·
1 Parent(s): 8367875

Add dataset files

Browse files
README.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ task_categories:
4
+ - tabular-classification
5
+ - tabular-regression
6
+ language:
7
+ - en
8
+ tags:
9
+ - healthcare
10
+ - medicine-quality
11
+ - online-pharmacy
12
+ - e-pharmacy
13
+ - social-media
14
+ - darknet
15
+ - falsified
16
+ - consumer-safety
17
+ - sub-saharan-africa
18
+ - lmic
19
+ pretty_name: "Online Pharmacy & E-Pharmacy Regulation (SF Prevalence, Platform Type, Consumer Safety)"
20
+ size_categories:
21
+ - 10K<n<100K
22
+ configs:
23
+ - config_name: licensed_e_pharmacy
24
+ data_files: data/epharmacy_licensed_e_pharmacy.csv
25
+ - config_name: social_media_marketplace
26
+ data_files: data/epharmacy_social_media_marketplace.csv
27
+ default: true
28
+ - config_name: rogue_website_darknet
29
+ data_files: data/epharmacy_rogue_website_darknet.csv
30
+ ---
31
+
32
+ # Online Pharmacy & E-Pharmacy Regulation Dataset
33
+
34
+ ## Abstract
35
+
36
+ **30,000 simulated online medicine purchase observations** (10,000 per scenario) across three e-pharmacy platform types. Variables include platform, product category, seller licensing, prescription verification, SF classification, price, payment method, and consumer demographics. Three scenarios: licensed e-pharmacy (6% SF), social media marketplace (65%), rogue website/darknet (89%).
37
+
38
+ **This dataset is entirely simulated. It must not be used for regulatory or enforcement decisions.**
39
+
40
+ ## Validation
41
+
42
+ <p align="center">
43
+ <img src="validation_report.png" alt="Validation Report" width="100%">
44
+ </p>
45
+
46
+ ## Usage
47
+
48
+ ```python
49
+ from datasets import load_dataset
50
+ dataset = load_dataset("electricsheepafrica/online-pharmacy-regulation", "social_media_marketplace")
51
+ df = dataset["train"].to_pandas()
52
+ print(df.groupby('platform_name')['quality_test_result'].apply(lambda x: (x=='fail').mean()))
53
+ ```
54
+
55
+ ## References
56
+
57
+ 1. WHO (2024). SF medicines sold online.
58
+ 2. NABP (2023). 95% of online pharmacies non-compliant.
59
+ 3. Interpol Operation Pangea. Illicit online pharmacy crackdowns.
60
+ 4. LegitScript. 30,000+ rogue pharmacy websites.
61
+
62
+ ## Citation
63
+
64
+ ```bibtex
65
+ @dataset{esa_epharmacy_2025,
66
+ title = {Online Pharmacy and E-Pharmacy Regulation Dataset},
67
+ author = {{Electric Sheep Africa}},
68
+ year = {2025},
69
+ publisher = {Hugging Face},
70
+ url = {https://huggingface.co/datasets/electricsheepafrica/online-pharmacy-regulation}
71
+ }
72
+ ```
73
+
74
+ ## License
75
+
76
+ [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/)
data/epharmacy_licensed_e_pharmacy.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/epharmacy_rogue_website_darknet.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/epharmacy_social_media_marketplace.csv ADDED
The diff for this file is too large to render. See raw diff
 
generate_dataset.py ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Literature-Informed Online Pharmacy & E-Pharmacy Regulation Dataset
4
+ =====================================================================
5
+
6
+ Each record = ONE online medicine purchase/listing assessed.
7
+
8
+ Sources (v2.0):
9
+ [1] WHO (2024). SF products increasingly sold online. Rise of
10
+ unauthorized e-pharmacy sites exacerbates SF problem.
11
+ [2] NABP (2023). 95% of online pharmacies globally do not comply
12
+ with pharmacy laws and practice standards.
13
+ [3] Interpol Operation Pangea. Annual crackdown on illicit online
14
+ pharmacies. 2022: 4,000+ websites shut down.
15
+ [4] LegitScript. ~30,000+ rogue pharmacy websites identified.
16
+ Most sell prescription medicines without prescriptions.
17
+ [5] WHO Africa (2023). E-pharmacy regulation nascent in SSA.
18
+ Only 5-10 countries have specific e-pharmacy legislation.
19
+ """
20
+
21
+ import numpy as np
22
+ import pandas as pd
23
+ import argparse
24
+ import os
25
+
26
+ PRODUCT_CATEGORIES = [
27
+ ('erectile_dysfunction', 'lifestyle', 0.15),
28
+ ('weight_loss', 'lifestyle', 0.10),
29
+ ('antibiotic', 'prescription', 0.12),
30
+ ('opioid_analgesic', 'controlled', 0.08),
31
+ ('benzodiazepine', 'controlled', 0.05),
32
+ ('antimalarial', 'essential', 0.08),
33
+ ('ARV_HIV', 'essential', 0.04),
34
+ ('antihypertensive', 'NCD', 0.06),
35
+ ('antidiabetic', 'NCD', 0.05),
36
+ ('contraceptive', 'reproductive', 0.04),
37
+ ('skin_lightening', 'cosmetic', 0.06),
38
+ ('COVID_treatment', 'pandemic', 0.03),
39
+ ('traditional_herbal', 'unregulated', 0.05),
40
+ ('supplement_vitamin', 'OTC', 0.05),
41
+ ('cancer_medicine', 'specialty', 0.04),
42
+ ]
43
+
44
+ SCENARIOS = {
45
+ 'licensed_e_pharmacy': {
46
+ 'platform_type': 'licensed_e_pharmacy',
47
+ 'sf_rate': 0.05,
48
+ 'falsified_rate': 0.01,
49
+ 'no_prescription_rate': 0.15,
50
+ 'unregistered_product_rate': 0.08,
51
+ 'regulatory_compliant': 0.85,
52
+ 'pharmacist_available': 0.90,
53
+ 'verified_supplier': 0.88,
54
+ 'delivery_cold_chain': 0.70,
55
+ 'consumer_complaint_rate': 0.03,
56
+ },
57
+ 'social_media_marketplace': {
58
+ 'platform_type': 'social_media',
59
+ 'sf_rate': 0.35,
60
+ 'falsified_rate': 0.15,
61
+ 'no_prescription_rate': 0.92,
62
+ 'unregistered_product_rate': 0.55,
63
+ 'regulatory_compliant': 0.02,
64
+ 'pharmacist_available': 0.05,
65
+ 'verified_supplier': 0.08,
66
+ 'delivery_cold_chain': 0.05,
67
+ 'consumer_complaint_rate': 0.20,
68
+ },
69
+ 'rogue_website_darknet': {
70
+ 'platform_type': 'rogue_website',
71
+ 'sf_rate': 0.65,
72
+ 'falsified_rate': 0.40,
73
+ 'no_prescription_rate': 0.99,
74
+ 'unregistered_product_rate': 0.85,
75
+ 'regulatory_compliant': 0.00,
76
+ 'pharmacist_available': 0.01,
77
+ 'verified_supplier': 0.02,
78
+ 'delivery_cold_chain': 0.01,
79
+ 'consumer_complaint_rate': 0.45,
80
+ },
81
+ }
82
+
83
+
84
+ def generate_dataset(n=10000, seed=42, scenario='social_media_marketplace'):
85
+ rng = np.random.default_rng(seed)
86
+ sc = SCENARIOS[scenario]
87
+ records = []
88
+ n_prod = len(PRODUCT_CATEGORIES)
89
+
90
+ for idx in range(n):
91
+ rec = {'id': idx + 1}
92
+ rec['platform_type'] = sc['platform_type']
93
+ rec['seller_id'] = f"EPHARM_{rng.integers(1, 1000):05d}"
94
+ rec['platform_name'] = rng.choice(
95
+ ['WhatsApp', 'Facebook', 'Instagram', 'Telegram', 'TikTok',
96
+ 'dedicated_website', 'marketplace_app', 'darknet_market'],
97
+ p=[0.10, 0.15, 0.10, 0.08, 0.05, 0.25, 0.15, 0.12]
98
+ if scenario == 'social_media_marketplace'
99
+ else ([0.02, 0.03, 0.02, 0.01, 0.01, 0.80, 0.10, 0.01]
100
+ if scenario == 'licensed_e_pharmacy'
101
+ else [0.03, 0.05, 0.03, 0.10, 0.02, 0.30, 0.07, 0.40]))
102
+
103
+ prod = PRODUCT_CATEGORIES[rng.choice(n_prod,
104
+ p=[p[2] for p in PRODUCT_CATEGORIES])]
105
+ rec['product_name'] = prod[0]
106
+ rec['product_category'] = prod[1]
107
+
108
+ rec['prescription_required_legally'] = 1 if prod[1] in (
109
+ 'prescription', 'controlled', 'essential', 'NCD', 'specialty') else 0
110
+ rec['prescription_verified'] = 0
111
+ if rec['prescription_required_legally']:
112
+ rec['prescription_verified'] = 0 if rng.random() < sc['no_prescription_rate'] else 1
113
+
114
+ rec['product_registered'] = 0 if rng.random() < sc['unregistered_product_rate'] else 1
115
+ rec['seller_licensed'] = 1 if rng.random() < sc['regulatory_compliant'] else 0
116
+ rec['pharmacist_consultation'] = 1 if rng.random() < sc['pharmacist_available'] else 0
117
+ rec['verified_supply_chain'] = 1 if rng.random() < sc['verified_supplier'] else 0
118
+ rec['cold_chain_maintained'] = 1 if rng.random() < sc['delivery_cold_chain'] else 0
119
+
120
+ rec['manufacturer_origin'] = rng.choice(
121
+ ['India', 'China', 'Europe', 'local_SSA', 'unknown', 'USA'],
122
+ p=[0.30, 0.20, 0.08, 0.07, 0.30, 0.05]
123
+ if scenario != 'licensed_e_pharmacy'
124
+ else [0.35, 0.10, 0.15, 0.15, 0.10, 0.15])
125
+
126
+ # SF determination
127
+ base_sf = sc['sf_rate']
128
+ if not rec['product_registered']:
129
+ base_sf *= 1.4
130
+ if not rec['verified_supply_chain']:
131
+ base_sf *= 1.3
132
+ if rec['manufacturer_origin'] == 'unknown':
133
+ base_sf *= 1.5
134
+ if prod[1] == 'controlled':
135
+ base_sf *= 1.3
136
+ if prod[1] == 'lifestyle':
137
+ base_sf *= 1.2
138
+ base_sf = np.clip(base_sf, 0.01, 0.90)
139
+
140
+ is_sf = rng.random() < base_sf
141
+ rec['quality_test_result'] = 'fail' if is_sf else 'pass'
142
+ rec['sf_classification'] = 'compliant'
143
+ if is_sf:
144
+ fals_prob = sc['falsified_rate'] / max(sc['sf_rate'], 0.001)
145
+ rec['sf_classification'] = 'falsified' if rng.random() < fals_prob else 'substandard'
146
+
147
+ rec['API_content_adequate'] = 1
148
+ if is_sf:
149
+ rec['API_content_adequate'] = 0 if rng.random() < 0.65 else 1
150
+
151
+ rec['price_vs_reference'] = round(np.clip(
152
+ rng.normal(0.40 if scenario == 'rogue_website_darknet' else
153
+ (0.70 if scenario == 'social_media_marketplace' else 0.90), 0.20),
154
+ 0.10, 2.0), 2)
155
+ rec['payment_method'] = rng.choice(
156
+ ['mobile_money', 'bank_transfer', 'cash_on_delivery',
157
+ 'cryptocurrency', 'credit_card'],
158
+ p=[0.35, 0.15, 0.30, 0.05, 0.15]
159
+ if scenario != 'rogue_website_darknet'
160
+ else [0.10, 0.10, 0.05, 0.50, 0.25])
161
+
162
+ rec['consumer_age_group'] = rng.choice(
163
+ ['18_24', '25_34', '35_49', '50_plus'],
164
+ p=[0.25, 0.35, 0.25, 0.15])
165
+ rec['consumer_education'] = rng.choice(
166
+ ['primary', 'secondary', 'tertiary'],
167
+ p=[0.15, 0.40, 0.45] if scenario != 'rogue_website_darknet'
168
+ else [0.05, 0.30, 0.65])
169
+ rec['consumer_complaint_filed'] = 1 if rng.random() < sc['consumer_complaint_rate'] else 0
170
+ rec['adverse_event_reported'] = 0
171
+ if is_sf:
172
+ rec['adverse_event_reported'] = 1 if rng.random() < 0.05 else 0
173
+
174
+ rec['website_takedown'] = 0
175
+ if scenario == 'rogue_website_darknet' and rng.random() < 0.03:
176
+ rec['website_takedown'] = 1
177
+ elif scenario == 'social_media_marketplace' and rng.random() < 0.01:
178
+ rec['website_takedown'] = 1
179
+
180
+ rec['year'] = rng.choice([2020, 2021, 2022, 2023, 2024],
181
+ p=[0.08, 0.12, 0.18, 0.28, 0.34])
182
+
183
+ records.append(rec)
184
+
185
+ df = pd.DataFrame(records)
186
+ sf_rate = df['quality_test_result'].eq('fail').mean() * 100
187
+ print(f"\n{'='*65}")
188
+ print(f"Online Pharmacy — {scenario} (n={n}, seed={seed})")
189
+ print(f"{'='*65}")
190
+ print(f" SF rate: {sf_rate:.1f}% (target ~{sc['sf_rate']*100:.0f}%)")
191
+ print(f" No prescription: {(1-df['prescription_verified'].mean())*100:.1f}%")
192
+ print(f" Licensed seller: {df['seller_licensed'].mean()*100:.1f}%")
193
+ return df
194
+
195
+
196
+ if __name__ == '__main__':
197
+ parser = argparse.ArgumentParser()
198
+ parser.add_argument('--all-scenarios', action='store_true')
199
+ parser.add_argument('--n', type=int, default=10000)
200
+ parser.add_argument('--seed', type=int, default=42)
201
+ args = parser.parse_args()
202
+ os.makedirs('data', exist_ok=True)
203
+ if args.all_scenarios:
204
+ for sc in SCENARIOS:
205
+ df = generate_dataset(n=args.n, seed=args.seed, scenario=sc)
206
+ df.to_csv(os.path.join('data', f'epharmacy_{sc}.csv'), index=False)
207
+ print(f" -> Saved\n")
208
+ else:
209
+ df = generate_dataset(n=args.n, seed=args.seed)
210
+ df.to_csv(os.path.join('data', 'epharmacy_social_media_marketplace.csv'), index=False)
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,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Validation & Diagnostic Visualization for Online Pharmacy & E-Pharmacy Regulation Dataset."""
3
+
4
+ import pandas as pd
5
+ import numpy as np
6
+ import matplotlib.pyplot as plt
7
+ import os
8
+
9
+ SCENARIOS = ['licensed_e_pharmacy', 'social_media_marketplace', 'rogue_website_darknet']
10
+
11
+
12
+ def load_scenarios(data_dir='data'):
13
+ dfs = {}
14
+ for sc in SCENARIOS:
15
+ path = os.path.join(data_dir, f'epharmacy_{sc}.csv')
16
+ if os.path.exists(path):
17
+ dfs[sc] = pd.read_csv(path)
18
+ return dfs
19
+
20
+
21
+ def make_report(dfs, output='validation_report.png'):
22
+ fig, axes = plt.subplots(4, 2, figsize=(16, 24))
23
+ fig.suptitle(
24
+ 'Online Pharmacy & E-Pharmacy Regulation — Validation Report\n'
25
+ '(Licensed E-Pharmacy → Social Media → Rogue/Darknet)',
26
+ fontsize=15, fontweight='bold', y=0.99)
27
+ colors = ['#2ecc71', '#f39c12', '#e74c3c']
28
+ x = np.arange(len(SCENARIOS))
29
+ labels = ['Licensed', 'Social Media', 'Rogue/Darknet']
30
+
31
+ ax = axes[0, 0]
32
+ sf = [dfs[sc]['quality_test_result'].eq('fail').mean()*100 for sc in SCENARIOS if sc in dfs]
33
+ ax.bar(x, sf, color=colors, alpha=0.8)
34
+ ax.set_xticks(x); ax.set_xticklabels(labels, fontsize=9)
35
+ for i, v in enumerate(sf):
36
+ ax.text(i, v+1, f'{v:.0f}%', ha='center', fontsize=10, fontweight='bold')
37
+ ax.set_ylabel('SF Rate (%)'); ax.set_title('SF Rate by Platform Type')
38
+
39
+ ax = axes[0, 1]
40
+ lic = [dfs[sc]['seller_licensed'].mean()*100 for sc in SCENARIOS if sc in dfs]
41
+ ax.bar(x, lic, color=colors, alpha=0.8)
42
+ ax.set_xticks(x); ax.set_xticklabels(labels, fontsize=9)
43
+ for i, v in enumerate(lic):
44
+ ax.text(i, v+1, f'{v:.0f}%', ha='center', fontsize=10, fontweight='bold')
45
+ ax.set_ylabel('Rate (%)'); ax.set_title('Seller Licensed')
46
+
47
+ ax = axes[1, 0]
48
+ df = dfs.get('social_media_marketplace', list(dfs.values())[1])
49
+ plat = df.groupby('platform_name')['quality_test_result'].apply(
50
+ lambda x: (x == 'fail').mean()*100).sort_values()
51
+ ax.barh(range(len(plat)), plat.values, color='#e74c3c', alpha=0.7)
52
+ ax.set_yticks(range(len(plat)))
53
+ ax.set_yticklabels([s.replace('_', ' ').title() for s in plat.index], fontsize=7)
54
+ ax.set_xlabel('SF Rate (%)'); ax.set_title('SF by Platform (Social Media)')
55
+
56
+ ax = axes[1, 1]
57
+ cat = df.groupby('product_category')['quality_test_result'].apply(
58
+ lambda x: (x == 'fail').mean()*100).sort_values()
59
+ ax.barh(range(len(cat)), cat.values, color='#9b59b6', alpha=0.7)
60
+ ax.set_yticks(range(len(cat)))
61
+ ax.set_yticklabels([s.replace('_', ' ').title() for s in cat.index], fontsize=8)
62
+ ax.set_xlabel('SF Rate (%)'); ax.set_title('SF by Product Category')
63
+
64
+ ax = axes[2, 0]
65
+ norx = [(1-dfs[sc]['prescription_verified'].mean())*100 for sc in SCENARIOS if sc in dfs]
66
+ ax.bar(x, norx, color=colors, alpha=0.8)
67
+ ax.set_xticks(x); ax.set_xticklabels(labels, fontsize=9)
68
+ for i, v in enumerate(norx):
69
+ ax.text(i, v+0.5, f'{v:.0f}%', ha='center', fontsize=10, fontweight='bold')
70
+ ax.set_ylabel('Rate (%)'); ax.set_title('No Prescription Verified')
71
+
72
+ ax = axes[2, 1]
73
+ price = df['price_vs_reference'].values
74
+ ax.hist(price, bins=30, color='#3498db', alpha=0.7, edgecolor='white')
75
+ ax.axvline(x=1.0, color='red', linestyle='--', label='Reference price')
76
+ ax.set_xlabel('Price vs Reference'); ax.set_title('Price Distribution (Social Media)')
77
+ ax.legend(fontsize=8)
78
+
79
+ ax = axes[3, 0]
80
+ w = 0.35
81
+ fals = [dfs[sc]['sf_classification'].eq('falsified').mean()*100 for sc in SCENARIOS if sc in dfs]
82
+ subs = [dfs[sc]['sf_classification'].eq('substandard').mean()*100 for sc in SCENARIOS if sc in dfs]
83
+ ax.bar(x - w/2, subs, w, label='Substandard', color='#f39c12', alpha=0.8)
84
+ ax.bar(x + w/2, fals, w, label='Falsified', color='#e74c3c', alpha=0.8)
85
+ ax.set_xticks(x); ax.set_xticklabels(labels, fontsize=9)
86
+ ax.set_ylabel('Rate (%)'); ax.set_title('Substandard vs Falsified'); ax.legend(fontsize=8)
87
+
88
+ ax = axes[3, 1]
89
+ comp = [dfs[sc]['consumer_complaint_filed'].mean()*100 for sc in SCENARIOS if sc in dfs]
90
+ ax.bar(x, comp, color=colors, alpha=0.8)
91
+ ax.set_xticks(x); ax.set_xticklabels(labels, fontsize=9)
92
+ for i, v in enumerate(comp):
93
+ ax.text(i, v+0.3, f'{v:.1f}%', ha='center', fontsize=10, fontweight='bold')
94
+ ax.set_ylabel('Rate (%)'); ax.set_title('Consumer Complaints Filed')
95
+
96
+ plt.tight_layout(rect=[0, 0, 1, 0.97])
97
+ plt.savefig(output, dpi=150, bbox_inches='tight')
98
+ print(f'Saved validation report to {output}')
99
+ plt.close()
100
+
101
+
102
+ if __name__ == '__main__':
103
+ dfs = load_scenarios()
104
+ if dfs:
105
+ make_report(dfs)
validation_report.png ADDED

Git LFS Details

  • SHA256: 829ebbd9db43b61e92e4e4457ae71d8f9df6a5842820de07a99d6487e9fa5f65
  • Pointer size: 131 Bytes
  • Size of remote file: 263 kB