Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -67,17 +67,15 @@ deep_model = NeuralNet(input_size, hidden_size, output_size)
|
|
67 |
criterion = nn.BCELoss()
|
68 |
optimizer = optim.Adam(deep_model.parameters(), lr=0.001)
|
69 |
|
70 |
-
# Skip training loop here for real-time prediction
|
71 |
-
|
72 |
# Title and description in Streamlit
|
73 |
st.title("BERTO AI😊 : Personalized Diabetes Treatment Predictor")
|
74 |
st.write("""
|
75 |
-
BERTO
|
76 |
-
of one of our
|
77 |
This application uses a deep learning model powered by PyTorch to predict whether you may have diabetes based on various health indicators.
|
78 |
-
We aim to provide insights and suggestions for personalizing diabetes treatment. The Application allows you to choose between two options
|
79 |
-
which have been
|
80 |
-
mission to help manage ,
|
81 |
""")
|
82 |
|
83 |
# Input form for user to enter health information with descriptions
|
@@ -94,11 +92,18 @@ HeartDiseaseorAttack = st.selectbox("History of Heart Disease or Attack (1: Yes,
|
|
94 |
Age = st.slider("Age", 18, 100, 30)
|
95 |
HighChol = st.selectbox("High Cholesterol (1: Yes, 0: No)", [0, 1])
|
96 |
DiffWalk = st.selectbox("Difficulty Walking (1: Yes, 0: No)", [0, 1])
|
97 |
-
BMI = st.slider("BMI (Body Mass Index)", 10.0, 50.0, 25.0)
|
98 |
HighBP = st.selectbox("High Blood Pressure (1: Yes, 0: No)", [0, 1])
|
99 |
GenHlth = st.slider("General Health (1=Excellent, 5=Poor)", 1, 5, 3)
|
100 |
|
101 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
user_input = np.array([[AnyHealthcare, Sex, Smoker, MentHlth, CholCheck, Stroke,
|
103 |
PhysHlth, HeartDiseaseorAttack, Age, HighChol, DiffWalk,
|
104 |
BMI, HighBP, GenHlth]])
|
@@ -120,6 +125,29 @@ if st.button("Predict"):
|
|
120 |
|
121 |
# Display prediction result
|
122 |
if prediction == 1:
|
123 |
-
st.success("The model predicts that you likely **
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
else:
|
125 |
-
st.success("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
criterion = nn.BCELoss()
|
68 |
optimizer = optim.Adam(deep_model.parameters(), lr=0.001)
|
69 |
|
|
|
|
|
70 |
# Title and description in Streamlit
|
71 |
st.title("BERTO AI😊 : Personalized Diabetes Treatment Predictor")
|
72 |
st.write("""
|
73 |
+
BERTO AI is a personalized diabetes prediction tool built to assist users in better understanding their health risks.
|
74 |
+
Berto honors the legacy of one of our founder's dad, Roberto Ferrer, who unfortunately succumbed to Type 2 Diabetes.
|
75 |
This application uses a deep learning model powered by PyTorch to predict whether you may have diabetes based on various health indicators.
|
76 |
+
We aim to provide insights and suggestions for personalizing diabetes treatment. The Application allows you to choose between two options, Yes and No,
|
77 |
+
which have been given binary values. There is also a slider for various features, which have ranges as indicated. Berto is part of DiabeTrek Health's
|
78 |
+
mission to help manage, prevent, and provide personalized treatment to Type 2 Diabetic Patients.
|
79 |
""")
|
80 |
|
81 |
# Input form for user to enter health information with descriptions
|
|
|
92 |
Age = st.slider("Age", 18, 100, 30)
|
93 |
HighChol = st.selectbox("High Cholesterol (1: Yes, 0: No)", [0, 1])
|
94 |
DiffWalk = st.selectbox("Difficulty Walking (1: Yes, 0: No)", [0, 1])
|
|
|
95 |
HighBP = st.selectbox("High Blood Pressure (1: Yes, 0: No)", [0, 1])
|
96 |
GenHlth = st.slider("General Health (1=Excellent, 5=Poor)", 1, 5, 3)
|
97 |
|
98 |
+
# Get height and weight input
|
99 |
+
height_cm = st.slider("Height (in cm)", 100, 250, 170)
|
100 |
+
weight_kg = st.slider("Weight (in kg)", 30, 200, 70)
|
101 |
+
|
102 |
+
# Calculate BMI
|
103 |
+
BMI = weight_kg / (height_cm / 100) ** 2
|
104 |
+
st.write(f"Your BMI is: {BMI:.2f}")
|
105 |
+
|
106 |
+
# Create a feature array from the inputs, including the calculated BMI
|
107 |
user_input = np.array([[AnyHealthcare, Sex, Smoker, MentHlth, CholCheck, Stroke,
|
108 |
PhysHlth, HeartDiseaseorAttack, Age, HighChol, DiffWalk,
|
109 |
BMI, HighBP, GenHlth]])
|
|
|
125 |
|
126 |
# Display prediction result
|
127 |
if prediction == 1:
|
128 |
+
st.success("The model predicts that you likely **have diabetes**.")
|
129 |
+
|
130 |
+
# Provide tips for managing diabetes
|
131 |
+
st.subheader("Tips for Managing Diabetes")
|
132 |
+
st.markdown("""
|
133 |
+
- **Maintain a balanced diet**: Focus on eating whole grains, vegetables, lean protein, and healthy fats.
|
134 |
+
- **Exercise regularly**: Physical activity helps control your blood sugar.
|
135 |
+
- **Monitor blood sugar levels**: Regular monitoring helps you keep track of your glucose levels.
|
136 |
+
- **Take medications as prescribed**: Follow your doctor's instructions regarding medications.
|
137 |
+
- **Manage stress**: Chronic stress can raise blood sugar levels, so practice relaxation techniques.
|
138 |
+
- **Get regular check-ups**: Regular health check-ups are crucial for managing diabetes effectively.
|
139 |
+
""")
|
140 |
else:
|
141 |
+
st.success("✅ Lower risk detected. Keep up the good work!")
|
142 |
+
|
143 |
+
# Provide tips for maintaining low diabetes risk
|
144 |
+
st.subheader("Tips to Maintain Low Diabetes Risk")
|
145 |
+
st.markdown("""
|
146 |
+
- **Keep a healthy weight**
|
147 |
+
- **Exercise often**
|
148 |
+
- **Eat well-balanced meals**
|
149 |
+
- **Cut down on sugar and unhealthy fats**
|
150 |
+
- **Check your blood sugar**
|
151 |
+
- **Manage stress**
|
152 |
+
- **Get regular check-ups**
|
153 |
+
""")
|