AIMLdeepanshu commited on
Commit
39ab8ad
·
verified ·
1 Parent(s): 2be19e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -17,8 +17,16 @@ def predict_alzheimers(age, gender, bmi, smoking, alcohol, diabetes, hypertensio
17
  apoe4 = 1 if apoe4 == "Yes" else 0
18
 
19
  features = np.array([[age, gender, bmi, smoking, alcohol, diabetes, hypertension, family_history, cognitive_score, apoe4]])
20
- prediction = model.predict(features)[0]
21
- return "🧠 Likely Alzheimers Positive" if prediction == 1 else "✅ Likely Alzheimer’s Negative"
 
 
 
 
 
 
 
 
22
 
23
  # Gradio UI
24
  interface = gr.Interface(
 
17
  apoe4 = 1 if apoe4 == "Yes" else 0
18
 
19
  features = np.array([[age, gender, bmi, smoking, alcohol, diabetes, hypertension, family_history, cognitive_score, apoe4]])
20
+
21
+ # Get probability of Alzheimer's positive (class 1)
22
+ proba = model.predict_proba(features)[0][1]
23
+ proba_percent = round(proba * 100, 2)
24
+
25
+ if proba >= 0.5:
26
+ return f"🧠 Likely Alzheimer’s Positive ({proba_percent}%)"
27
+ else:
28
+ return f"✅ Likely Alzheimer’s Negative ({100 - proba_percent}%)"
29
+
30
 
31
  # Gradio UI
32
  interface = gr.Interface(