-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add helper data PyrenewHEWData
class to hold input data to PyrenewHewModel
s
#283
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #283 +/- ##
==========================================
- Coverage 15.87% 15.63% -0.25%
==========================================
Files 21 22 +1
Lines 1537 1561 +24
==========================================
Hits 244 244
- Misses 1293 1317 +24
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks mostly good to me. Just few comments/questions for clarification.
] | ||
|
||
@property | ||
def last_data_dates(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this better as a dictionary?
) | ||
|
||
@property | ||
def first_data_dates(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this better as a dictionary?
|
||
@property | ||
def first_data_date_overall(self): | ||
return min([x for x in self.first_data_dates if x is not None]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return min([x for x in self.first_data_dates if x is not None]) | |
return min(filter(None, self.first_data_dates)) |
|
||
@property | ||
def last_data_date_overall(self): | ||
return max([x for x in self.last_data_dates if x is not None]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return max([x for x in self.last_data_dates if x is not None]) | |
return max(filter(None, self.last_data_dates)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we prune the data_for_model_fit.json
object to only supply the info necessary to create pyrenew_hew_data?
n_init_days = self.latent_infection_process_rv.infection_initialization_process.infection_init_method.n_timepoints | ||
first_latent_infection_dow = ( | ||
data.first_data_date_overall - datetime.timedelta(days=n_init_days) | ||
).weekday() | ||
|
||
sampled_ed_visits, sampled_admissions, sampled_wastewater = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight preference for
sampled_ed_visits, sampled_admissions, sampled_wastewater = ( | |
sampled_ed_visits = sampled_admissions = sampled_wastewater = None |
or
sampled_ed_visits, sampled_admissions, sampled_wastewater = ( | |
sampled_ed_visits = None | |
sampled_admissions = None | |
sampled_wastewater = None |
self.ihr_rv = ihr_rv | ||
self.ihr_rel_iedr_rv = ihr_rel_iedr_rv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check that at most one of these is not None
?
|
||
hospital_admissions_obs_rv = NegativeBinomialObservation( | ||
"observed_hospital_admissions", | ||
concentration_rv=self.hosp_admit_neg_bin_concentration_rv, | ||
) | ||
predicted_admissions = latent_hospital_admissions | ||
|
||
sampled_admissions = hospital_admissions_obs_rv( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sampled_admissions = hospital_admissions_obs_rv( | |
observed_hospital_admissions = hospital_admissions_obs_rv( |
and rename in the return
else: | ||
ihr = self.ihr_rv() | ||
|
||
latent_admissions = population_size * ihr * latent_infections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a better name. Or just pass latent_incidence=population_size * ihr * latent_infections
in to compute_delay_ascertained_incidence
@@ -227,61 +234,89 @@ def sample( | |||
concentration_rv=self.ed_neg_bin_concentration_rv, | |||
) | |||
|
|||
observed_ed_visits = ed_visit_obs_rv( | |||
sampled_ed_visits = ed_visit_obs_rv( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sampled_ed_visits = ed_visit_obs_rv( | |
observed_ed_visits = ed_visit_obs_rv( |
also change the return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left many comments, none of which are mandatory.
Main change
Add
PyrenewHEWData
This:
if is None
conditionals from the mainmodel.sample()
code.to_forecast_data()
transformation helper for posterior prediction.Additional changes:
create_pyrenew_hew_model_from_stan_data()
and hosp_only_ww_model/pyrenew_hew_model.qmd, closing Removecreate_pyrenew_hew_model_from_stan_data
? #280