Kossisoroyce commited on
Commit
06881dd
·
verified ·
1 Parent(s): 5c3859a

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ task_categories:
4
+ - tabular-classification
5
+ language:
6
+ - en
7
+ tags:
8
+ - healthcare
9
+ - obstetric-fistula
10
+ - vesicovaginal-fistula
11
+ - obstructed-labour
12
+ - maternal-health
13
+ - sub-saharan-africa
14
+ - lmic
15
+ pretty_name: "Obstetric Fistula (VVF/RVF, Repair, Social Consequences, Outcomes)"
16
+ size_categories:
17
+ - 10K<n<100K
18
+ configs:
19
+ - config_name: specialized_fistula_centre
20
+ data_files: data/fistula_specialized_fistula_centre.csv
21
+ - config_name: district_hospital
22
+ data_files: data/fistula_district_hospital.csv
23
+ default: true
24
+ - config_name: no_surgical_access
25
+ data_files: data/fistula_no_surgical_access.csv
26
+ ---
27
+
28
+ # Obstetric Fistula Dataset
29
+
30
+ ## Abstract
31
+
32
+ This dataset provides **30,000 simulated obstetric fistula patient records** (10,000 per scenario) from sub-Saharan Africa. Each record contains 50+ variables including demographics, obstetric history, fistula characteristics, social consequences, surgical repair, rehabilitation, and outcomes. Three settings: specialized fistula centre (76% repair success), district hospital (59%), and no surgical access (0%).
33
+
34
+ ## 1. Introduction
35
+
36
+ Obstetric fistula — a hole between the birth canal and bladder/rectum — is caused by prolonged, obstructed labour without timely EmONC. SSA has 50% of the global burden with 50,000-100,000 new cases annually (UNFPA 2024). Consequences include urinary/faecal incontinence, social isolation, divorce, depression, and economic devastation. Repair success is 85-90% at specialized centres, but most women lack access. Child marriage and short stature are key risk factors.
37
+
38
+ **This dataset is entirely simulated. It must not be used for clinical decision-making.**
39
+
40
+ ## 2. Methodology
41
+
42
+ ### 2.1 Parameterization
43
+
44
+ | Parameter | Value | Source |
45
+ | --- | --- | --- |
46
+ | SSA share of global burden | 50% | UNFPA 2024 |
47
+ | VVF type | 80% | UNFPA |
48
+ | Stillbirth rate | ~70% | PubMed 2018 |
49
+ | Repair success (specialist) | 85-90% | PMC 2024 |
50
+ | Divorce/separation | ~55% | UNFPA 2024 |
51
+ | Depression | ~60% | UNFPA |
52
+ | Child marriage risk | Major factor | PubMed 1999 |
53
+
54
+ ### 2.2 Scenario Design
55
+
56
+ | Scenario | Repair | Specialist | Physio | Success |
57
+ | --- | --- | --- | --- | --- |
58
+ | Specialized centre | Yes | Yes | Yes | 76% |
59
+ | District hospital | Yes | No | No | 59% |
60
+ | No surgical access | No | No | No | 0% |
61
+
62
+ ## 3. Schema
63
+
64
+ | Column | Type | Description |
65
+ | --- | --- | --- |
66
+ | id | int | Unique identifier |
67
+ | age_at_presentation | int | Age at presentation |
68
+ | age_at_fistula_onset | int | Age when fistula developed |
69
+ | years_living_with_fistula | int | Duration before treatment |
70
+ | child_marriage | binary | Married <18 |
71
+ | fistula_type | categorical | vesicovaginal / rectovaginal / combined |
72
+ | fistula_size | categorical | small / medium / large / extensive |
73
+ | obstructed_labour | binary | Obstructed labour |
74
+ | stillbirth | binary | Stillbirth in index pregnancy |
75
+ | divorced_separated | binary | Divorced/separated |
76
+ | social_isolation | binary | Social isolation |
77
+ | depression | binary | Depression |
78
+ | repair_performed | binary | Surgical repair done |
79
+ | repair_successful | binary | Repair successful |
80
+ | residual_incontinence | binary | Residual incontinence |
81
+ | continence_at_3_months | binary | Continent at 3 months |
82
+ | returned_to_community | binary | Community reintegration |
83
+
84
+ ## 4. Validation
85
+
86
+ <p align="center">
87
+ <img src="validation_report.png" alt="Validation Report" width="100%">
88
+ </p>
89
+
90
+ Key validation checks:
91
+
92
+ - **VVF**: 80% of fistula types ✓
93
+ - **Stillbirth**: ~70% ✓
94
+ - **Repair success gradient**: 76% → 59% → 0% ✓
95
+ - **Social consequences**: >50% divorced, >60% depressed ✓
96
+ - **Obstructed labour**: Major cause ✓
97
+ - **Success decreases with fistula size** ✓
98
+
99
+ ## 5. Usage
100
+
101
+ ```python
102
+ from datasets import load_dataset
103
+ dataset = load_dataset("electricsheepafrica/obstetric-fistula", "district_hospital")
104
+ df = dataset["train"].to_pandas()
105
+ ```
106
+
107
+ ## 6. Limitations
108
+
109
+ - **Simulated**: Not from real fistula registries.
110
+ - **No urodynamic data**: No bladder pressure studies.
111
+ - **No imaging**: No fistulogram data.
112
+ - **Simplified**: No detailed surgical notes.
113
+ - **Cross-sectional**: No long-term follow-up trajectory.
114
+
115
+ ## 7. References
116
+
117
+ 1. UNFPA (2024). Obstetric fistula factsheet.
118
+ 2. UNFPA WCARO (2024). Fistula burden in West/Central Africa.
119
+ 3. PMC (2024). Fistula repair failure in SSA.
120
+ 4. PubMed (1999). Sociomedical risk factors for VVF.
121
+ 5. PubMed (2018). VVF in Uganda — Kitovu Hospital.
122
+ 6. PubMed (2024). Systematic review repair outcomes LMICs.
123
+
124
+ ## Citation
125
+
126
+ ```bibtex
127
+ @dataset{esa_obstetric_fistula_2025,
128
+ title={Obstetric Fistula Dataset},
129
+ author={Electric Sheep Africa},
130
+ year={2025},
131
+ publisher={Hugging Face},
132
+ url={https://huggingface.co/datasets/electricsheepafrica/obstetric-fistula}
133
+ }
134
+ ```
135
+
136
+ ## License
137
+
138
+ [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/)
data/fistula_district_hospital.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/fistula_no_surgical_access.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/fistula_specialized_fistula_centre.csv ADDED
The diff for this file is too large to render. See raw diff
 
generate_dataset.py ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Literature-Informed Obstetric Fistula Dataset
4
+ ==============================================
5
+
6
+ Generates realistic synthetic records of obstetric fistula patients
7
+ in sub-Saharan Africa, including risk factors, fistula characteristics,
8
+ social consequences, surgical repair, and outcomes.
9
+
10
+ References (web-searched):
11
+ -----------
12
+ [1] UNFPA 2024. Obstetric fistula caused by prolonged
13
+ obstructed labour without timely EmONC. SSA has 50%
14
+ of global burden. 50K-100K new cases/year.
15
+ [2] UNFPA WCARO 2024. West/Central Africa highest rates.
16
+ Social isolation, divorce, depression common.
17
+ [3] PMC 2024. Fistula repair failure in SSA. Repair
18
+ success 85-90% at specialized centres.
19
+ [4] PubMed 1999. Early marriage, young adolescents,
20
+ premature pregnancy → VVF. Sociomedical risk factors.
21
+ [5] PubMed 2018. Kitovu Hospital Uganda, highest fistula
22
+ rates globally. Incidence and causative factors.
23
+ [6] PubMed 2024. Systematic review repair outcomes.
24
+ Proportions of successful repair in LMICs.
25
+ """
26
+
27
+ import numpy as np
28
+ import pandas as pd
29
+ import argparse
30
+ import os
31
+
32
+ SCENARIOS = {
33
+ 'specialized_fistula_centre': {
34
+ 'description': 'Dedicated fistula repair centre with '
35
+ 'trained surgeon, physiotherapy, social '
36
+ 'support (e.g., Addis Ababa Fistula Hospital, '
37
+ 'Kitovu Uganda)',
38
+ 'repair_available': True,
39
+ 'specialist_surgeon': True,
40
+ 'physiotherapy': True,
41
+ 'social_support': True,
42
+ 'repair_success': 0.90,
43
+ },
44
+ 'district_hospital': {
45
+ 'description': 'District hospital with visiting fistula '
46
+ 'surgeon, basic repair capability, limited '
47
+ 'follow-up (e.g., district hospitals DRC, '
48
+ 'Malawi, Tanzania)',
49
+ 'repair_available': True,
50
+ 'specialist_surgeon': False,
51
+ 'physiotherapy': False,
52
+ 'social_support': False,
53
+ 'repair_success': 0.70,
54
+ },
55
+ 'no_surgical_access': {
56
+ 'description': 'Rural community with no surgical access, '
57
+ 'traditional remedies, referral barriers '
58
+ '(e.g., rural Niger, Chad, South Sudan)',
59
+ 'repair_available': False,
60
+ 'specialist_surgeon': False,
61
+ 'physiotherapy': False,
62
+ 'social_support': False,
63
+ 'repair_success': 0.0,
64
+ },
65
+ }
66
+
67
+
68
+ def generate_dataset(n=10000, seed=42, scenario='district_hospital'):
69
+ rng = np.random.default_rng(seed)
70
+ sc = SCENARIOS[scenario]
71
+
72
+ records = []
73
+
74
+ for idx in range(n):
75
+ rec = {'id': idx + 1}
76
+
77
+ # ── 1. Demographics ──
78
+ rec['age_at_presentation'] = max(14, min(65, int(rng.normal(28, 8))))
79
+ rec['age_at_fistula_onset'] = max(13, min(rec['age_at_presentation'],
80
+ int(rng.normal(20, 5))))
81
+ rec['years_living_with_fistula'] = max(0,
82
+ rec['age_at_presentation'] - rec['age_at_fistula_onset'])
83
+ rec['age_at_marriage'] = max(10, min(30, int(rng.normal(16, 3))))
84
+ rec['child_marriage'] = 1 if rec['age_at_marriage'] < 18 else 0
85
+ rec['age_at_first_pregnancy'] = max(rec['age_at_marriage'],
86
+ min(35, int(rng.normal(17, 3))))
87
+ rec['education'] = rng.choice(
88
+ ['none', 'primary', 'secondary', 'tertiary'],
89
+ p=[0.45, 0.35, 0.15, 0.05])
90
+ rec['rural'] = 1 if rng.random() < 0.80 else 0
91
+ rec['parity'] = max(0, min(12, int(rng.exponential(2.5))))
92
+ rec['height_cm'] = max(140, min(180, int(rng.normal(157, 6))))
93
+ rec['short_stature'] = 1 if rec['height_cm'] < 150 else 0
94
+ rec['bmi'] = round(max(14, min(35, rng.normal(20, 3))), 1)
95
+
96
+ # ── 2. Obstetric history ──
97
+ rec['labour_duration_hours'] = max(6, min(120, int(rng.exponential(24) + 12)))
98
+ rec['prolonged_labour'] = 1 if rec['labour_duration_hours'] > 24 else 0
99
+ rec['obstructed_labour'] = 1 if rec['labour_duration_hours'] > 18 and rng.random() < 0.85 else 0
100
+ rec['caesarean_performed'] = 0
101
+ if rec['obstructed_labour']:
102
+ rec['caesarean_performed'] = 1 if rng.random() < 0.15 else 0
103
+ rec['skilled_birth_attendant'] = 1 if rng.random() < 0.20 else 0
104
+ rec['place_of_delivery'] = rng.choice(
105
+ ['home', 'health_centre', 'hospital'],
106
+ p=[0.60, 0.25, 0.15])
107
+ rec['stillbirth'] = 1 if rng.random() < 0.70 else 0
108
+ rec['neonatal_death'] = 0
109
+ if not rec['stillbirth']:
110
+ rec['neonatal_death'] = 1 if rng.random() < 0.15 else 0
111
+
112
+ # ── 3. Fistula characteristics ──
113
+ rec['fistula_type'] = rng.choice(
114
+ ['vesicovaginal', 'rectovaginal', 'combined'],
115
+ p=[0.80, 0.10, 0.10])
116
+ rec['fistula_size'] = rng.choice(
117
+ ['small', 'medium', 'large', 'extensive'],
118
+ p=[0.20, 0.35, 0.30, 0.15])
119
+ rec['urethral_involvement'] = 1 if rng.random() < 0.25 else 0
120
+ rec['circumferential_defect'] = 1 if rec['fistula_size'] == 'extensive' and rng.random() < 0.40 else 0
121
+ rec['scarring_severity'] = rng.choice(
122
+ ['mild', 'moderate', 'severe'],
123
+ p=[0.25, 0.40, 0.35])
124
+ rec['vaginal_stenosis'] = 1 if rec['scarring_severity'] == 'severe' and rng.random() < 0.40 else 0
125
+ rec['foot_drop'] = 1 if rec['prolonged_labour'] and rng.random() < 0.10 else 0
126
+
127
+ # ── 4. Social consequences [1][2] ──
128
+ rec['divorced_separated'] = 1 if rng.random() < 0.55 else 0
129
+ rec['social_isolation'] = 1 if rng.random() < 0.65 else 0
130
+ rec['depression'] = 1 if rng.random() < 0.60 else 0
131
+ rec['anxiety'] = 1 if rng.random() < 0.45 else 0
132
+ rec['economic_impact'] = rng.choice(
133
+ ['none', 'mild', 'severe'],
134
+ p=[0.10, 0.30, 0.60])
135
+ rec['unable_to_work'] = 1 if rng.random() < 0.50 else 0
136
+ rec['skin_excoriation'] = 1 if rng.random() < 0.70 else 0
137
+ rec['recurrent_uti'] = 1 if rng.random() < 0.50 else 0
138
+ rec['malodour'] = 1 if rng.random() < 0.80 else 0
139
+
140
+ # ── 5. Care seeking ──
141
+ rec['delay_to_presentation_years'] = rec['years_living_with_fistula']
142
+ rec['previous_repair_attempts'] = max(0, min(5, int(rng.exponential(0.5))))
143
+ rec['traditional_remedy_tried'] = 1 if rng.random() < 0.35 else 0
144
+ rec['barrier_to_care'] = rng.choice(
145
+ ['cost', 'distance', 'awareness', 'stigma', 'no_service', 'none'],
146
+ p=[0.20, 0.20, 0.15, 0.15, 0.20, 0.10])
147
+ rec['referred_by'] = rng.choice(
148
+ ['self', 'ngo', 'health_worker', 'community', 'media'],
149
+ p=[0.30, 0.25, 0.20, 0.15, 0.10])
150
+
151
+ # ── 6. Surgical repair [3][6] ──
152
+ rec['repair_performed'] = 0
153
+ if sc['repair_available']:
154
+ rec['repair_performed'] = 1 if rng.random() < 0.85 else 0
155
+
156
+ rec['repair_technique'] = 'none'
157
+ if rec['repair_performed']:
158
+ rec['repair_technique'] = rng.choice(
159
+ ['transvaginal', 'transabdominal', 'combined'],
160
+ p=[0.75, 0.15, 0.10])
161
+
162
+ rec['graft_used'] = 0
163
+ if rec['repair_performed'] and rec['fistula_size'] in ('large', 'extensive'):
164
+ rec['graft_used'] = 1 if rng.random() < 0.20 else 0
165
+
166
+ rec['catheter_days'] = 0
167
+ if rec['repair_performed']:
168
+ rec['catheter_days'] = max(7, min(28, int(rng.normal(14, 3))))
169
+
170
+ rec['repair_successful'] = 0
171
+ if rec['repair_performed']:
172
+ success_prob = sc['repair_success']
173
+ if rec['fistula_size'] == 'extensive':
174
+ success_prob *= 0.60
175
+ elif rec['fistula_size'] == 'large':
176
+ success_prob *= 0.80
177
+ if rec['previous_repair_attempts'] > 0:
178
+ success_prob *= 0.85
179
+ if rec['circumferential_defect']:
180
+ success_prob *= 0.50
181
+ rec['repair_successful'] = 1 if rng.random() < success_prob else 0
182
+
183
+ rec['residual_incontinence'] = 0
184
+ if rec['repair_successful']:
185
+ rec['residual_incontinence'] = 1 if rng.random() < 0.15 else 0
186
+
187
+ rec['complication_post_repair'] = 0
188
+ if rec['repair_performed']:
189
+ rec['complication_post_repair'] = 1 if rng.random() < 0.10 else 0
190
+
191
+ # ── 7. Rehabilitation ──
192
+ rec['physiotherapy_received'] = 0
193
+ if rec['repair_performed'] and sc['physiotherapy']:
194
+ rec['physiotherapy_received'] = 1 if rng.random() < 0.70 else 0
195
+
196
+ rec['social_reintegration_support'] = 0
197
+ if rec['repair_performed'] and sc['social_support']:
198
+ rec['social_reintegration_support'] = 1 if rng.random() < 0.60 else 0
199
+
200
+ rec['livelihood_support'] = 0
201
+ if rec['social_reintegration_support']:
202
+ rec['livelihood_support'] = 1 if rng.random() < 0.40 else 0
203
+
204
+ rec['continence_at_3_months'] = 0
205
+ if rec['repair_successful'] and not rec['residual_incontinence']:
206
+ rec['continence_at_3_months'] = 1 if rng.random() < 0.90 else 0
207
+
208
+ rec['returned_to_community'] = 0
209
+ if rec['repair_successful']:
210
+ rec['returned_to_community'] = 1 if rng.random() < 0.75 else 0
211
+
212
+ records.append(rec)
213
+
214
+ df = pd.DataFrame(records)
215
+
216
+ print(f"\n{'='*65}")
217
+ print(f"Obstetric Fistula — {scenario} (n={n}, seed={seed})")
218
+ print(f"{'='*65}")
219
+ print(f"\n Repair performed: {df['repair_performed'].mean()*100:.1f}%")
220
+ print(f" Repair success: {df[df['repair_performed']==1]['repair_successful'].mean()*100:.1f}%" if df['repair_performed'].sum() > 0 else " No repairs")
221
+ print(f" Stillbirth: {df['stillbirth'].mean()*100:.1f}%")
222
+ print(f" Divorced: {df['divorced_separated'].mean()*100:.1f}%")
223
+ print(f" Depression: {df['depression'].mean()*100:.1f}%")
224
+ print(f" Mean years with fistula: {df['years_living_with_fistula'].mean():.1f}")
225
+
226
+ return df
227
+
228
+
229
+ if __name__ == '__main__':
230
+ parser = argparse.ArgumentParser(
231
+ description='Generate obstetric fistula dataset')
232
+ parser.add_argument('--scenario', type=str, default='district_hospital',
233
+ choices=list(SCENARIOS.keys()))
234
+ parser.add_argument('--n', type=int, default=10000)
235
+ parser.add_argument('--seed', type=int, default=42)
236
+ parser.add_argument('--output', type=str, default=None)
237
+ parser.add_argument('--all-scenarios', action='store_true')
238
+ args = parser.parse_args()
239
+
240
+ os.makedirs('data', exist_ok=True)
241
+
242
+ if args.all_scenarios:
243
+ for sc_name in SCENARIOS:
244
+ df = generate_dataset(n=args.n, seed=args.seed, scenario=sc_name)
245
+ out = os.path.join('data', f'fistula_{sc_name}.csv')
246
+ df.to_csv(out, index=False)
247
+ print(f" -> Saved to {out}\n")
248
+ else:
249
+ df = generate_dataset(n=args.n, seed=args.seed, scenario=args.scenario)
250
+ out = args.output or os.path.join('data', f'fistula_{args.scenario}.csv')
251
+ df.to_csv(out, index=False)
252
+ print(f" -> Saved to {out}")
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,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Validation & Diagnostic Visualization for Obstetric Fistula Dataset."""
3
+
4
+ import pandas as pd
5
+ import numpy as np
6
+ import matplotlib.pyplot as plt
7
+ import os
8
+
9
+ SCENARIOS = ['specialized_fistula_centre', 'district_hospital', 'no_surgical_access']
10
+
11
+
12
+ def load_scenarios(data_dir='data'):
13
+ dfs = {}
14
+ for sc in SCENARIOS:
15
+ path = os.path.join(data_dir, f'fistula_{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, 22))
23
+ fig.suptitle('Obstetric Fistula — Validation Report',
24
+ fontsize=16, fontweight='bold', y=0.98)
25
+ df = dfs.get('district_hospital', list(dfs.values())[0])
26
+ colors = ['#2ecc71', '#f39c12', '#e74c3c']
27
+
28
+ ax = axes[0, 0]
29
+ x = np.arange(len(SCENARIOS))
30
+ repair = [dfs[sc]['repair_performed'].mean()*100 for sc in SCENARIOS if sc in dfs]
31
+ success = []
32
+ for sc in SCENARIOS:
33
+ if sc in dfs:
34
+ d = dfs[sc]
35
+ rep = d[d['repair_performed'] == 1]
36
+ success.append(rep['repair_successful'].mean()*100 if len(rep) > 0 else 0)
37
+ w = 0.3
38
+ ax.bar(x - w/2, repair, w, label='Repair Performed', color='#3498db', alpha=0.8)
39
+ ax.bar(x + w/2, success, w, label='Repair Success', color='#2ecc71', alpha=0.8)
40
+ ax.set_xticks(x)
41
+ ax.set_xticklabels(['Specialist', 'District', 'No Access'], fontsize=9)
42
+ ax.set_ylabel('Rate (%)')
43
+ ax.set_title('Repair Access & Success (85-90% at specialist)')
44
+ ax.legend(fontsize=8)
45
+
46
+ ax = axes[0, 1]
47
+ ft = df['fistula_type'].value_counts()
48
+ c_colors = ['#e74c3c', '#f39c12', '#9b59b6']
49
+ ax.pie(ft.values,
50
+ labels=[s.replace('_', ' ').upper() for s in ft.index],
51
+ autopct='%1.0f%%', colors=c_colors[:len(ft)],
52
+ startangle=90, textprops={'fontsize': 9})
53
+ ax.set_title('Fistula Type (VVF = 80%)')
54
+
55
+ ax = axes[1, 0]
56
+ social = ['divorced_separated', 'social_isolation', 'depression',
57
+ 'unable_to_work', 'skin_excoriation', 'malodour']
58
+ s_labels = ['Divorced', 'Isolated', 'Depression', 'Unable Work', 'Excoriation', 'Malodour']
59
+ vals = [df[s].mean()*100 for s in social]
60
+ ax.barh(range(6), vals, color='#9b59b6', alpha=0.7)
61
+ ax.set_yticks(range(6))
62
+ ax.set_yticklabels(s_labels, fontsize=9)
63
+ for i, v in enumerate(vals):
64
+ ax.text(v + 0.5, i, f'{v:.0f}%', va='center', fontsize=9)
65
+ ax.set_xlabel('Prevalence (%)')
66
+ ax.set_title('Social Consequences (devastating)')
67
+
68
+ ax = axes[1, 1]
69
+ ax.hist(df['years_living_with_fistula'], bins=20, color='#e74c3c',
70
+ alpha=0.7, edgecolor='white')
71
+ ax.set_xlabel('Years Living with Fistula')
72
+ ax.set_title('Duration Before Presentation')
73
+
74
+ ax = axes[2, 0]
75
+ risks = ['child_marriage', 'short_stature', 'prolonged_labour',
76
+ 'obstructed_labour', 'stillbirth']
77
+ r_labels = ['Child Marriage', 'Short Stature', 'Prolonged Labour',
78
+ 'Obstructed Labour', 'Stillbirth']
79
+ vals = [df[r].mean()*100 for r in risks]
80
+ ax.bar(range(5), vals, color=['#e74c3c', '#f39c12', '#9b59b6', '#3498db', '#e67e22'], alpha=0.8)
81
+ ax.set_xticks(range(5))
82
+ ax.set_xticklabels(r_labels, fontsize=7, rotation=15)
83
+ for i, v in enumerate(vals):
84
+ ax.text(i, v + 0.5, f'{v:.0f}%', ha='center', fontsize=8)
85
+ ax.set_ylabel('Prevalence (%)')
86
+ ax.set_title('Risk Factors (obstructed labour = key cause)')
87
+
88
+ ax = axes[2, 1]
89
+ barriers = df[df['barrier_to_care'] != 'none']['barrier_to_care'].value_counts()
90
+ if len(barriers) > 0:
91
+ ax.barh(range(len(barriers)), barriers.values, color='#3498db', alpha=0.8)
92
+ ax.set_yticks(range(len(barriers)))
93
+ ax.set_yticklabels([s.replace('_', ' ').title() for s in barriers.index], fontsize=9)
94
+ ax.set_xlabel('Count')
95
+ ax.set_title('Barriers to Care')
96
+
97
+ ax = axes[3, 0]
98
+ sizes = ['small', 'medium', 'large', 'extensive']
99
+ rep_d = df[df['repair_performed'] == 1]
100
+ if len(rep_d) > 0:
101
+ size_success = []
102
+ for sz in sizes:
103
+ sz_d = rep_d[rep_d['fistula_size'] == sz]
104
+ size_success.append(sz_d['repair_successful'].mean()*100 if len(sz_d) > 0 else 0)
105
+ ax.bar(range(4), size_success,
106
+ color=['#2ecc71', '#f39c12', '#e74c3c', '#9b59b6'], alpha=0.8)
107
+ ax.set_xticks(range(4))
108
+ ax.set_xticklabels(sizes, fontsize=9)
109
+ for i, v in enumerate(size_success):
110
+ ax.text(i, v + 1, f'{v:.0f}%', ha='center', fontsize=9)
111
+ ax.set_ylabel('Success Rate (%)')
112
+ ax.set_title('Repair Success by Fistula Size')
113
+
114
+ ax = axes[3, 1]
115
+ ax.hist(df['age_at_fistula_onset'], bins=20, color='#f39c12',
116
+ alpha=0.7, edgecolor='white', label='Onset')
117
+ ax.hist(df['age_at_presentation'], bins=20, color='#3498db',
118
+ alpha=0.5, edgecolor='white', label='Presentation')
119
+ ax.set_xlabel('Age (years)')
120
+ ax.set_title('Age at Onset vs Presentation')
121
+ ax.legend(fontsize=8)
122
+
123
+ plt.tight_layout(rect=[0, 0, 1, 0.97])
124
+ plt.savefig(output, dpi=150, bbox_inches='tight')
125
+ print(f'Saved validation report to {output}')
126
+ plt.close()
127
+
128
+
129
+ if __name__ == '__main__':
130
+ dfs = load_scenarios()
131
+ if dfs:
132
+ make_report(dfs)
validation_report.png ADDED

Git LFS Details

  • SHA256: 26e38de5c9f6cd60f1c800e07923958bae7d9bdb706351f45d25fffd2fa061b1
  • Pointer size: 131 Bytes
  • Size of remote file: 301 kB