bucky.model.optimize

WIP prior optimization.

Module Contents

Functions

case_death_df(first_day: datetime.datetime, adm2_filter: xp.ndarray) → pd.DataFrame

Load historical case and death data and filter to correct dates/counties.

extract_values(base_params: dict, to_extract: list)

Extract numerical values of specified parameters from base params dictionary.

hosp_df(first_day: datetime.datetime, adm1_filter: xp.ndarray) → pd.DataFrame

Load historical hospitalization data and filter to correct dates/states.

opt_func(params, args)

Function y = f(params, args) to be minimized.

ravel_3d(a: xp.ndarray)

Ravel each element of a, preserving first dimension.

rebuild_params(values, keys)

Build parameter dictionary from flattened values and ordered parameter names.

test_opt(env)

Wrapper for calling the optimizer.

bucky.model.optimize.BEST_OPT_FILE = best_opt.yml[source]
bucky.model.optimize.COLUMNS = ['daily_reported_cases', 'daily_deaths', 'daily_hospitalizations'][source]
bucky.model.optimize.DEFAULT_RET = 100000.0[source]
bucky.model.optimize.VALUES_FILE = values.csv[source]
bucky.model.optimize.case_death_df(first_day: datetime.datetime, adm2_filter: xp.ndarray) → pd.DataFrame[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: datetime.datetime, adm1_filter: xp.ndarray) → pd.DataFrame[source]

Load historical hospitalization data and filter to correct dates/states.

bucky.model.optimize.opt_func(params, args)[source]

Function y = f(params, args) to be minimized.

bucky.model.optimize.ravel_3d(a: xp.ndarray)[source]

Ravel each element of a, preserving first dimension.

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

bucky.model.optimize.test_opt(env)[source]

Wrapper for calling the optimizer.