Last active
June 27, 2020 18:51
-
-
Save rvipandey/6c865dd46fc0c6375f3ee2465b899115 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xdata = np.array(list(abs(fmodel.day_count))) | |
ydata = np.array(list(abs(fmodel.Confirmed))) | |
cof,cov = curve_fit(sigmoid, xdata, ydata, method='trf',bounds=([0.,0., 0.],[indiapopulation,1, 100.])) | |
#‘trf’ : Trust Region Reflective algorithm, particularly suitable for large sparse problems with bounds. Generally robust method. | |
x = np.linspace(-1, fmodel.day_count.max()+40, 40) | |
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='Confirmed Cases Approx', | |
marker_color='Orange', | |
)) | |
fig.add_trace(go.Scatter(x=xdata, y=ydata, | |
mode="markers", | |
name='Confirm Cases', | |
marker_color='Red', | |
marker_line_width=2, marker_size=10 | |
)) | |
fig | |
fig.update_layout( | |
title='Daily Confirmed Cases in India is approx '+ str(int(cof[0])) +', Confirm case 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=7, | |
color="blue" | |
)) | |
fig.show() | |
#Total Confirmed Case | |
print(round(fmodel.Confirmed.sum()+((fmodel.day_count.max()+40-fmodel.day_count.max())*y[21:40].mean()))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment