bucky.model.optimize
¶
WIP prior optimization.
Module Contents¶
Functions¶
|
Load historical case and death data and filter to correct dates/counties. |
|
Extract numerical values of specified parameters from base params dictionary. |
|
Load historical hospitalization data and filter to correct dates/states. |
|
Function y = f(params, args) to be minimized. |
|
Ravel each element of arr, preserving first dimension. |
|
Build parameter dictionary from flattened values and ordered parameter names. |
|
Wrapper for calling the optimizer. |
Attributes¶
- bucky.model.optimize.BEST_OPT_FILE = best_opt.yml¶
- bucky.model.optimize.COLUMNS = ['daily_reported_cases', 'daily_deaths', 'daily_hospitalizations']¶
- bucky.model.optimize.DEFAULT_RET = 100000.0¶
- bucky.model.optimize.VALUES_FILE = values.csv¶
- bucky.model.optimize.case_death_df(first_day, adm2_filter)[source]¶
Load historical case and death data and filter to correct dates/counties.
- bucky.model.optimize.extract_values(base_params: dict, to_extract: list)[source]¶
Extract numerical values of specified parameters from base params dictionary.
For example, given the following (in yaml representation for clarity)
- base_params:
- Rt_fac:
dist: “approx_mPERT” mu: 1. gamma: 5. a: .9 b: 1.1
- R_fac:
dist: “approx_mPERT” mu: .5 a: .45 b: .55 gamma: 50.
- consts:
En: 3 Im: 3 Rhn: 3
- to_extract:
Rt_fac
R_fac
- consts:
En
Im
extract_values(base_params, to_extract) would return:
np.array([1., 5., .2, .5, 50., .1, 3, 3]), [(“Rt_fac”, [“mu”, “gamma”, “b-a”]), (“R_fac”, [“mu”, “gamma”, “b-a”]), (“consts”, [“En”, “Im”])]
- bucky.model.optimize.hosp_df(first_day, adm1_filter)[source]¶
Load historical hospitalization data and filter to correct dates/states.
- bucky.model.optimize.ravel_3d(arr)[source]¶
Ravel each element of arr, preserving first dimension.
- Parameters
arr (
numpy.ndarray
orcupy.ndarray
if using CuPy) –
- bucky.model.optimize.rebuild_params(values, keys)[source]¶
Build parameter dictionary from flattened values and ordered parameter names.
For example, given the following:
values = np.array([1., 5., .2, .5, 50., .1, 3, 3]), keys = [(“Rt_fac”, [“mu”, “gamma”, “b-a”]), (“R_fac”, [“mu”, “gamma”, “b-a”]), (“consts”, [“En”, “Im”])]
rebuild_params(values, keys) would return (in yaml representation for clarity):
- Rt_fac:
mu: 1. gamma: 5. a: .9 b: 1.1
- R_fac:
mu: .5 gamma: 50. a: .45 b: .55
- consts:
En: 3 Im: 3