Spaces:
Sleeping
Sleeping
santarabantoosoo
commited on
Commit
•
c92e63c
1
Parent(s):
222772d
app.py
CHANGED
@@ -5,68 +5,59 @@ import numpy as np
|
|
5 |
import lightgbm as lgb
|
6 |
from autogluon.tabular import TabularPredictor
|
7 |
|
8 |
-
loaded_model = pickle.load(open('model.pkl', 'rb'))
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
'pathology_others': pathology_others , 'B_symptoms_Yes': B_symptoms,
|
37 |
-
'radio_Yes': 1, 'second_PET' : 1}, index = [0])
|
38 |
-
|
39 |
-
X_test_no_radio = pd.DataFrame({'Age' : age, 'early_advanced_early': early_stage,
|
40 |
-
'pathology_Nodular Sclerosis cHL' : pathology_nod,
|
41 |
-
'pathology_others': pathology_others, 'B_symptoms_Yes': B_symptoms,
|
42 |
-
'radio_Yes': 0, 'second_PET' : 1}, index = [0])
|
43 |
-
|
44 |
-
|
45 |
-
pred_proba_radio = loaded_model.predict_proba(X_test_radio)[:, 1]
|
46 |
|
47 |
pred_proba_radio = round(np.ndarray.item(pred_proba_radio),2)
|
48 |
|
49 |
pred_radio = loaded_model.predict(X_test_radio)
|
50 |
|
51 |
-
pred_proba_no_radio = loaded_model.predict_proba(X_test_no_radio)
|
52 |
|
53 |
pred_proba_no_radio = round(np.ndarray.item(pred_proba_no_radio),2)
|
54 |
|
55 |
pred_no_radio = loaded_model.predict(X_test_no_radio)
|
56 |
|
57 |
-
return pred_proba_radio
|
58 |
|
59 |
-
iface = gr.Interface(
|
|
|
|
|
60 |
description = 'This model predicts relapse according to risk factors.',
|
61 |
fn=relapse,
|
62 |
inputs= [
|
63 |
gr.Number(label = 'Age', show_label = True),
|
64 |
-
|
65 |
-
gr.Radio( choices = ['Mixed cellularity', 'Nodular', 'Others'], label = 'Pathology',
|
66 |
-
show_label = True),
|
67 |
gr.Checkbox(label = 'B_symptoms', show_label = True)],
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
71 |
|
72 |
iface.launch()
|
|
|
5 |
import lightgbm as lgb
|
6 |
from autogluon.tabular import TabularPredictor
|
7 |
|
8 |
+
loaded_model = pickle.load(open('Autogluon/models/XGBoost_BAG_L1/model.pkl', 'rb'))
|
9 |
+
# pred_proba_radio = loaded_model.predict_proba(X_test_radio)
|
10 |
+
# pred_proba_radio
|
11 |
+
|
12 |
+
|
13 |
+
def relapse(age, pathology, B_symptoms):
|
14 |
+
|
15 |
+
X_test_radio = pd.DataFrame.from_dict(
|
16 |
+
{
|
17 |
+
"Age": [age],
|
18 |
+
"pathology_Nodular Sclerosis cHL": [1 if pathology == 'Nodular' else 0],
|
19 |
+
"pathology_others": [1 if pathology == 'Others' else 0],
|
20 |
+
"B_symptoms_Yes" : [1 if B_symptoms else 0],
|
21 |
+
'radio_Yes': [1]
|
22 |
+
}
|
23 |
+
)
|
24 |
+
|
25 |
+
X_test_no_radio = pd.DataFrame.from_dict(
|
26 |
+
{
|
27 |
+
"Age": [age],
|
28 |
+
"pathology_Nodular Sclerosis cHL": [1 if pathology == 'Nodular' else 0],
|
29 |
+
"pathology_others": [1 if pathology == 'Others' else 0],
|
30 |
+
"B_symptoms_Yes" : [1 if B_symptoms else 0],
|
31 |
+
'radio_Yes': [0]
|
32 |
+
}
|
33 |
+
)
|
34 |
+
|
35 |
+
pred_proba_radio = loaded_model.predict_proba(X_test_radio)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
pred_proba_radio = round(np.ndarray.item(pred_proba_radio),2)
|
38 |
|
39 |
pred_radio = loaded_model.predict(X_test_radio)
|
40 |
|
41 |
+
pred_proba_no_radio = loaded_model.predict_proba(X_test_no_radio)
|
42 |
|
43 |
pred_proba_no_radio = round(np.ndarray.item(pred_proba_no_radio),2)
|
44 |
|
45 |
pred_no_radio = loaded_model.predict(X_test_no_radio)
|
46 |
|
47 |
+
return {"Radio": pred_proba_radio, "No Radio": pred_proba_no_radio}
|
48 |
|
49 |
+
iface = gr.Interface(
|
50 |
+
|
51 |
+
title = 'Should we omit radiotherapy?',
|
52 |
description = 'This model predicts relapse according to risk factors.',
|
53 |
fn=relapse,
|
54 |
inputs= [
|
55 |
gr.Number(label = 'Age', show_label = True),
|
56 |
+
gr.Radio( choices = ['Mixed cellularity', 'Nodular', 'Others'], label = 'Pathology', show_label = True),
|
|
|
|
|
57 |
gr.Checkbox(label = 'B_symptoms', show_label = True)],
|
58 |
+
outputs = gr.Label(label = 'Has a higher probability of relapse', show_label = True)
|
59 |
+
,live = True,
|
60 |
+
interpretation="default",
|
61 |
+
)
|
62 |
|
63 |
iface.launch()
|