AIMLdeepanshu commited on
Commit
1a5d07f
·
verified ·
1 Parent(s): 20d08d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -17
app.py CHANGED
@@ -7,29 +7,31 @@ model = joblib.load("best_random_forest_model.pkl")
7
 
8
  # Define the prediction function
9
  def predict_alzheimers(
10
- age, gender, bmi, physical_activity, smoking, alcohol,
11
- diabetes, hypertension, cholesterol, family_history,
12
- cognitive_score, depression, sleep_quality, dietary,
13
  genetic_risk, social_engagement, income, stress
14
  ):
15
- # Mapping categorical inputs to numerical values
16
- gender = 1 if gender == "Female" else 0
17
- physical_activity = {"Low": 0, "Medium": 1, "High": 2}[physical_activity]
18
- smoking = {"Never": 0, "Former": 1, "Current": 2}[smoking]
19
- alcohol = {"Never": 0, "Occasionally": 1, "Regularly": 2}[alcohol]
20
  diabetes = 1 if diabetes == "Yes" else 0
21
  hypertension = 1 if hypertension == "Yes" else 0
22
- cholesterol = {"Low": 0, "Normal": 1, "High": 2}.get(cholesterol, 1) # default: Normal
23
-
24
  family_history = 1 if family_history == "Yes" else 0
25
- depression = {"Low": 0, "Medium": 1, "High": 2}[depression]
26
- sleep_quality = {"Poor": 0, "Average": 1, "Good": 2}[sleep_quality]
27
- dietary = {"Healthy": 0, "Average": 1, "Unhealthy": 2}.get(dietary, 1) # default: Average
28
-
29
  genetic_risk = 1 if genetic_risk == "Yes" else 0
30
- social_engagement = {"Low": 0, "Medium": 1, "High": 2}[social_engagement]
31
- income = {"Low": 0, "Medium": 1, "High": 2}[income]
32
- stress = {"Low": 0, "Medium": 1, "High": 2}[stress]
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  # Create input array
35
  features = np.array([[
 
7
 
8
  # Define the prediction function
9
  def predict_alzheimers(
10
+ age, gender, bmi, diabetes, hypertension, cholesterol,
11
+ physical_activity, smoking, alcohol, family_history,
12
+ cognitive_score, depression, sleep, dietary,
13
  genetic_risk, social_engagement, income, stress
14
  ):
15
+ # Map categorical values to numerical ones
16
+ gender = 1 if gender == "Male" else 0
 
 
 
17
  diabetes = 1 if diabetes == "Yes" else 0
18
  hypertension = 1 if hypertension == "Yes" else 0
 
 
19
  family_history = 1 if family_history == "Yes" else 0
 
 
 
 
20
  genetic_risk = 1 if genetic_risk == "Yes" else 0
21
+
22
+ cholesterol = {"Low": 0, "Normal": 1, "High": 2}.get(cholesterol, 1)
23
+ physical_activity = {"Low": 0, "Medium": 1, "High": 2}.get(physical_activity, 1)
24
+ smoking = {"Never": 0, "Former": 1, "Current": 2}.get(smoking, 1)
25
+ alcohol = {"Never": 0, "Occasionally": 1, "Regularly": 2}.get(alcohol, 1)
26
+ depression = {"Low": 0, "Medium": 1, "High": 2}.get(depression, 1)
27
+ sleep = {"Poor": 0, "Average": 1, "Good": 2}.get(sleep, 1)
28
+ dietary = {"Healthy": 0, "Average": 1, "Unhealthy": 2}.get(dietary, 1)
29
+ social_engagement = {"Low": 0, "Medium": 1, "High": 2}.get(social_engagement, 1)
30
+ income = {"Low": 0, "Medium": 1, "High": 2}.get(income, 1)
31
+ stress = {"Low": 0, "Medium": 1, "High": 2}.get(stress, 1)
32
+
33
+ # ... your model input code continues ...
34
+
35
 
36
  # Create input array
37
  features = np.array([[