ikhlasulakmalh commited on
Commit
ef59fe2
·
1 Parent(s): 53aa3a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -12
app.py CHANGED
@@ -19,18 +19,23 @@ X = pd.DataFrame([symptoms_dict], columns=column_list)
19
  st.write('Generated DataFrame:')
20
  st.write(X)
21
 
22
- # Unpickle classifier
23
- clf = joblib.load("self_diagnose_model.pkl")
24
-
25
- # Store inputs into dataframe
26
- X = pd.DataFrame([[
27
- age, sex, high_chol, chol_check, bmi, smoker, hda, pa, fruit, veggies, hac, gh, mh, ph, dw, stroke, high_bp
28
- ]], columns=preds)
29
-
30
- # Get prediction
31
- prediction = clf.predict(X)[0]
32
-
33
- st.text(prediction)
 
 
 
 
 
34
 
35
 
36
 
 
19
  st.write('Generated DataFrame:')
20
  st.write(X)
21
 
22
+ if st.button("Submit"):
23
+ # Unpickle classifier
24
+ clf = joblib.load("self_diagnose_model.pkl")
25
+
26
+ # Get prediction
27
+ prediction = clf.predict(X)[0]
28
+
29
+ st.text("Predicted Disease:", prediction)
30
+ st.text("Confidence Scores (Probabilities for Each Class):")
31
+ st.write(confidence_scores)
32
+
33
+ # You can also display the top N predicted classes with their probabilities
34
+ top_n = 5 # Change this value to display more or fewer top classes
35
+ top_n_classes = np.argsort(-confidence_scores)[:top_n]
36
+ st.text("Top {} Predicted Diseases:".format(top_n))
37
+ for i, class_idx in enumerate(top_n_classes):
38
+ st.text(f"{clf.classes_[class_idx]}: {confidence_scores[class_idx]:.2f}")
39
 
40
 
41