mohitrajdeo commited on
Commit
753a007
Β·
1 Parent(s): 3f3165d

Refactor sidebar options and update diabetes prediction logic to handle gender-specific input

Browse files
Files changed (2) hide show
  1. app.py +13 -5
  2. requirements.txt +3 -0
app.py CHANGED
@@ -62,7 +62,7 @@ with st.sidebar:
62
 
63
  selected = option_menu(
64
  menu_title="Navigation",
65
- options=['Home', 'Diabetes Prediction','Hypertension Prediction', 'Cardiovascular Disease Prediction', 'Stroke Prediction','Asthma Prediction', 'Sleep Health Analysis','Mental-Analysis','Medical Consultant', 'Data Visualization'],
66
  icons=['house', 'activity', 'lungs', 'heart-pulse', 'brain', 'bar-chart', 'chat'],
67
  menu_icon="cast",
68
  default_index=0,
@@ -74,7 +74,7 @@ with st.sidebar:
74
  }
75
  )
76
 
77
-
78
  # 'Checkbox-to-disease-predictor',
79
  # 'Text-based Disease Prediction',
80
  # Utility function to safely convert input to float
@@ -152,7 +152,15 @@ if selected == 'Diabetes Prediction':
152
  col1, col2 = st.columns(2)
153
 
154
  with col1:
155
- Pregnancies = safe_float(st.text_input("Number of Pregnancies", "0"))
 
 
 
 
 
 
 
 
156
  Glucose = safe_float(st.text_input("Glucose Level", "100"))
157
  BloodPressure = safe_float(st.text_input("Blood Pressure", "80"))
158
  SkinThickness = safe_float(st.text_input("Skin Thickness", "20"))
@@ -171,13 +179,13 @@ if selected == 'Diabetes Prediction':
171
  with st.spinner("⏳ Predicting... Please wait..."):
172
  time.sleep(2) # Simulating delay (remove in actual use)
173
  diab_prediction = diabetes_model.predict(input_data)
174
-
175
-
176
 
177
  result = "πŸ›‘ The person is diabetic" if diab_prediction[0] == 1 else "βœ… The person is not diabetic"
178
  if diab_prediction[0] == 0:
179
  # st.balloons() # Or use st.confetti() if you install the library
180
  st.success(result)
 
 
181
 
182
  except Exception as e:
183
  st.error(f"❌ Error: {e}")
 
62
 
63
  selected = option_menu(
64
  menu_title="Navigation",
65
+ options=['Home', 'Diabetes Prediction','Hypertension Prediction', 'Cardiovascular Disease Prediction', 'Asthma Prediction', 'Sleep Health Analysis','Mental-Analysis','Medical Consultant', 'Data Visualization'],
66
  icons=['house', 'activity', 'lungs', 'heart-pulse', 'brain', 'bar-chart', 'chat'],
67
  menu_icon="cast",
68
  default_index=0,
 
74
  }
75
  )
76
 
77
+ # 'Stroke Prediction',
78
  # 'Checkbox-to-disease-predictor',
79
  # 'Text-based Disease Prediction',
80
  # Utility function to safely convert input to float
 
152
  col1, col2 = st.columns(2)
153
 
154
  with col1:
155
+ gender = st.radio("Gender", ["Male", "Female"], horizontal=True)
156
+
157
+ # For females, show Pregnancies input; for males, set to 0
158
+ if gender == "Female":
159
+ Pregnancies = safe_float(st.text_input("Number of Pregnancies", "0"))
160
+ else:
161
+ Pregnancies = 0.0
162
+ st.info("Pregnancies set to 0 for males")
163
+
164
  Glucose = safe_float(st.text_input("Glucose Level", "100"))
165
  BloodPressure = safe_float(st.text_input("Blood Pressure", "80"))
166
  SkinThickness = safe_float(st.text_input("Skin Thickness", "20"))
 
179
  with st.spinner("⏳ Predicting... Please wait..."):
180
  time.sleep(2) # Simulating delay (remove in actual use)
181
  diab_prediction = diabetes_model.predict(input_data)
 
 
182
 
183
  result = "πŸ›‘ The person is diabetic" if diab_prediction[0] == 1 else "βœ… The person is not diabetic"
184
  if diab_prediction[0] == 0:
185
  # st.balloons() # Or use st.confetti() if you install the library
186
  st.success(result)
187
+ else:
188
+ st.error(result)
189
 
190
  except Exception as e:
191
  st.error(f"❌ Error: {e}")
requirements.txt CHANGED
@@ -4,6 +4,8 @@ streamlit
4
  streamlit-option-menu
5
  seaborn
6
  matplotlib
 
 
7
  pandas
8
  google-generativeai
9
  python-dotenv
@@ -15,3 +17,4 @@ tf-keras
15
  plotly
16
  plotly-express
17
  xgboost
 
 
4
  streamlit-option-menu
5
  seaborn
6
  matplotlib
7
+ pickle5
8
+ joblib
9
  pandas
10
  google-generativeai
11
  python-dotenv
 
17
  plotly
18
  plotly-express
19
  xgboost
20
+ scikit-learn-extra