biogeme.segmentation module
Class that provides some automatic specification for segmented parameters
- author:
Michel Bierlaire
- date:
Thu Feb 2 09:42:36 2023
- class biogeme.segmentation.DiscreteSegmentationTuple(variable, mapping, reference=None)[source]
Bases:
object
Characterization of a segmentation
- Parameters:
variable (Variable | str)
mapping (dict[int, str])
reference (str | None)
- class biogeme.segmentation.OneSegmentation(beta, segmentation_tuple)[source]
Bases:
object
Single segmentation of a parameter
- Parameters:
beta (biogeme.expressions.Beta)
segmentation_tuple (DiscreteSegmentationTuple)
- beta_code(category, assignment)[source]
- Constructs the Python code for the expression of the
parameter associated with a specific category
- Parameters:
category (str) – name of the category
assignment (bool) – if True, the code includes the assignment to a variable.
- Returns:
the Python code
- Return type:
str
- beta_expression(category)[source]
- Constructs the expression for the parameter associated with
a specific category
- Parameters:
category (str) – name of the category
- Return type:
- Returns:
expression of the parameter for the category
- beta_name(category)[source]
Construct the name of the parameter associated with a specific category
- Parameters:
category (str) – name of the category
- Returns:
name of parameter for the category
- Return type:
str
- Raises:
BiogemeError – if the category is not listed in the mapping of the segmentation.
- class biogeme.segmentation.Segmentation(beta, segmentation_tuples, prefix='segmented')[source]
Bases:
object
Segmentation of a parameter, possibly with multiple socio-economic variables
- Parameters:
beta (biogeme.expressions.Beta)
segmentation_tuples (Iterable[DiscreteSegmentationTuple])
prefix (str)
- beta_code()[source]
Constructs the Python code for the parameter
- Returns:
Python code
- Return type:
str
- biogeme.segmentation.segment_parameter(beta, segmentation_tuples, prefix='segmented')[source]
Warning
This function is deprecated. Use
segmented_beta()
instead.- Parameters:
beta (Beta)
segmentation_tuples (Iterable[DiscreteSegmentationTuple])
prefix (str)
- biogeme.segmentation.segmented_beta(beta, segmentation_tuples, prefix='segmented')[source]
Obtain the segmented Beta from a unique function call
- Parameters:
beta (
Beta
) – parameter to be segmentedsegmentation_tuples (
Iterable
[DiscreteSegmentationTuple
]) – characterization of the segmentationsprefix (
str
) – prefix to be used to generated the name of the segmented parameter
- Returns:
expression of the segmented Beta