def update_SIR_figure(country_drop_down): traces = [] df_plot = df_analyse[df_analyse['country'] == country_drop_down] df_plot = df_plot[['state', 'country', 'confirmed', 'date']].groupby(['country', 'date']).agg(np.sum).reset_index() df_plot.sort_values('date', ascending=True).head() df_plot = df_plot.confirmed[35:] t, fitted = SIR_modelling(df_plot) traces.append( dict(x=t, y=fitted, mode='markers+lines', opacity=8, name='SIR-curve')) traces.append( dict(x=t, y=df_plot, mode='lines', opacity=0.9, name='Original-curve')) return { 'data': traces, 'layout': dict(width=2200, height=800, title='SIR virus spread model', xaxis={ 'title': 'Days', 'tickangle': -45, 'nticks': 20, 'tickfont': dict(size=14, color="#7f7f7f"), }, yaxis={'title': "Infected population"}) }
def update_SIR_figure(country_drop_down): traces = [] df_plot = df_input_large[df_input_large['country'] == country_drop_down] df_plot = df_plot[[ 'state', 'country', 'confirmed', 'confirmed_filtered', 'date' ]].groupby(['country', 'date']).agg(np.sum).reset_index() df_plot.sort_values('date', ascending=True).head() df_plot = df_plot.confirmed[40:] t, fitted = SIR_modelling(df_plot) traces.append( dict(x=t, y=fitted, mode='markers', opacity=1.1, name='SIR-model-curve')) traces.append( dict(x=t, y=df_plot, mode='lines', opacity=0.7, name='Original Data curve')) return { 'data': traces, 'layout': dict(width=1200, height=700, title='SIR model fitting', xaxis={ 'title': 'Days', 'tickangle': -48, 'nticks': 21, 'tickfont': dict(size=16, color="#7f7f7f"), }, yaxis={'title': "Infected population"}) }
def SIR(countries): SIR_modelling()