Abstract
Background
Medication non-adherence among chronic disease patients undermines treatment outcomes worldwide, and the problem is compounded in Ghana by high out-of-pocket costs, inconsistent drug supply, and limited follow-up care. Machine learning (ML) models developed in high-income settings often fail to generalise to low- and middle-income country (LMIC) health systems because they overlook local socioeconomic and insurance-related barriers. This study developed and validated a context-aware, explainable ML framework for predicting medication adherence among chronic disease patients in Ghana using structured electronic medical record (EMR) data.
Methods
We conducted a retrospective, observational study using EMR data from 1,772 adult outpatients with hypertension, diabetes, or related chronic conditions at Presbyterian Hospital, Agogo, Ghana. Adherence was operationalised using the Proportion of Days Covered (PDC ≥ 80% = adherent). Five base classifiers (logistic regression, random forest, support vector machine, XGBoost, and multilayer perceptron) were trained on demographic, clinical, and cost-related features, augmented with six domain-informed interaction features (e.g., age–medication complexity and price burden among uninsured patients). Models were tuned via grid search with 5-fold cross-validation and combined into voting and stacking ensembles. Shapley Additive Explanations (SHAP) were used for interpretability, followed by a systematic ablation study across four feature-count configurations (12, 7, 5, and 3 features).
Results
The final stacked ensemble achieved 89.5% accuracy, an F1-score of 0.930, and an ROC-AUC of 0.934 on a held-out test set, outperforming all individual base models and a voting ensemble. Insurance status, an age–medication interaction term, and chronic comorbidity status were the strongest SHAP-ranked predictors. Ablation analysis showed a 7-feature configuration matched or exceeded full-model performance (87.6% accuracy, AUC 0.935), while reduction to 3 features retained 84.5% accuracy but reduced non-adherent-class recall from 69% to 58%. Training on SMOTE-balanced data improved non-adherent recall (0.77→0.84) at the cost of precision and overall accuracy.
Conclusions
Interpretable, context-specific ML models incorporating domain-informed interaction features can reliably predict medication adherence in a Ghanaian outpatient population, outperforming generic baseline approaches. SHAP-guided ablation identified a compact, deployable 3-to-7-feature hierarchy suited to varying resource settings, offering a practical pathway for adherence risk stratification in LMIC health systems.