ninte's picture
Update app.py
849766e
import streamlit as st
import pandas as pd
import joblib
# Load the saved model
loaded_model = joblib.load('diabetes_prediction_model.joblib')
def predict_diabetes(data):
# Use the loaded model to make predictions
predicted_class = loaded_model.predict(data)
return predicted_class
def main():
st.title("Diabetes Prediction App")
# Create input form for user to enter values
st.sidebar.header("User Input Features")
pregnancies = st.sidebar.slider("Pregnancies", 0, 17, 3)
glucose = st.sidebar.slider("Glucose", 0, 199, 117)
blood_pressure = st.sidebar.slider("Blood Pressure", 0, 122, 72)
skin_thickness = st.sidebar.slider("Skin Thickness", 0, 99, 23)
insulin = st.sidebar.slider("Insulin", 0, 846, 30)
bmi = st.sidebar.slider("BMI", 0.0, 67.1, 32.0)
diabetes_pedigree_function = st.sidebar.slider("Diabetes Pedigree Function", 0.078, 2.42, 0.3725)
age = st.sidebar.slider("Age", 21, 81, 29)
# Create a DataFrame from user input
user_data = pd.DataFrame({
'Pregnancies': [pregnancies],
'Glucose': [glucose],
'BloodPressure': [blood_pressure],
'SkinThickness': [skin_thickness],
'Insulin': [insulin],
'BMI': [bmi],
'DiabetesPedigreeFunction': [diabetes_pedigree_function],
'Age': [age]
})
# Make prediction
if st.button("Predict"):
prediction = predict_diabetes(user_data)
st.success(f"The individual is {'Diabetic' if prediction[0] == 1 else 'Not Diabetic'}.")
if __name__ == "__main__":
main()