Spaces:
Build error
Build error
Update app.py
Browse filesadded mat number..
app.py
CHANGED
@@ -3,22 +3,22 @@ import pandas as pd
|
|
3 |
import plotly.graph_objects as go
|
4 |
|
5 |
data = {
|
6 |
-
'years_after_diagnosis': [5, 8, 7, 7, 8, 7, 5, 6,
|
7 |
-
'age_at_diagnosis': [54, 41, 65, 85, 60, 66, 61,
|
8 |
-
'stage level': [6, 6, 5, 5, 10, 8, 6,
|
9 |
-
'status': [1, 1, 0, 1, 1, 1, 0,
|
10 |
}
|
11 |
|
12 |
df = pd.DataFrame(data)
|
13 |
|
14 |
def plot_probability_chart(years_after_diagnosis, age_at_diagnosis, stage_level, chemotherapy, brachtherapy,
|
15 |
-
chemoradiation, radiotherapy, radiation, menopause, MENO_post, HISTOLOGY, CM_1, CM_2, CM_3
|
16 |
match = df.loc[
|
17 |
(df['years_after_diagnosis'] == years_after_diagnosis) &
|
18 |
(df['age_at_diagnosis'] == age_at_diagnosis) &
|
19 |
(df['stage level'] == stage_level)
|
20 |
]
|
21 |
-
|
22 |
if len(match) == 0:
|
23 |
probability_alive = 0.5
|
24 |
probability_dead = 0.5
|
@@ -45,32 +45,8 @@ def plot_probability_chart(years_after_diagnosis, age_at_diagnosis, stage_level,
|
|
45 |
xaxis_title="Status",
|
46 |
yaxis_title="Probability",
|
47 |
)
|
48 |
-
return fig
|
49 |
-
|
50 |
-
if len(match) == 0:
|
51 |
-
return "No matching patient record found"
|
52 |
|
53 |
-
|
54 |
-
label = ["Alive", "Dead"]
|
55 |
-
if status == 0:
|
56 |
-
probability_alive = 0.2
|
57 |
-
probability_dead = 0.8
|
58 |
-
else:
|
59 |
-
probability_alive = 0.7
|
60 |
-
probability_dead = 0.3
|
61 |
-
|
62 |
-
fig = go.Figure(
|
63 |
-
go.Bar(
|
64 |
-
x=label,
|
65 |
-
y=[probability_alive, probability_dead]
|
66 |
-
)
|
67 |
-
)
|
68 |
-
fig.update_layout(
|
69 |
-
title="Survival Probability Chart",
|
70 |
-
xaxis_title="Status",
|
71 |
-
yaxis_title="Probability",
|
72 |
-
)
|
73 |
-
return fig
|
74 |
|
75 |
inputs = [
|
76 |
gr.inputs.Slider(minimum=0, maximum=10, step=1, default=5, label='years_after_diagnosis'),
|
@@ -86,8 +62,13 @@ inputs = [
|
|
86 |
gr.inputs.Slider(minimum=0, maximum=2, step=1, default=2, label='HISTOLOGY'),
|
87 |
gr.inputs.Checkbox(label='CM_1'),
|
88 |
gr.inputs.Checkbox(label='CM_2'),
|
89 |
-
gr.inputs.Checkbox(label='CM_3')
|
90 |
-
gr.inputs.Radio(["Alive", "Dead"], label="Status")
|
91 |
]
|
92 |
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import plotly.graph_objects as go
|
4 |
|
5 |
data = {
|
6 |
+
'years_after_diagnosis': [5, 8, 7, 7, 8, 7, 5, 6, 8, 5],
|
7 |
+
'age_at_diagnosis': [54, 41, 65, 85, 60, 66, 61, 55, 54, 48],
|
8 |
+
'stage level': [6, 6, 5, 5, 10, 8, 6, 3, 8, 6],
|
9 |
+
'status': [1, 1, 0, 1, 1, 1, 0, 0, 0, 0]
|
10 |
}
|
11 |
|
12 |
df = pd.DataFrame(data)
|
13 |
|
14 |
def plot_probability_chart(years_after_diagnosis, age_at_diagnosis, stage_level, chemotherapy, brachtherapy,
|
15 |
+
chemoradiation, radiotherapy, radiation, menopause, MENO_post, HISTOLOGY, CM_1, CM_2, CM_3):
|
16 |
match = df.loc[
|
17 |
(df['years_after_diagnosis'] == years_after_diagnosis) &
|
18 |
(df['age_at_diagnosis'] == age_at_diagnosis) &
|
19 |
(df['stage level'] == stage_level)
|
20 |
]
|
21 |
+
|
22 |
if len(match) == 0:
|
23 |
probability_alive = 0.5
|
24 |
probability_dead = 0.5
|
|
|
45 |
xaxis_title="Status",
|
46 |
yaxis_title="Probability",
|
47 |
)
|
|
|
|
|
|
|
|
|
48 |
|
49 |
+
return f"Patient Status: {label[status]}, Probability Score: {probability_alive if status == 1 else probability_dead}", fig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
inputs = [
|
52 |
gr.inputs.Slider(minimum=0, maximum=10, step=1, default=5, label='years_after_diagnosis'),
|
|
|
62 |
gr.inputs.Slider(minimum=0, maximum=2, step=1, default=2, label='HISTOLOGY'),
|
63 |
gr.inputs.Checkbox(label='CM_1'),
|
64 |
gr.inputs.Checkbox(label='CM_2'),
|
65 |
+
gr.inputs.Checkbox(label='CM_3')
|
|
|
66 |
]
|
67 |
|
68 |
+
title = "Cervical Cancer Survival Predictor"
|
69 |
+
subtitle = "Ojie, Deborah Voke (PG/2021/274546)"
|
70 |
+
description = f"<small><center>{subtitle}</center></small>"
|
71 |
+
|
72 |
+
interface = gr.Interface(fn=plot_probability_chart, inputs=inputs, outputs=["markdown", "plot"],
|
73 |
+
title=title, description=description, examples=None)
|
74 |
+
interface.launch()
|