Make Predictions of Integrands¶
Once we’ve fit to a database and/or made posterior samples, we can make predictions using the fit or sampled variables on the average integrand grid. This is how we make predictions for age groups and times on the IHME grid.
Predict Script¶
-
cascade_at.executor.predict.
fill_avgint_with_priors_grid
(inputs, alchemy, settings, source_db_path, child_locations, child_sexes)[source]¶ Fill the average integrand table with the grid that the priors are on. This is so that we can “predict” the prior for the next level of the cascade.
- Parameters
inputs (
MeasurementInputs
) – An inputs objectalchemy (
Alchemy
) – A grid alchemy objectsettings (
SettingsConfig
) – A settings configuration objectsource_db_path (
Union
[str
,Path
]) – The path of the source database that has had a fit on itchild_locations (
List
[int
]) – The child locations to predict forchild_sexes (
List
[int
]) – The child sexes to predict for
-
class
cascade_at.executor.predict.
Predict
(**kwargs)[source]¶ Bases:
cascade_at.dismod.api.multithreading._DismodThread
Predicts for a database in parallel. Chops up the sample table into a bunch of copies, each with only one sample.
-
cascade_at.executor.predict.
predict_sample_sequence
(path, table)[source]¶ Runs predict for either fit_var or sample, based on the table.
-
cascade_at.executor.predict.
predict_sample_pool
(main_db, index_file_pattern, n_sim, n_pool)[source]¶ Run predict sample in a pool by making copies of the existing database and splitting out the sample table into n_sim databases, running predict sample on each of them, and combining the results back into the main database.
-
cascade_at.executor.predict.
predict_sample
(model_version_id, parent_location_id, sex_id, child_locations, child_sexes, prior_grid=True, save_fit=False, save_final=False, sample=False, n_sim=1, n_pool=1)[source]¶ Takes a database that has already had a fit and simulate sample run on it, fills the avgint table for the child_locations and child_sexes you want to make predictions for, and then predicts on that grid. Makes predictions on the grid that is specified for the primary rates in the model, for the primary rates only.
- Parameters
model_version_id (
int
) – The model version IDparent_location_id (
int
) – The parent location ID that specifies where the database is storedsex_id (
int
) – The sex ID that specifies where the database is storedchild_locations (
List
[int
]) – The child locations to make predictions for on the rate gridchild_sexes (
List
[int
]) – The child sexes to make predictions for on the rate gridprior_grid (
bool
) – Whether or not to replace the default gbd-avgint grid with a prior grid for the rates.save_fit (
bool
) – Whether or not to save the fit for upload later.save_final (
bool
) – Whether or not to save the final for upload later.sample (
bool
) – Whether to predict from the sample table or the fit_var tablen_sim (
int
) – The number of simulations to predict forn_pool (
int
) – The number of multiprocessing pools to create. If 1, then will not run with pools but just run all simulations together in one dmdismod command.
- Return type
None
Predict Cascade Operation¶
-
class
cascade_at.cascade.cascade_operations.
Predict
(model_version_id, parent_location_id, sex_id, child_locations=None, child_sexes=None, prior_grid=True, save_fit=False, save_final=False, sample=True, **kwargs)[source]¶ Bases:
cascade_at.cascade.cascade_operations._CascadeOperation
The base class for a cascade operation.
- Parameters
upstream_commands – A list of commands that are upstream to this operation. This means that it will be run before this operation.
executor_parameters – Optional dictionary of execution parameters that updates the execution parameters
DEFAULT_EXECUTOR_PARAMETERS