
Introduction—
MATLABSolutions demonstrate In this task we are going to design the project. According to WHO, Diabetes is a chronic disease that occurs either when the pancreas does not produce enough insulin or when the body cannot effectively use the insulin it produces. Insulin is a hormone that regulates blood sugar. Hyperglycaemia, or raised blood sugar, is a common effect of uncontrolled diabetes and over time leads to serious damage to many of the body's systems, especially the nerves and blood vessels
Between 2000 and 2016, there was a 5% increase in premature mortality rates (i.e. before the age of 70) from diabetes. In high-income countries the premature mortality rate due to diabetes decreased from 2000 to 2010 but then increased in 2010-2016. In lower-middle-income countries, the premature mortality rate due to diabetes increased across both periods.
Diabetes Prediction Machine Learning Project using Python Streamlit
Below are the steps by which we can make a Diabetes Prediction Machine Learning Project using Python Streamlit:
Step 1: Create a Virtual Environment
virtualenv env
.\env\Scripts\activate.ps1
Step 2: Install Libraries
First, install all the essential libraries using the following commands. In a Diabetes prediction GUI built with Streamlit, these libraries serve critical roles. Numpy enables efficient data handling, Pickle5 is essential for saving and loading machine learning models, and Streamlit empowers the creation of simple web apps from data analysis scripts, making them accessible to users without the need for advanced web development skills.
pip install numpy
pip install pickle5
pip install streamlit
Step 3 : File Structure
Open File Structure
Step 4: Writing Our Code
After installing all the libraries we write our coding part :
- Model Loading: The code loads a pre-trained machine learning model from a file named ‘trained_model.sav‘ using the
pickle.loadmethod. This model is stored in the variableloaded_modeland will be used for making predictions. - Diabetes Prediction Function: The
diabetes_predictionfunction is defined to make predictions based on user input. It takes a list of input data, converts it to a NumPy array, reshapes it, and then uses the loaded model to make a prediction. If the prediction is 0, it returns ‘Non Diabetic,’ otherwise, it returns ‘Diabetic’. - Main Function: The
mainfunction is the core of the web application. It uses Streamlit to create a simple web interface for diabetes prediction. It displays input fields for various features related to diabetes, such as number of pregnancies, glucose level, blood pressure, and more. After entering the data, the user can click a “Predict” button to trigger the prediction. - User Interface: The code defines the layout of the web app, takes user input for the diabetes-related features, calls the
diabetes_predictionfunction with the user’s input, and displays the prediction result using thest.successfunction. If the user clicks the “Predict” button, the result is shown, indicating whether the individual is predicted to be diabetic or non-diabetic.