Created
March 16, 2020 23:00
-
-
Save santiagocasas/4245c69dfd173deb7c47aa2624d1f522 to your computer and use it in GitHub Desktop.
prediction
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
chosenmodel='Logistic' | |
if chosenmodel=="Logistic": | |
print("Chosen Model: ", chosenmodel) | |
reg_model = logistic_model | |
elif chosenmodel=='Gompertz': | |
print("Chosen Model: ", chosenmodel) | |
reg_model = gompertz_model | |
for country in countries_list: | |
print("\n ***Country: "+str(country)) | |
x = np.array(list(df_dict[country]['DayCount'].values)) | |
print("Used data, Day Count: ", x[-1+leaveout]) | |
print("Used data, Last day date: ", datetime.strftime(df_dict[country].index[-1+leaveout], ' %d, %b %Y' )) | |
y = np.array(list(df_dict[country]['Cases'].values)) | |
print("Used data, Number of cases: "+casestr+" in the last day: ", y[-1+leaveout]) | |
print("---") | |
pred_days = 0 | |
day = x[-1]+pred_days | |
pred_date = datetime.strftime(df_dict[country].index[-1] + timedelta(days=pred_days), ' %d, %b %Y' ) | |
print("Prediction for: ", pred_date) | |
realdat = y[-1] | |
a,b,c = (c_pars[(country,chosenmodel,par)] for par in ['a','b','c']) | |
sigma_a,sigma_b,sigma_c = (c_pars[(country,chosenmodel,par)] for par in ['sga','sgb','sgc']) | |
prediction = reg_model(day,a,b,c) | |
pluspred = np.abs(reg_model(day,np.abs(a+sigma_a),np.abs(b+sigma_b),np.abs(c+sigma_c))) | |
minuspred = np.abs(reg_model(day,np.abs(a-sigma_a),np.abs(b-sigma_b),np.abs(c-sigma_c))) | |
print("Prediction from "+chosenmodel+" Model : ", frm(prediction), ' ( +'+frm(pluspred-prediction)+', -'+frm(prediction-minuspred)+')') | |
print("Real data: ", frm(realdat)) | |
prediction_error_perc = 100*(prediction-realdat)/realdat | |
print("Prediction Percentage error: ", '{:2f}'.format(prediction_error_perc), '%') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment