Jiranuwat commited on
Commit
833b190
·
1 Parent(s): 69589ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -111,7 +111,7 @@ def SIR(country,R0,t_infective):
111
 
112
  return R0,t_infective,beta,gamma,rmpe,plotdata(t, s, i,r,R0)
113
 
114
- def compare_plt(country):
115
  fig = plt.figure(figsize=(12,6))
116
  ax = [fig.add_subplot(121, axisbelow=True),fig.add_subplot(122)]
117
  ax[0].set_title('Monkeypox confirmed cases')
@@ -120,7 +120,7 @@ def compare_plt(country):
120
  ax[0].set_ylabel('Number of cases')
121
  ax[0].legend()
122
 
123
- scaler = all_location[country]['total_cases'].apply(lambda x : x/pop_dict[country])
124
  ax[1].set_title('Monkeypox confirmed cases compare with model')
125
  ax[1].plot(scaler,lw=3,label='Real Infective')
126
  ax[1].plot(i,lw=3,label='SIR model Infective')
@@ -141,6 +141,7 @@ def main():
141
  recovery = st.slider("How long Monkeypox recover?", 21, 31, 21)
142
  R0 = st.slider("Basic Reproduction Number (R0)", 0.57, 3.00, 0.57)# user's input
143
  country_code = code[country][0]
 
144
 
145
  # clicked==True only when the button is clicked
146
  clicked = st.form_submit_button("Show Graph")
@@ -150,7 +151,7 @@ def main():
150
  SIR_param = SIR(country_code,R0,recovery)
151
 
152
  st.pyplot(SIR_param[-1])
153
- st.pyplot(compare_plt(country_code))
154
  st.success("SIR model parameters for "+str(country)+" is")
155
  st.success("R0 = "+str(SIR_param[0]))
156
  st.success("Beta = "+str(SIR_param[2]))
 
111
 
112
  return R0,t_infective,beta,gamma,rmpe,plotdata(t, s, i,r,R0)
113
 
114
+ def compare_plt(country,pop):
115
  fig = plt.figure(figsize=(12,6))
116
  ax = [fig.add_subplot(121, axisbelow=True),fig.add_subplot(122)]
117
  ax[0].set_title('Monkeypox confirmed cases')
 
120
  ax[0].set_ylabel('Number of cases')
121
  ax[0].legend()
122
 
123
+ scaler = all_location[country]['total_cases'].apply(lambda x : x/pop)
124
  ax[1].set_title('Monkeypox confirmed cases compare with model')
125
  ax[1].plot(scaler,lw=3,label='Real Infective')
126
  ax[1].plot(i,lw=3,label='SIR model Infective')
 
141
  recovery = st.slider("How long Monkeypox recover?", 21, 31, 21)
142
  R0 = st.slider("Basic Reproduction Number (R0)", 0.57, 3.00, 0.57)# user's input
143
  country_code = code[country][0]
144
+ pop = pop_dict[country_code]
145
 
146
  # clicked==True only when the button is clicked
147
  clicked = st.form_submit_button("Show Graph")
 
151
  SIR_param = SIR(country_code,R0,recovery)
152
 
153
  st.pyplot(SIR_param[-1])
154
+ st.pyplot(compare_plt(country_code,pop))
155
  st.success("SIR model parameters for "+str(country)+" is")
156
  st.success("R0 = "+str(SIR_param[0]))
157
  st.success("Beta = "+str(SIR_param[2]))