lisphilar / covid19-sir

CovsirPhy: Python library for COVID-19 analysis with phase-dependent SIR-derived ODE models.
https://lisphilar.github.io/covid19-sir/
Apache License 2.0
109 stars 44 forks source link

[Discuss] Add Date column to phase_estimator df #503

Closed rebeccadavidsson closed 3 years ago

rebeccadavidsson commented 3 years ago

It would be useful if the dataframe also has a 'Date' column, that's now being returned from:

snl.estimate(cs.SIRF, phases=["1st"])
df = snl.phase_estimator(phase="1st").accuracy()

There is a t column, however it's hard to relate this column to the original date. Schermafbeelding 2021-01-07 om 10 18 13

Temporary Solution

df["Date"] = data.iloc[-len(df):]["Date"].values
df.plot(x="Date", y=["Infected_actual", "Infected_predicted"]);

Also, the y-axis range could be smaller/in range of the data: image

Inserting the date would also allow the phase_estimator() function to have multiple phases as input, eventually creating an overview of the accuracy along each phase.

lisphilar commented 3 years ago

Did you try snl.history("Infected")?

# Disable all phases except for 1st and 2nd phases
all_phases = snl.summary().index.tolist()
snl.disable(phases=all_phases)
snl.enable(phases=["1st", "2nd"])
# Parameter estimation
snl.estimate(cs.SIRF)
# Compare actual values and estimated values
snl.history("Infected")

Figure_1

For enhancement, we will add the following features.

If this is a good solution for you, I will create issues later. Do you have time to create pull requests?

rebeccadavidsson commented 3 years ago

Great, thank you!

lisphilar commented 3 years ago

We wiil move forward to #510, #511 and #512.