Streamlit : Diabetes Prediction

Introduction

Extended Version for the Diabetes Prediction : Please check the diabetes prediction first.

A diabetes prediction web application built using machine learning provides a simple and effective tool for early health assessment.
This project allows users to input basic medical parameters and instantly receive a prediction about whether the person may have diabetes.

Using Python and Streamlit the system delivers a lightweight interactive web interface for real time predictions making it helpful for awareness and preventive decision making.

Project Overview

  • Machine learning powered diabetes prediction system
  • Integrated into a Streamlit web app for user friendly interaction
  • Uses a pre trained model loaded from a pickle file
  • Accepts eight medical input values and returns a prediction result

Libraries Used

  • NumPy for numerical array handling
  • Pickle for loading the pre trained ML model
  • Streamlit for building the web application interface
  • Scikit Learn model used during offline training before export as a pickle file

Application Details

The project uses a previously trained machine learning model saved as
trained_model.sav

The app accepts the following health features from the user

  • Number of pregnancies
  • Glucose level
  • Blood pressure
  • Skin thickness
  • Insulin level
  • BMI
  • Diabetes pedigree function
  • Age

These inputs are fed into the model to determine whether the person is diabetic or not.

Preprocessing Steps

  • User values entered through text input fields in Streamlit
  • Inputs are collected as a list and converted to a NumPy array
  • Array is reshaped to match the model input size so the model understands it is a single person prediction
  • Model produces a binary output where
  • Zero means not diabetic
  • One means diabetic

Model Interaction

  • The web app loads the trained model using pickle load
  • Function diabetes prediction handles
  • Input conversion
  • Reshaping
  • Model prediction
  • Returning a readable output message for the user

Example logic from your app

  • If prediction equals zero return person is not diabetic
  • Otherwise return person is diabetic

Streamlit Interface

  • App title displayed using st.title
  • Text input fields collect user data from browser
  • When the user clicks the Diabetes Test Result button the result is calculated
  • st.success displays the output message on screen

The interface is simple clean and suitable for both beginners and health analysts.

Prediction Flow

1 User enters eight medical values
2 Values are converted into numerical format
3 Model predicts the health status
4 Result is displayed immediately on the Streamlit page

Deployment Possibilities

  • Deploy on Streamlit Cloud for instant public access
  • Package inside a Flask app for full scale web deployment
  • Embed inside healthcare portals or community screening tools

Key Takeaways

  • Complete working ML web app built using Streamlit
  • Demonstrates how offline trained models can be deployed through a simple UI
  • Shows practical application of machine learning for public health awareness

Future Enhancements

  • Add validation to check if user inputs are numeric
  • Improve UI with sliders instead of text fields
  • Add data visualizations for health insights
  • Deploy as a mobile friendly interface

Share this post:
Facebook
Twitter
LinkedIn

Web Development Projects

Interested in more? Check out my Machine Learning projects as well.

Machine Learning Projects

Interested in more? Check out my Machine Learning projects as well.

Python Projects

Interested in more? Check out my Python projects as well.