biogeme.segmentation.one_segmentation module

Handles the segmentation of a single parameter using a discrete variable.

This class manages how a single Beta parameter is segmented according to a discrete variable. It generates distinct parameters for each category in the segmentation (except the reference), enabling models to estimate category-specific effects.

Attributes:

beta: The base Beta parameter being segmented. segmentation_tuple: The DiscreteSegmentationTuple defining the segmentation. variable: The discrete variable used for segmentation. reference: The reference category for the segmentation. mapping: Dictionary of category values to category names, excluding the reference.

class biogeme.segmentation.one_segmentation.OneSegmentation(beta, segmentation_tuple)[source]

Bases: object

Parameters:
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.

Return type:

str

Returns:

the Python code

beta_expression(category=None)[source]
Constructs the expression for the parameter associated with

a specific category

Parameters:

category (str | None) – name of the category. If None, it is the reference category.

Return type:

Beta

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

Return type:

str

Returns:

name of parameter for the category

Raises:

BiogemeError – if the category is not listed in the mapping of the segmentation.

list_of_code()[source]
Create a list of Python codes for the expressions involved

in the segmentation of the parameter

Return type:

list[str]

Returns:

list of codes

list_of_expressions()[source]

Create a list of expressions involved in the segmentation of the parameter

Returns:

list of expressions

Return type:

list(biogeme.expressions.Expression)