Cascade Operation Sequences

Cascade Operation Stacking Functions

These functions make sequences of _CascadeOperation and the appropriate upstream dependencies. They can then be used together to create a _CascadeCommand.

cascade_at.cascade.cascade_stacks.single_fit(model_version_id, location_id, sex_id)[source]

Create a sequence of tasks to do a single fit both model. Configures inputs, does a fit fixed, then fit both, then predict and uploads the result. Will fit the model based on the settings attached to the model version ID.

Parameters
  • model_version_id (int) – The model version ID.

  • location_id (int) – The parent location ID to run the model for.

  • sex_id (int) – The sex ID to run the model for.

Returns

Return type

List of CascadeOperations.

cascade_at.cascade.cascade_stacks.single_fit_with_uncertainty(model_version_id, location_id, sex_id, n_sim=100, n_pool=20, skip_configure=False, ode_fit_strategy=True)[source]

Create a sequence of tasks to do a single fit both model. Configures inputs, does a fit fixed, then fit both, then predict and uploads the result. Will fit the model based on the settings attached to the model version ID.

Parameters
  • model_version_id (int) – The model version ID.

  • location_id (int) – The parent location ID to run the model for.

  • sex_id (int) – The sex ID to run the model for.

  • n_sim (int) – The number of simulations to do, number of draws to make

  • n_pool (int) – The number of multiprocessing pools to use in creating the draws

Returns

Return type

List of CascadeOperations.

cascade_at.cascade.cascade_stacks.root_fit(model_version_id, location_id, sex_id, child_locations, child_sexes, skip_configure=False, mulcov_stats=True, n_sim=100, n_pool=20, ode_fit_strategy=True)[source]

Create a sequence of tasks to do a top-level prior fit. Does a fit fixed, then fit both, then creates posteriors that can be used as priors later on. Saves its fit to be uploaded.

Parameters
  • model_version_id (int) – The model version ID.

  • location_id (int) – The parent location ID to run the model for.

  • sex_id (int) – The sex ID to run the model for.

  • child_locations (List[int]) – The children to fill the avgint table with

  • child_sexes (List[int]) – The sexes to predict for.

  • skip_configure (bool) – Don’t run a task to configure the inputs. Only do this if it has already happened. This disables building the inputs.p and setting.json files.

  • mulcov_stats (bool) – Compute mulcov statistics at this level

  • n_sim (int) –

  • n_pool (int) –

Returns

Return type

List of CascadeOperations.

cascade_at.cascade.cascade_stacks.branch_fit(model_version_id, location_id, sex_id, prior_parent, prior_sex, child_locations, child_sexes, upstream_commands=None, n_sim=100, n_pool=20, ode_fit_strategy=False)[source]

Create a sequence of tasks to do a cascade fit (mid-level). Does a fit fixed, then fit both, predicts on the prior rate grid to create posteriors that can be used as priors later on. Saves its fit to be uploaded.

Parameters
  • model_version_id (int) – The model version ID.

  • location_id (int) – The parent location ID to run the model for.

  • sex_id (int) – The sex ID to run the model for.

  • prior_parent (int) – The location ID corresponding to a database to pull the prior from

  • prior_sex (int) – The sex ID corresponding to a database to pull the prior from

  • child_locations (List[int]) – The children to fill the avgint table with

  • child_sexes (List[int]) – The sexes to predict for.

  • upstream_commands (Optional[List[str]]) – Commands that need to be run before this stack.

Returns

Return type

List of CascadeOperations.

cascade_at.cascade.cascade_stacks.leaf_fit(model_version_id, location_id, sex_id, prior_parent, prior_sex, n_sim=100, n_pool=20, upstream_commands=None, ode_fit_strategy=False)[source]

Create a sequence of tasks to do a for a leaf-node fit, no children. Does a fit fixed then sample simulate to create posteriors. Saves its fit to be uploaded.

Parameters
  • model_version_id (int) – The model version ID.

  • location_id (int) – The parent location ID to run the model for.

  • sex_id (int) – The sex ID to run the model for.

  • prior_parent (int) – The location ID corresponding to a database to pull the prior from

  • prior_sex (int) – The sex ID corresponding to a database to pull the prior from

  • n_sim (int) – The number of simulations to do to get the posterior fit.

  • n_pool (int) – The number of pools to use to do the simulation fits.

  • upstream_commands (Optional[List[str]]) – Commands that need to be run before this stack.

Returns

Return type

List of CascadeOperations.