Input Demographics

There are two main demographic objects needed to pull data from the IHME databases, and more generally for building the cascade model.

Demographics

class cascade_at.inputs.demographics.Demographics(gbd_round_id, location_set_version_id=None)[source]

Bases: object

Grabs and stores demographic information needed for shared functions. Will also make a location hierarchy dag.

Parameters
  • gbd_round_id (int) – The GBD round

  • location_set_version_id (Optional[int]) – The location set version to use (right now EpiViz-AT is passing dismod location set versions, but this will eventually switch to the cause of death hierarchy that is more extensive).

Location Hierarchy

class cascade_at.inputs.locations.LocationDAG(location_set_version_id=None, gbd_round_id=None, df=None, root=None)[source]

Bases: object

Create a location DAG from the GBD location hierarchy, using networkx graph where each node is the location ID, and its properties are all properties from db_queries.

The root of this dag is the global location ID.

Parameters
  • location_set_version_id (Optional[int]) – The location set version corresponding to the hierarchy to pull from the IHME databases

  • gbd_round_id (Optional[int]) – Which gbd round the location set version is coming from

  • df (Optional[DataFrame]) – An optional df to pass instead of location sets and gbd rounds if you’d rather construct the DAG from a pandas data frame.

depth(location_id)[source]

Gets the depth of the hierarchy at this location.

Return type

int

descendants(location_id)[source]

Gets all descendants (not just direct children) for a location ID. :type location_id: int :param location_id: (int) :rtype: List[int] :return:

children(location_id)[source]

Gets the child location IDs.

Return type

List[int]

parent_children(location_id)[source]

Gets the parent and the child location IDs.

Return type

List[int]

is_leaf(location_id)[source]

Checks if a location is a leaf node in the tree.

Return type

bool

to_dataframe()[source]

Converts the location DAG to a data frame with location ID and parent ID and name. Helpful for debugging, and putting into the dismod database.

Return type

DataFrame

Returns

pd.DataFrame