The Problem: NCDs in Eswatini
Non-communicable diseases (NCDs) are responsible for roughly 74% of deaths worldwide each year, and a striking 77% of these occur in low- and middle-income countries. Diabetes and cardiovascular disease (CVD) are among the most pressing, driven by lifestyle factors such as low physical activity, poor diet, and strained healthcare infrastructure challenges that resonate strongly in Eswatini.
To help address this gap, Bandile Malaza, developed an intelligent health advisory system that brings together predictive analytics, large language models, and retrieval-augmented generation (RAG) to support early detection and personalized care.
How the System Works
The platform was built around two core prediction models:
- Diabetes prediction, trained on patient records from the UCI Machine Learning Repository. Features included age, gender, polyuria, polydipsia, weight loss, and several other clinical indicators.
- Heart disease prediction, trained on patient records from Kaggle. Features included age, sex, chest pain type, resting blood pressure, cholesterol, and more.
Several machine learning algorithms were tested for each task, including Support Vector Machines (SVM), Logistic Regression, Decision Trees, and Random Forest classifiers. After data cleaning, handling missing values, and feature scaling, the models were evaluated on accuracy, precision, recall, F1-score, and AUC.
Results were strong across the board. For diabetes prediction, the Decision Tree classifier reached 97% accuracy, outperforming SVM and Logistic Regression (both at 93% accuracy). For heart disease prediction, SVM achieved the best balance of recall and F1-score among the models tested, with all approaches performing in the 80-82% accuracy range.
Adding Intelligence with Llama 3.3 and RAG
What sets this project apart is how the prediction models are paired with a conversational AI layer. Once a user receives a risk prediction, the results are delivered through a chatbot interface powered by Llama 3.3, which generates context-aware, personalized lifestyle recommendations based on the user's risk level.
To make these recommendations genuinely useful in the Eswatini context, the system uses Retrieval-Augmented Generation (RAG) to pull in up-to-date, locally relevant information including details about health facilities across the country. This means the AI assistant isn't just giving generic advice; it's grounding its responses in information specific to where users actually live and the resources available to them.
The application itself was built using Flask for the web framework, with the trained models serialized using Joblib for deployment. Development was carried out using GitHub for version control and Gitpod as a cloud-based development environment.
Why It Matters
This project demonstrates a practical pathway for AI to support overstretched healthcare systems in low-resource settings. By combining reliable predictive models with an AI assistant that understands local context, tools like this could help people get earlier warnings about their health risks and clearer guidance on what to do next without needing to wait for an appointment or travel to a clinic.
What's Next
The next steps for this project involve incorporating local Eswatini health datasets to further improve model accuracy and ensure the recommendations reflect the realities of the population they're meant to serve. There's also room to expand the range of features and conditions covered as the system matures.
A key future direction is adding siSwati language support, so that the chatbot can communicate with users in their native language making the system more accessible and inclusive for communities across Eswatini, particularly in rural areas where English literacy may be a barrier to accessing health information. Beyond language, plans for advancing the system include broadening it to cover additional NCDs, integrating with local clinic data and health worker workflows, and refining the RAG knowledge base with more comprehensive, regularly updated information on Eswatini's health facilities and services.
Projects like this highlight the growing potential for homegrown AI solutions to make a real difference in healthcare access across Eswatini and the broader region.
This work was carried out with guidance from Mr. Magagula and Dr. Metfula at the University of Eswatini. Connect with Bandile Malaza at or via , or check out the project on .