JadAssaf commited on
Commit
c87c55c
1 Parent(s): 78f7cb6

added class probabilities

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -1,6 +1,7 @@
1
  # %%
2
  import gradio as gr
3
  import joblib
 
4
  loaded_rf_2way = joblib.load("STPI_2WAY_RandomForest.joblib")
5
  loaded_rf_3way = joblib.load("STPI_3WAY_RandomForest.joblib")
6
 
@@ -38,17 +39,26 @@ Abs_Diff_t_0_5_MaxValue,Abs_Diff_t_1_0_MaxValue,Abs_Diff_t_2_0_MaxValue,Optional
38
  result_2way = loaded_rf_2way.predict([X])
39
  print('The patient is ', outcome_decoded[int(result_2way)], ' through the 2way method')
40
 
 
 
 
 
41
  result_3way = loaded_rf_3way.predict([X])
 
 
 
 
 
42
  if result_2way == 0:
43
  print('The patient is ', outcome_decoded[int(result_3way)], 'through the 3way method')
44
  # result = 'The 3-way classification resulted in a ', outcome_decoded[int(result_3way)] + ' patient.'
45
  # further_analysis = 'Futher analysis using the 2-way classification resulted in a ' + outcome_decoded[int(result_2way)] + ' label.'
46
- return 'The 3-way classification resulted in a ' + outcome_decoded[int(result_3way)] + ' patient. Futher analysis using the 2-way classification resulted in a ' + outcome_decoded[int(result_2way)] + ' label.'
47
 
48
  # result = 'The 2-way classification resulted in a ', outcome_decoded[int(result_2way)] + ' patient.'
49
  # further_analysis = 'Futher analysis using the 3-way classification resulted in a ' + outcome_decoded[int(result_3way)] + ' label.'
50
 
51
- return 'The 2-way classification resulted in a ' + outcome_decoded[int(result_2way)] + ' patient. Futher analysis using the 3-way classification resulted in a ' + outcome_decoded[int(result_3way)] + ' label.'
52
 
53
  iface = gr.Interface(
54
  fn=STPI,
@@ -58,5 +68,7 @@ iface = gr.Interface(
58
  # "number",
59
  "number", "number","number","text"],
60
  outputs="text")
61
- iface.launch(share=True)
 
 
62
  # %%
 
1
  # %%
2
  import gradio as gr
3
  import joblib
4
+ import numpy as np
5
  loaded_rf_2way = joblib.load("STPI_2WAY_RandomForest.joblib")
6
  loaded_rf_3way = joblib.load("STPI_3WAY_RandomForest.joblib")
7
 
 
39
  result_2way = loaded_rf_2way.predict([X])
40
  print('The patient is ', outcome_decoded[int(result_2way)], ' through the 2way method')
41
 
42
+ probs_2way = loaded_rf_2way.predict_proba([X])
43
+ probs_2way = str(np.round(probs_2way[0], decimals=2))
44
+ print('2 way class Probabilities (Normal/KC) are ', probs_2way)
45
+
46
  result_3way = loaded_rf_3way.predict([X])
47
+
48
+ probs_3way = loaded_rf_3way.predict_proba([X])
49
+ probs_3way = str(np.round(probs_3way[0], decimals=2))
50
+ print('3 way class Probabilities (Normal/Suspect/KC) are ', probs_3way)
51
+
52
  if result_2way == 0:
53
  print('The patient is ', outcome_decoded[int(result_3way)], 'through the 3way method')
54
  # result = 'The 3-way classification resulted in a ', outcome_decoded[int(result_3way)] + ' patient.'
55
  # further_analysis = 'Futher analysis using the 2-way classification resulted in a ' + outcome_decoded[int(result_2way)] + ' label.'
56
+ return 'The 3-way classification resulted in a ' + outcome_decoded[int(result_3way)] + ' patient. Futher analysis using the 2-way classification resulted in a ' + outcome_decoded[int(result_2way)] + ' label. ' + '2 way class Probabilities (Normal/KC) are ' + probs_2way + ' and 3 way class Probabilities (Normal/Suspect/KC) are ' + probs_3way
57
 
58
  # result = 'The 2-way classification resulted in a ', outcome_decoded[int(result_2way)] + ' patient.'
59
  # further_analysis = 'Futher analysis using the 3-way classification resulted in a ' + outcome_decoded[int(result_3way)] + ' label.'
60
 
61
+ return 'The 2-way classification resulted in a ' + outcome_decoded[int(result_2way)] + ' patient. Futher analysis using the 3-way classification resulted in a ' + outcome_decoded[int(result_3way)] + ' label. ' + '2 way class Probabilities (Normal/KC) are ' + probs_2way + ' and 3 way class Probabilities (Normal/Suspect/KC) are ' + probs_3way
62
 
63
  iface = gr.Interface(
64
  fn=STPI,
 
68
  # "number",
69
  "number", "number","number","text"],
70
  outputs="text")
71
+ iface.launch(
72
+ # share=True
73
+ )
74
  # %%