champpy.Parameterizer¶
The Parameterizer class is the factory class to calculate the model parameters ModelParams required as input for the mobility model MobModel.
The Parameterizer uses cleaned reference mobility profiles MobProfiles and user parameters UserParamsParameterizer as inputs.
Basic workflow:
Initialize the parameterizer
Parameterizerwith user parametersUserParamsParameterizer.Call
calculate_params()to calculate the model parametersModelParamsusing the cleaned reference mobility profilesMobProfilesas input.The calculated
ModelParamsinstance can be further used forMobModel.
The model parameters ModelParams have the following structure:
ModelParams
├── df # Dataframe holding the model parameters
└── info # Meta information about the parameters
Besided the Parameterizer, existing parameters can be loaded using the ModelParamsLoader class.
- class champpy.Parameterizer(user_params)[source]¶
Class to determine the paramerters for the mobility model.
The Parameterizer is a factory class to calculate the parameters for the mobility model based on cleaned mobility data and user-defined parameters. The main method is
calc_params(), which takes cleaned mobility data as input and returns the calculated parameters asModelParams.- Parameters:
user_params (
UserParamsParameterizer) – User paramerters for the parameterization
- calc_params(ref_profiles)[source]¶
Calculate parameters for the mobility model.
Main method to calculate parameters for the mobility model based on cleaned mobility data and user-defined parameters. The function performs the following steps for each cluster and weekday combination:
Calculate percentage of clusters based on number of days per cluster
Extend reference data to include weekday and day index
Reindex locations to consecutive integers starting from 1 (keep 0 as is)
Calculate transition matrices for each cluster and weekday combination
Fit Beta distributions for speed parameters binned by trip duration
- Parameters:
ref_profiles (
MobProfiles) – Cleaned mobility data to be used as reference for the parameterization. Must be cleaned usingMobProfilesCleanerbefore input.- Returns:
Calculated parameters and metadata stored in
ModelParamsdataclass.- Return type:
- class champpy.UserParamsParameterizer(description, vehicle_type, temp_res=0.25, typeday=<factory>, speed_dist_edges_duration=<factory>)[source]¶
User parameters for the parameterization of the mobility model.
This data class encapsulates all user-configurable parameters required by the
Parameterizerto calculate mobility model parameters from reference data.Examples
user_params = UserParamsParameterizer( description="Passenger cars weekday/weekend", vehicle_type="passenger car", temp_res=0.25, typeday=TypeDays(groups=[[0, 1, 2, 3, 4], [5, 6]]) )
- description: str¶
Description of the parameter set.
Example:
"Parameters for passenger cars based on example1 data"
- speed_dist_edges_duration: list¶
Speed distribution bin edges by trip duration in hours.
Default:
[0, 0.5, 1, 10](bins: 0-30min, 30min-1h, 1h-10h)
- class champpy.ModelParams(df, info)[source]¶
Calculated parameters used in the mobility model.
This dataclass combines the calculated parameter DataFrame with metadata information about the parameter set. This class is generated with
Parameterizerand can be loaded withParamsLoader.- df: DataFrame¶
DataFrame with calculated parameters.
The DataFrame is construced with the panderad schema ParamsSchema and contains the following columns:
Column
Type
Description
id_params
Unique identifier for the parameter set
id_cluster
Cluster identifier (≥1)
percentage
Percentage of this cluster (0-100)
speed_max
Maximum speed for normalization (≥0)
weekdays
List of weekday integers (0=Monday, 6=Sunday)
transition_matrix
3D array with transition probabilities (timesteps, locations, locations)
speed_dist_param1
Beta distribution alpha parameters by duration bin
speed_dist_param2
Beta distribution beta parameters by duration bin
speed_dist_edges_duration
Duration bin edges in hours
- info: ParamsInfo¶
Information about the parameter set.
- class champpy.ParamsInfo(id_params, description, vehicle_type, temp_res, annual_km, locations, share_of_time_at_locations, number_typedays, number_clusters, labels_locations, labels_clusters, created_user=<factory>, created_dt=<factory>)[source]¶
Metadata information for a mobility model parameter set.
This dataclass stores descriptive information and metadata about calculated mobility model parameters, such as temporal resolution, vehicle type, and clustering details.
Share of time (0-1) vehicles spend at each location.