bucky.model.optimize
WIP prior optimization.
case_death_df(first_day: datetime.datetime, adm2_filter: xp.ndarray) → pd.DataFrame
case_death_df
Load historical case and death data and filter to correct dates/counties.
extract_values(base_params: dict, to_extract: list)
extract_values
Extract numerical values of specified parameters from base params dictionary.
hosp_df(first_day: datetime.datetime, adm1_filter: xp.ndarray) → pd.DataFrame
hosp_df
Load historical hospitalization data and filter to correct dates/states.
opt_func(params, args)
opt_func
Function y = f(params, args) to be minimized.
ravel_3d(a: xp.ndarray)
ravel_3d
Ravel each element of a, preserving first dimension.
rebuild_params(values, keys)
rebuild_params
Build parameter dictionary from flattened values and ordered parameter names.
test_opt(env)
test_opt
Wrapper for calling the optimizer.
bucky.model.optimize.
BEST_OPT_FILE
COLUMNS
DEFAULT_RET
VALUES_FILE
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
dist: “approx_mPERT” mu: 1. gamma: 5. a: .9 b: 1.1
dist: “approx_mPERT” mu: .5 a: .45 b: .55 gamma: 50.
En: 3 Im: 3 Rhn: 3
Rt_fac
R_fac
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”])]
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
mu: 1. gamma: 5. a: .9 b: 1.1
mu: .5 gamma: 50. a: .45 b: .55
En: 3 Im: 3
bucky.model.npi
bucky.model.parameters