Skip to content

Instantly share code, notes, and snippets.

@rvipandey
Last active June 27, 2020 18:52
Show Gist options
  • Save rvipandey/db7718fe97a363e30e71782d4ba24ca5 to your computer and use it in GitHub Desktop.
Save rvipandey/db7718fe97a363e30e71782d4ba24ca5 to your computer and use it in GitHub Desktop.
indiapopulation=1380004385
fmodel=population[population.Confirmed>=50]
fmodel['day_count']=list(range(1,len(fmodel)+1))
fmodel['increase'] = (fmodel.Confirmed-fmodel.Confirmed.shift(1)).fillna(0).astype(int)
fmodel['increaserate']=(fmodel['increase']/fmodel["Confirmed"])
fmodel['Active']=fmodel['Confirmed']-fmodel['Deceased']-fmodel['Recovered']
xdata = np.array(list(abs(fmodel.day_count)))
ydata = np.array(list(abs(fmodel.Active)))
cof,cov = curve_fit(sigmoid, xdata, ydata, method='trf',bounds=([0.,0., 0.],[indiapopulation,1, 100.]))
x = np.linspace(-1, fmodel.day_count.max()+20, 20)
y = sigmoid(x,cof[0],cof[1],cof[2])
fig = go.Figure()
fig.add_trace(go.Scatter(x=x, y=y,
mode="lines+text",
name='Active Cases Approx',
marker_color='orange',
))
fig.add_trace(go.Scatter(x=xdata, y=ydata,
mode="markers",
name='Active Cases',
marker_color='Green',
marker_line_width=2, marker_size=10
))
fig
fig.update_layout(
title='Daily Active Cases in India is approx '+ str(int(cof[0])) +', Active cases curve started flatten from day ' + str(int(cof[2])) +" and will flatten by day "+str(round(int(cof[2])*2.5)),
template='gridon', font=dict(
family="Courier New, monospace",
size=10,
color="blue"
))
fig.show()
#Total Active Case
print(round(fmodel.Active.sum()+((fmodel.day_count.max()+40-fmodel.day_count.max())*y[11:20].mean())))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment