-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreamlit_Model.py
46 lines (37 loc) · 1.96 KB
/
streamlit_Model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import streamlit as st
import pickle
import pandas as pd
# Load the saved model
with open("diabetes_prediction_model.pkl", 'rb') as file:
model = pickle.load(file)
# Function to make predictions
def predict_diabetes(input_data):
# Define the column names (these should match the columns used in your model)
columns = ['Pregnancies', 'Glucose', 'BloodPressure', 'SkinThickness', 'Insulin',
'BMI', 'DiabetesPedigreeFunction', 'Age']
# Convert the input data into a DataFrame
input_data_df = pd.DataFrame([input_data], columns=columns)
# Make prediction
prediction = model.predict(input_data_df)
return prediction[0]
# Streamlit app interface
st.title("Diabetes Prediction App")
st.write("Enter the information below to predict whether a patient has diabetes:")
# Input fields for the user
Pregnancies = st.number_input('Number of Pregnancies', min_value=0, max_value=20, value=0)
Glucose = st.number_input('Glucose Concentration', min_value=0, max_value=200, value=0)
BloodPressure = st.number_input('Blood Pressure', min_value=0, max_value=150, value=0)
SkinThickness = st.number_input('Skin Thickness', min_value=0, max_value=100, value=0)
Insulin = st.number_input('Insulin Level', min_value=0, max_value=900, value=0)
BMI = st.number_input('BMI', min_value=0, max_value=60, value=0)
DiabetesPedigreeFunction = st.number_input('Diabetes Pedigree Function', min_value=0.0, max_value=2.5, value=0.0)
Age = st.number_input('Age', min_value=0, max_value=120, value=0)
# Create a list with the input values
input_data = [Pregnancies, Glucose, BloodPressure, SkinThickness, Insulin, BMI, DiabetesPedigreeFunction, Age]
# Make a prediction when the button is pressed
if st.button('Predict'):
prediction = predict_diabetes(input_data)
if prediction == 1:
st.write("The person is predicted to have diabetes.")
else:
st.write("The person is predicted to not have diabetes.")