forked from aoguedao/dinn_covid19
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamlit_app.py
More file actions
134 lines (114 loc) · 3.11 KB
/
streamlit_app.py
File metadata and controls
134 lines (114 loc) · 3.11 KB
1
2
3
4
5
6
7
8
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import numpy as np
import streamlit as st
from models.sird import run
st.set_page_config(
page_title="Disease Informed Neural Networks",
page_icon="🧬",
layout="wide",
)
st.title("COVID-19 and Disease Informed Neural Networks")
tab_sird, tab_help = st.tabs(["SIRD", "Help"])
with tab_sird:
st.latex(r"""
\begin{align*}
\frac{dS}{dt} &= - \frac{\beta}{N} S I \\
\frac{dI}{dt} &= \frac{\beta}{N} S I - \omega I - \gamma I \\
\frac{dR}{dt} &= \omega I \\
\frac{dD}{dt} &= \gamma I \\
\end{align*}
"""
)
col11, col12, col13, col14 = st.columns(4)
N = col11.number_input(
"N",
min_value=100,
max_value=10000,
value=1000,
step=100,
format=None,
help="Population",
)
beta = col12.number_input(
"Beta",
min_value=0.001,
max_value=1.0,
value=0.5,
step=0.001,
format=None,
help="Transmission Rate",
)
omega = col13.number_input(
"Omega",
min_value=0.001,
max_value=1.0,
value=1 / 14,
step=0.001,
format=None,
help="Rate at which Infected individuals become Recovered",
)
gamma = col14.number_input(
"Gamma",
min_value=0.001,
max_value=1.0,
value=1 / 5,
step=0.001,
format=None,
help="Rate at which Infected individuals become Dead",
)
col21, col22, col23 = st.columns(3)
iterations = col21.number_input(
"Iterations",
min_value=1000,
max_value=50000,
value=10000,
step=1000,
format=None,
help="Training iterations",
)
layers = col22.number_input(
"Layers",
min_value=1,
max_value=10,
value=3,
step=1,
format=None,
help="Neural Network hidden layers",
)
neurons = col23.number_input(
"Neurons",
min_value=8,
max_value=256,
value=64,
step=8,
format=None,
help="Neurons for each hidden layer",
)
if st.button("Run DINN"):
with st.spinner('Wait for it...'):
t_train = np.arange(0, 366, 3)[:, np.newaxis]
t_pred = np.arange(0, 366, 1)[:, np.newaxis]
parameters = {
"beta": beta,
"omega": omega,
"gamma": gamma,
}
hyperparameters = {
"search_range": (0.2, 1.8),
"iterations": iterations,
"layers": layers,
"neurons": neurons,
"activation": "relu",
"loss_weights": 4 * [1] + 4 * [1] + 4 * [1],
}
error_df, fig = run(
t_train=t_train,
t_pred=t_pred,
N=N,
parameters=parameters,
hyperparameters=hyperparameters
)
st.pyplot(fig)
st.table(error_df)
with tab_help:
st.header("Work in progress... Here is kitty.")
st.image("https://static.streamlit.io/examples/cat.jpg", width=200)