Skip to content

Instantly share code, notes, and snippets.

@liannewriting
Created March 10, 2020 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liannewriting/ab23ea2f38364e9c19f08ba07ffa8c37 to your computer and use it in GitHub Desktop.
Save liannewriting/ab23ea2f38364e9c19f08ba07ffa8c37 to your computer and use it in GitHub Desktop.
coronavirus-death-rate-recovery-hyperparameter-tuning-202003
# pick a set of parameters that resulted in a low loss.
ttd_scale = 63.696418
ttd_shape = 0.968338
ttr_scale = 15.034069
ttr_shape = 1.851922
death_rate = 0.218912
# run the simulation with the parameters.
df_res, loss = run_sim(ttd_scale=ttd_scale, ttd_shape=ttd_shape, ttr_scale=ttr_scale, ttr_shape=ttr_shape, death_rate=death_rate)
loss
# visualize how well it fits recoveries.
sns.lineplot(x="Date", y="New_Recovered", data=df_res, label='New_Recovered')
sns.lineplot(x="Date", y="pred_new_recoveries", data=df_res, label='pred_new_recoveries')
import scipy.stats as stats
# look at the shape of the time to recovery distribution.
x = np.linspace (0, 100, 200)
y = stats.gamma.pdf(x, a=ttr_shape, scale=ttr_scale)
sns.lineplot(x=x, y=y)
# visualize how well it fits deaths.
sns.lineplot(x="Date", y="New_Deaths", data=df_res, label='New_Deaths')
sns.lineplot(x="Date", y="pred_new_deaths", data=df_res, label='pred_new_deaths')
import scipy.stats as stats
# look at the shape of the time to recovery distribution.
x = np.linspace (0, 100, 200)
y = stats.gamma.pdf(x, a=ttd_shape, scale=ttd_scale)
sns.lineplot(x=x, y=y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment