Skip to content

Conversation

quinn-dougherty
Copy link
Collaborator

@quinn-dougherty quinn-dougherty commented Mar 26, 2020

Closes #255

notebook for reference

found a clean way to do it in streamlit's UI that doesn't build up ugly technical debt.

TODO: need to rearrange the order in which computations happen in order to get it to actually work. in the notebook, inferred doubling time is a function of assumed doubling time, so i just need to make that work with autopopulating the form with a default (and not write myself into literal circles)

@quinn-dougherty
Copy link
Collaborator Author

inferred doubling time is a function of assumed doubling time

I was mistaken about this, sorry, correcting approach.

@quinn-dougherty
Copy link
Collaborator Author

quinn-dougherty commented Mar 26, 2020

Re Phil's comment. (streamlit's st.date_input)

Screenshot from 2020-03-26 17-17-03

Screenshot from 2020-03-26 17-17-16

@cjbayesian
Copy link
Collaborator

@quinn-dougherty That looks perfect. Just fix the typo -> "I know the date of the first [...]" (remove 'number of')

if p.n_days_since_first_hospitalized is not None:
# do not shorten this to `if foo:` form. if you do and n_days_since_first_hospitalized is 0,
# program will crash.
p.doubling_time = self.argmin_dt(np.linspace(1, 15, 29), p)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really horrifying thought, but is there a principled reason the doubling time can never be less than 1 day? Super-spreader events would seem to do exactly that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a hardcoded constant from Corey's notebook that we can factor into the settings.cfg file if we wish. since we're pushing to prod weekly, we only hope that things don't get that drastic too quickly ;)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More broadly, if the parameter sweep from argmin_dt returns a value at either extreme of its range, it means either

  • The best fit value is approximately the given limit
  • The fit failed because the true result is outside the range

We need to not let the latter case go through without warning or examination. It may just as well be an indicator of mis-keyed inputs, as of the math honestly saying anything about the circumstances.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a physical limit on doubling time down around 0.1, since that implies 10 daily doublings, or about 1000x, which exhausts itself pretty damn quickly. I think there's some threshold higher than that where we should warn the user that the computed value is implausibly low

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you're right. i'll add in some sort of warning system.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that a different merge allowed doubling time to be a float/fractional.

@PhilMiller
Copy link
Collaborator

A UI note for as this progresses: The number of days for which the user asks for a projection needs to be in addition to days in the back-cast - i.e. the admissions and census charts should run from -1*n_days_since_first_hospitalized to n_days

@quinn-dougherty
Copy link
Collaborator Author

@cjbayesian
your notebook has S, I, R = population_size-initial_i, initial_i, 0, your susceptible population is total_population - initial_infected.

This is not parity with prod. The codebase considers the entire total_population susceptible.

how should we proceed? initial_i (infected as we call it in prod) is 3 orders of magnitude smaller than total population, so it shouldn't be effecting our results right now.

@PhilMiller
Copy link
Collaborator

That would be #211, which I realized I need to go back and revise the fix in #212 for the big refactoring.

@cjbayesian
Copy link
Collaborator

Yep, @PhilMiller is right that I had fixed the susceptible calculation in the notebook per issue #211 .

@quinn-dougherty
Copy link
Collaborator Author

quinn-dougherty commented Mar 27, 2020

That would be #211, which I realized I need to go back and revise the fix in #212 for the big refactoring.
Yep, @PhilMiller is right that I had fixed the susceptible calculation in the notebook per issue #211.

#276 merged

@cjbayesian
Copy link
Collaborator

cjbayesian commented Mar 27, 2020

@PhilMiller and @quinn-dougherty : I have a coherent way to handle either case of user input (doubling_time or n_days_since_first_hospitalized) which addresses also #187 .

I just pushed an update to my notebook showing how. It's basically the same fitting procedure, just holding doubling_time constant and fitting n_days_since_first_hospitalized instead.

@quinn-dougherty
Copy link
Collaborator Author

Per Phil's comments, someone remind us to have a talk about what this np.linspace(1,15,29) should be set to before push to prod monday.

@quinn-dougherty
Copy link
Collaborator Author

  • not using vectorized argmin because i'm keeping track of state.
  • changed obs_pred_diff to loss_dt

pushing some commits without the 187 piggyback shortly

@quinn-dougherty
Copy link
Collaborator Author

quinn-dougherty commented Mar 27, 2020

I have a coherent way to handle either case of user input (doubling_time given n_days_since_first_hospitalized) which addresses also #187 .
I just pushed an update to my notebook showing how. It's basically the same fitting procedure, just holding doubling_time constant and fitting n_days_since_first_hospitalized instead.

sorry, this is gonna have to be another PR. racing to get the basics of 255 into Prod monday.

@quinn-dougherty
Copy link
Collaborator Author

there's a math error -- Corey's notebook infers a doubling time of 4 with similar initial conditions, my implementation infers a doubling time of 15 :(

I'll also recall Phil's warning, it's reporting the 15th day (the max of the range) as the doubling time on input 03-09-2020 (with checkbox "i know date of first hospitalized")
Screenshot from 2020-03-27 11-35-43

what Phil wrote:

More broadly, if the parameter sweep from argmin_dt returns a value at either extreme of its range, it means either

  • The best fit value is approximately the given limit
  • The fit failed because the true result is outside the range
    We need to not let the latter case go through without warning or examination. It may just as well be an indicator of mis-keyed inputs, as of the math honestly saying anything about the circumstances.

@quinn-dougherty
Copy link
Collaborator Author

TODO:

  • implement warning if inferred doubling time is at the top or the bottom of its search space.

recovered,
beta,
gamma,
p.n_days
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be p.n_days + p.n_days_since_first_hospitalization?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all i'll say is that wouldn't be parity with the notebook. @cjbayesian

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so we'll fix this later then. We really want the raw_df to hold all of the data instead of having to bodge n_days_since... into every function.

I'll get a copy of the notebook and test for equivalent output later.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, this input can no longer be described as the number of days to project as stated in the ui. It is projecting less than n_days, it is projecting from the first infection. The ui / users here will be confusing / confused.

@quinn-dougherty
Copy link
Collaborator Author

quinn-dougherty commented Mar 27, 2020

hi -- are we ok if i piggyback updating settings.py in here? i'm trying to achieve parity with the notebook. i'm assuming it'll happen before monday anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle 'mid-growth stage' ["model"]
4 participants