biogeme.sampling_of_alternatives.sampling_of_alternatives module¶
Module in charge of functionalities related to the sampling of alternatives
- author:
Michel Bierlaire
- date:
Thu Sep 7 10:14:54 2023
- class biogeme.sampling_of_alternatives.sampling_of_alternatives.SamplingOfAlternatives(context)[source]¶
Bases:
object
Class dealing with the various methods needed to estimate models with samples of alternatives
- Parameters:
context (SamplingContext)
- add_alphas(the_sample)[source]¶
Add the alpha parameters in the sampled database
- Return type:
DataFrame
- Parameters:
the_sample (DataFrame)
- sample_alternatives(chosen)[source]¶
Performing the sampling of alternatives
- Parameters:
chosen (
int
) – ID of the chosen alternative, that must be included in the choice set.- Return type:
DataFrame
- Returns:
data frame containing a sample of alternatives. The first one is the chosen alternative
- Raises:
BiogemeError – if the chosen alternative is unknown.
- biogeme.sampling_of_alternatives.sampling_of_alternatives.generate_segment_size(sample_size, number_of_segments)[source]¶
This function calculates the size of each segment, so that they are as close to each other as possible, and cover the full sample
- Parameters:
sample_size (int) – total size of the sample
number_of_segments (int) – number of segments
- Returns:
list of length number_of_segments, containing the segment sizes
- Return type:
list[int]