ninte commited on
Commit
849766e
·
1 Parent(s): e8e6fb2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -2
app.py CHANGED
@@ -1,4 +1,46 @@
1
  import streamlit as st
 
 
2
 
3
- x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import pandas as pd
3
+ import joblib
4
 
5
+ # Load the saved model
6
+ loaded_model = joblib.load('diabetes_prediction_model.joblib')
7
+
8
+ def predict_diabetes(data):
9
+ # Use the loaded model to make predictions
10
+ predicted_class = loaded_model.predict(data)
11
+ return predicted_class
12
+
13
+ def main():
14
+ st.title("Diabetes Prediction App")
15
+
16
+ # Create input form for user to enter values
17
+ st.sidebar.header("User Input Features")
18
+
19
+ pregnancies = st.sidebar.slider("Pregnancies", 0, 17, 3)
20
+ glucose = st.sidebar.slider("Glucose", 0, 199, 117)
21
+ blood_pressure = st.sidebar.slider("Blood Pressure", 0, 122, 72)
22
+ skin_thickness = st.sidebar.slider("Skin Thickness", 0, 99, 23)
23
+ insulin = st.sidebar.slider("Insulin", 0, 846, 30)
24
+ bmi = st.sidebar.slider("BMI", 0.0, 67.1, 32.0)
25
+ diabetes_pedigree_function = st.sidebar.slider("Diabetes Pedigree Function", 0.078, 2.42, 0.3725)
26
+ age = st.sidebar.slider("Age", 21, 81, 29)
27
+
28
+ # Create a DataFrame from user input
29
+ user_data = pd.DataFrame({
30
+ 'Pregnancies': [pregnancies],
31
+ 'Glucose': [glucose],
32
+ 'BloodPressure': [blood_pressure],
33
+ 'SkinThickness': [skin_thickness],
34
+ 'Insulin': [insulin],
35
+ 'BMI': [bmi],
36
+ 'DiabetesPedigreeFunction': [diabetes_pedigree_function],
37
+ 'Age': [age]
38
+ })
39
+
40
+ # Make prediction
41
+ if st.button("Predict"):
42
+ prediction = predict_diabetes(user_data)
43
+ st.success(f"The individual is {'Diabetic' if prediction[0] == 1 else 'Not Diabetic'}.")
44
+
45
+ if __name__ == "__main__":
46
+ main()