| |
| """ |
| Literature-Informed Oral Health & Dental Disease Dataset |
| ========================================================= |
| |
| Generates realistic synthetic records of oral health patients in |
| sub-Saharan Africa, including dental caries, periodontal disease, |
| noma, oral cancer, treatment access, and outcomes. |
| |
| References (web-searched): |
| ----------- |
| [1] WHO Africa 2024. Africa has largest global increase in |
| oral diseases. 6 major conditions: caries, periodontal, |
| oral cancer, oral HIV, noma, cleft lip/palate. |
| [2] WHO 2022. Global Oral Health Status Report. Untreated |
| caries is most prevalent condition globally. |
| [3] PubMed 2021. DMFT in East Africa: 2.57 at age 12, |
| 4.04 at age 15. High caries burden. |
| [4] BMC Public Health 2021. Dental caries in adults SSA. |
| Limited access to dental care. |
| [5] WHO Africa. Noma (cancrum oris) persists in extreme |
| poverty. CFR 70-90% untreated. Disfiguring. |
| [6] PubMed 2015. Oral health South Africa: DMFT trends, |
| national surveys, fluoride. |
| [7] Dentist ratio in SSA: <1 per 100,000 population in |
| many countries. WHO target 1:7500. |
| """ |
|
|
| import numpy as np |
| import pandas as pd |
| import argparse |
| import os |
|
|
| SCENARIOS = { |
| 'dental_clinic': { |
| 'description': 'Urban dental clinic with dentist, basic ' |
| 'restorative/extraction capability, X-ray ' |
| '(e.g., university dental clinics Nairobi, ' |
| 'Lagos, Addis Ababa)', |
| 'dentist_available': True, |
| 'restorative_available': True, |
| 'xray_available': True, |
| 'fluoride_programme': True, |
| 'treatment_mod': 1.0, |
| }, |
| 'district_hospital': { |
| 'description': 'District hospital with dental officer, ' |
| 'extraction only, no restorative ' |
| '(e.g., district hospitals Tanzania, Malawi)', |
| 'dentist_available': True, |
| 'restorative_available': False, |
| 'xray_available': False, |
| 'fluoride_programme': False, |
| 'treatment_mod': 0.6, |
| }, |
| 'rural_health_centre': { |
| 'description': 'Rural health centre, no dental professional, ' |
| 'basic pain relief, referral ' |
| '(e.g., rural CHCs DRC, Niger, Chad)', |
| 'dentist_available': False, |
| 'restorative_available': False, |
| 'xray_available': False, |
| 'fluoride_programme': False, |
| 'treatment_mod': 0.2, |
| }, |
| } |
|
|
|
|
| def generate_dataset(n=10000, seed=42, scenario='district_hospital'): |
| rng = np.random.default_rng(seed) |
| sc = SCENARIOS[scenario] |
|
|
| records = [] |
|
|
| for idx in range(n): |
| rec = {'id': idx + 1} |
|
|
| |
| rec['age_years'] = max(2, min(80, int(rng.normal(28, 18)))) |
| rec['sex'] = rng.choice(['M', 'F'], p=[0.48, 0.52]) |
| rec['child'] = 1 if rec['age_years'] < 18 else 0 |
| rec['education'] = rng.choice( |
| ['none', 'primary', 'secondary', 'tertiary'], |
| p=[0.20, 0.35, 0.35, 0.10]) |
| rec['urban'] = 1 if rng.random() < 0.40 else 0 |
|
|
| |
| rec['tobacco_use'] = 0 |
| if rec['age_years'] >= 15: |
| rec['tobacco_use'] = 1 if rng.random() < 0.12 else 0 |
| rec['sugary_diet'] = 1 if rng.random() < 0.55 else 0 |
| rec['fluoride_toothpaste'] = 1 if rng.random() < (0.50 if rec['urban'] else 0.20) else 0 |
| rec['brushing_frequency'] = rng.choice( |
| ['never', 'occasional', 'once_daily', 'twice_daily'], |
| p=[0.15, 0.25, 0.40, 0.20]) |
| rec['hiv_positive'] = 1 if rng.random() < 0.06 else 0 |
| rec['diabetes'] = 0 |
| if rec['age_years'] >= 30: |
| rec['diabetes'] = 1 if rng.random() < 0.08 else 0 |
| rec['malnutrition'] = 0 |
| if rec['child']: |
| rec['malnutrition'] = 1 if rng.random() < 0.15 else 0 |
|
|
| |
| caries_prob = 0.40 |
| if rec['sugary_diet']: |
| caries_prob += 0.15 |
| if rec['brushing_frequency'] in ('never', 'occasional'): |
| caries_prob += 0.10 |
| if not rec['fluoride_toothpaste']: |
| caries_prob += 0.05 |
| rec['dental_caries'] = 1 if rng.random() < min(caries_prob, 0.80) else 0 |
|
|
| rec['dmft_score'] = 0 |
| if rec['dental_caries']: |
| if rec['child']: |
| rec['dmft_score'] = max(0, min(20, int(rng.exponential(3)))) |
| else: |
| rec['dmft_score'] = max(0, min(32, int(rng.exponential(5)))) |
|
|
| rec['untreated_caries'] = 0 |
| if rec['dental_caries']: |
| rec['untreated_caries'] = 1 if rng.random() < 0.80 else 0 |
|
|
| |
| rec['periodontal_disease'] = 0 |
| if rec['age_years'] >= 15: |
| perio_prob = 0.20 |
| if rec['tobacco_use']: |
| perio_prob *= 1.5 |
| if rec['diabetes']: |
| perio_prob *= 1.5 |
| if rec['hiv_positive']: |
| perio_prob *= 1.3 |
| rec['periodontal_disease'] = 1 if rng.random() < min(perio_prob, 0.60) else 0 |
|
|
| rec['periodontal_severity'] = 'none' |
| if rec['periodontal_disease']: |
| rec['periodontal_severity'] = rng.choice( |
| ['mild', 'moderate', 'severe'], |
| p=[0.30, 0.45, 0.25]) |
|
|
| rec['tooth_loss'] = 0 |
| if rec['periodontal_severity'] == 'severe' or rec['dmft_score'] > 8: |
| rec['tooth_loss'] = max(0, min(20, int(rng.exponential(3)))) |
|
|
| |
| rec['oral_cancer'] = 0 |
| if rec['age_years'] >= 40: |
| oc_prob = 0.005 |
| if rec['tobacco_use']: |
| oc_prob *= 3 |
| rec['oral_cancer'] = 1 if rng.random() < oc_prob else 0 |
|
|
| rec['noma'] = 0 |
| if rec['child'] and rec['malnutrition']: |
| rec['noma'] = 1 if rng.random() < 0.005 else 0 |
|
|
| rec['oral_hiv_manifestation'] = 0 |
| if rec['hiv_positive']: |
| rec['oral_hiv_manifestation'] = 1 if rng.random() < 0.30 else 0 |
|
|
| rec['cleft_lip_palate'] = 0 |
| if rec['age_years'] < 10: |
| rec['cleft_lip_palate'] = 1 if rng.random() < 0.002 else 0 |
|
|
| rec['dental_trauma'] = 0 |
| if rec['age_years'] < 18: |
| rec['dental_trauma'] = 1 if rng.random() < 0.05 else 0 |
|
|
| rec['dental_abscess'] = 0 |
| if rec['untreated_caries']: |
| rec['dental_abscess'] = 1 if rng.random() < 0.10 else 0 |
|
|
| rec['dental_pain'] = 0 |
| if rec['dental_caries'] or rec['periodontal_disease'] or rec['dental_abscess']: |
| rec['dental_pain'] = 1 if rng.random() < 0.60 else 0 |
|
|
| |
| rec['sought_dental_care'] = 0 |
| if rec['dental_pain'] or rec['dental_abscess']: |
| rec['sought_dental_care'] = 1 if rng.random() < (0.50 * sc['treatment_mod'] + 0.10) else 0 |
|
|
| rec['treatment_received'] = 'none' |
| if rec['sought_dental_care']: |
| if sc['restorative_available']: |
| rec['treatment_received'] = rng.choice( |
| ['extraction', 'filling', 'scaling', 'antibiotics', 'pain_relief'], |
| p=[0.35, 0.25, 0.10, 0.15, 0.15]) |
| elif sc['dentist_available']: |
| rec['treatment_received'] = rng.choice( |
| ['extraction', 'antibiotics', 'pain_relief'], |
| p=[0.50, 0.25, 0.25]) |
| else: |
| rec['treatment_received'] = rng.choice( |
| ['pain_relief', 'traditional_remedy', 'referral'], |
| p=[0.40, 0.35, 0.25]) |
|
|
| rec['barrier_to_care'] = 'none' |
| if not rec['sought_dental_care'] and rec['dental_pain']: |
| rec['barrier_to_care'] = rng.choice( |
| ['cost', 'distance', 'no_dentist', 'fear', |
| 'not_severe_enough', 'traditional_preference'], |
| p=[0.25, 0.20, 0.20, 0.15, 0.10, 0.10]) |
|
|
| rec['fluoride_varnish'] = 0 |
| if rec['child'] and sc['fluoride_programme']: |
| rec['fluoride_varnish'] = 1 if rng.random() < 0.20 else 0 |
|
|
| rec['oral_health_education'] = 0 |
| if rec['sought_dental_care'] and sc['dentist_available']: |
| rec['oral_health_education'] = 1 if rng.random() < 0.30 else 0 |
|
|
| |
| rec['pain_resolved'] = 0 |
| if rec['treatment_received'] not in ('none', 'referral'): |
| rec['pain_resolved'] = 1 if rng.random() < 0.70 else 0 |
|
|
| rec['complication'] = 0 |
| if rec['dental_abscess'] and rec['treatment_received'] == 'none': |
| rec['complication'] = 1 if rng.random() < 0.15 else 0 |
|
|
| rec['noma_disfigurement'] = 0 |
| if rec['noma']: |
| rec['noma_disfigurement'] = 1 if rng.random() < 0.80 else 0 |
|
|
| records.append(rec) |
|
|
| df = pd.DataFrame(records) |
|
|
| print(f"\n{'='*65}") |
| print(f"Oral Health — {scenario} (n={n}, seed={seed})") |
| print(f"{'='*65}") |
| print(f"\n Dental caries: {df['dental_caries'].mean()*100:.1f}%") |
| print(f" Untreated: {df['untreated_caries'].mean()*100:.1f}%") |
| print(f" Periodontal: {df['periodontal_disease'].mean()*100:.1f}%") |
| print(f" Dental pain: {df['dental_pain'].mean()*100:.1f}%") |
| print(f" Sought care: {df['sought_dental_care'].mean()*100:.1f}%") |
| print(f" Mean DMFT: {df[df['dental_caries']==1]['dmft_score'].mean():.1f}") |
|
|
| return df |
|
|
|
|
| if __name__ == '__main__': |
| parser = argparse.ArgumentParser( |
| description='Generate oral health dataset') |
| parser.add_argument('--scenario', type=str, default='district_hospital', |
| choices=list(SCENARIOS.keys())) |
| parser.add_argument('--n', type=int, default=10000) |
| parser.add_argument('--seed', type=int, default=42) |
| parser.add_argument('--output', type=str, default=None) |
| parser.add_argument('--all-scenarios', action='store_true') |
| args = parser.parse_args() |
|
|
| os.makedirs('data', exist_ok=True) |
|
|
| if args.all_scenarios: |
| for sc_name in SCENARIOS: |
| df = generate_dataset(n=args.n, seed=args.seed, scenario=sc_name) |
| out = os.path.join('data', f'oral_{sc_name}.csv') |
| df.to_csv(out, index=False) |
| print(f" -> Saved to {out}\n") |
| else: |
| df = generate_dataset(n=args.n, seed=args.seed, scenario=args.scenario) |
| out = args.output or os.path.join('data', f'oral_{args.scenario}.csv') |
| df.to_csv(out, index=False) |
| print(f" -> Saved to {out}") |
|
|