Tensorflow recently made a tutorial titled Estimation of undocumented SARS-CoV2 cases. It replicates 6th March 2020 paper by Li et al titled Substantial Undocumented Infection Facilitates the Rapid Dissemination of Novel Coronavirus (SARS-CoV2). It is a compartment based SEIR model where the population is represented by a state with compartments Susceptible, Exposed, Undocumented Infectious and Documented Infectious.

I am trying to test the validity of this model by training it with data for 30 days, and forecast the state for next 15 days. I did find the optimal parameters of the model and current state, but I am not sure how I can use it to predict future states. I have been attempting this for almost a week now. The programming style in the notebook is quite unfamiliar to me, hence, I am struggling to figure out how exactly to do it.

I request someone with more experience to go through the notebook once and give me suggestions about how to predict the states.

Thank you!


1 Answer 1


To summarize, the notebook describes three key components:

  • The state, which completely describes the system at any given time. A SEIR model by definition has four variables in the state: susceptible, exposed, infected, and reported.
  • The dynamics, which describe how the states evolve over time.
  • The measured parameters for the dynamic equations: $\beta$, $\mu$, $\theta$, $Z$, $\alpha$, and $D$. Note, these parameters are (for our purposes) constant.

The tutorial walks you through measuring the parameters. The logic is:

  • You know your state for 30 consecutive days
  • You know that one day progresses to the next through the dynamics equations
  • So, you can solve for the parameters that maximize the accuracy of your model

Now that you have the parameters, your goal is to make predictions for the future. This is "just" a matter of plugging your parameters into the dynamics equations and doing the math.

Now solving six coupled differential equations is rarely easy, but they've done much of the heavy lifting for you. In particular, the function transition_fn is pretty much exactly what you want: it takes the current state, current time, and some "extra" information (defined in the tutorial) and produces the prediction for the next state.

So I think what you need to do is:

  1. Figure out how to call transition_fn. You'll have to define state_params and extra in exactly the right format. The parameters you calculated in the tutorial will become part of extra
  2. Start by using the same time period that the tutorial uses. This is "cheating" a bit, since you used the data to derive your parameters and now you're using the parameters to predict the data. But this is a good "sanity check": your predictions should definitely be accurate here, so you'll be able to identify any problems.
  3. Then, use a different time period to assess whether the model is useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.