DEV Community

Suleyman Sade
Suleyman Sade

Posted on • Originally published at suleymansade.blogspot.com

How I Build a Diabetes Risk App with Python & ML

DiaGuide: Diabetes Risk Prediction App

👋 Introduction

Hi there!

Last week, I built my first fully functional website, implementing AI to predict diabetes risk using historical data. This was my first time publishing a real, working website—and I am honestly proud of the result. And I built all this during 48-hour hackathon, working solo.

I used Streamlit for the UI, scikit-learn for the AI training, and a model. Here is how:

💡 The Idea

When the project topic was first released, I was slightly surprised to see healthcare 💓 — most of the hackathons I had joined previously allowed more open-ended, general tech solutions. But then I started thinking 🤔, and this pushed me to research more deeply.

Since I was good at data analysis and developing ML models, I decided to focus on those areas. I spent all of Friday and Saturday morning brainstorming ideas. I actually came up with a couple 🧠:

  • 💊 Medication Tracker App

    • An app to keep track of daily medication while allowing users to note how effective each medication is.
    • ✅ Easy to implement
    • ❌ The idea wasn't original enough
    • ❌ I wasn’t sure how to keep track of the data on a web server
    • ❌ I didn’t have enough time to learn and build a mobile app
  • Symptom-Based Doctor Recommendation

    • A questionnaire to determine whether the person needs to go to the doctor.
    • ✅ Useful in real life
    • ❌ Too broad
    • ❌ Hard to implement with all the parameters and questions
    • ❌ Hard to find a reliable database to use

Because of the reasons I mentioned above, I decided to pivot. But I still liked the idea of using a questionnaire to determine something important.

So I shifted gears to something more specific — a disease or mental health condition. I was very indecisive at first, but then I found a very useful diabetes dataset, and the parameters made sense to me. That’s when I committed to building DiaGuide.

⚙️ Tools & Stack

🀄 Language(s): Python

💻 Frontend

  • 🔨 Tools & Libraries: Streamlit
  • ❓ Why I chose it: I needed a simple library that I could use to create layout and I needed it fast 🏃‍♂️💨. As someone who doesn't have much experience in frontend design, Streamlit helped me a lot with being beginner-friendly and having a good documentation 📖 and tutorials. It was the perfect tool to create data-heavy app that requires minimal UI design.
  • 🛠️ How I used it: It was basically the cornerstone of my UI. Everything—from layout to interactivity—was built using 🐍 Python. No HTML, no CSS, just clean Python code.

🤖 Machine Learning

  • 🔨 Tools & Libraries: scikit-learn
  • 🔎 Model Type(s): Logistic Regression, Random Forest, Gradient Boosting
  • 🧹 Data Cleaning Libraries: Pandas, Numpy
  • 💪 Performance/Evaluation: I created 3 different models and evaluated each one of them by getting their ROC curve. This evaluation checks how successful the model is using the test sample when 1 = exact, 0.5 = same as randomly choosing:
    • Logistic Regression: 0.81, very fast ⚡
    • Gradient Boosting: 0.82, okay speed ⌛
    • Random Forest: 0.77, slows down the code significantly 🐢 and slower server response
    • 🏆 Result: Logistic Regression—it didn't have much accuracy difference with Gradient Boosting but was significantly faster.

📊 Dataset

  • 🌐 Source: Kaggle / UCI Machine Learning Repository
  • 🔗 Link: https://www.kaggle.com/datasets/alexteboul/diabetes-health-indicators-dataset/data
  • 🔢 Features Used: BMI, Age, Blood Pressure, etc.
  • 🤔 Why this dataset: ✅ Clean, 🏷️ labeled, 🧠 interpretable
  • 📝 Additional Notes: I didn't use two of the columns in the database—education level and income—because I thought they were more personal. Also, I evaluated with and without them and they only increased the accuracy by 1%, which is not significant.

🌐 Hosting & Deployment

  • 🚀 Where I deployed: Streamlit Cloud
  • 🧑‍💻 GitHub Repository: SuleymanSade/DiaGuide
  • 🌐 Streamlit App: DiaGuide App
  • 🛠️ How I did it: I put all the libraries I used into requirements.txt ➡️ Configured Git LFS to fit my models (since some of them were bigger than 100MB) ➡️ Created a GitHub repo & pushed the code ➡️ Set up Streamlit Cloud and it was ready to go
  • Why I used Streamlit Cloud: It was free-to-use and really simple to set up. It also connected to the repository, so if I make a change in the future, the website is going to update too.

Top comments (1)

Collapse
 
avies profile image
avies • Edited

Wow, this is such an impressive project! I am living with type 2 diabetes, such tools like DiaGuide are honestly find. I recently decided to take control of my own health and Get Mounjaro Online and it’s made a huge difference in my daily life. Apps like yours can really empower people to catch risks early and take action.