MultiCostDistribution#

class caf.distribute.gravity_model.multi_area.MultiCostDistribution(distributions)#

Bases: object

Cost distributions to be used for the multi-cost distribution gravity model.

Parameters:

distributions (list[MGMCostDistribution]) – Distributions to be used for the multicost distributions

Attributes Summary

Methods Summary

copy()

Get a copy of the object.

from_pandas(ordered_zones, tld, ...[, ...])

Build class using pandas dataframes.

validate(distributions)

Check the distributions passed.

Attributes Documentation

distributions: list[MGMCostDistribution] = <dataclasses._MISSING_TYPE object>#

Methods Documentation

copy()#

Get a copy of the object.

Returns:

Deep copy of the object

Return type:

MultiCostDistribution

classmethod from_pandas(ordered_zones, tld, cat_zone_correspondence, func_params, *, tld_cat_col='category', tld_min_col='from', tld_max_col='to', tld_avg_col='av_distance', tld_trips_col='trips', lookup_cat_col='category', lookup_zone_col='zone_id')#

Build class using pandas dataframes.

Parameters:
  • ordered_zones (pd.Series) – list of zones in the same order as other inputs

  • tld (pd.DataFrame) – tld data - should contain the tlds for each distribution labeled by the tld_cat_col

  • cat_zone_correspondence (pd.DataFrame) – lookup between categories values within tld and zones which use the corresponding distribution

  • func_params (dict[int | str, dict[str, float]]) – starting/run cost function params to use for each distribution key: distribution category, value: dict[param name, param value]

  • tld_cat_col (str, optional) – column name for the category column in tld, by default “category”

  • tld_min_col (str, optional) – column name for the min bin edge column in tld, by default “from”

  • tld_max_col (str, optional) – column name for the max bin edge column in tld, by default “to”

  • tld_avg_col (str, optional) – column name for the average distance column in tld, by default “av_distance”

  • tld_trips_col (str, optional) – column name for the trips column in tld, by default “trips”

  • lookup_cat_col (str, optional) – column name for the category column in cat_zone_correspondence, by default “category”

  • lookup_zone_col (str, optional) – column name for the zone column in cat_zone_correspondence, by default “zone_id”

Return type:

MultiCostDistribution

Raises:

KeyError – when a category value is not founf in the function parameter keys

See also

None

classmethod validate(distributions)#

Check the distributions passed.

Raises an error if duplicate zones are found across different distributions.

Parameters:

distributions (list[MGMCostDistribution]) – Distributions to validate

Raises:
  • ValueError – The length of the list of the distributions passed is 0

  • ValueError – The same zones are found in multiple distributions