transitlos.stop_scores¶
Vectorized application of transitlos.scoring to a per-stop table.
Takes the raw per-stop table produced by transitlos.stops.download_and_prepare_stops
(columns headway_minutes, headway_cv, avg_speed_kmh, route_type) and
adds the mrc_score, speed_score, frequency_score, mode_category, and
stop_score columns from transitlos.scoring.
2026-09-28 model rewrite: the prior four-factor
(mode_score/speed_score/frequency_score/reliability_score) design is
replaced by the finalized three-factor model (mrc_score/speed_score/
frequency_score -- see transitlos.scoring.mrc's module docstring for why
mode and reliability/comfort are now one combined axis). stop_score is
also no longer independently walk-decayed here: downstream callers now pass
stop_score and mode_category into walk_access.walk_decay/
accessibility_score.accessibility_score, since D(t; stop_score)'s scale
is itself mode- and stop_score-dependent (see walk_access.py).
Honesty note: headway_cv coming out of transitlos.stops is currently
always null (pyGTFSHandler's get_headway_at_stops only exposes a mean
headway, not its distribution). Rather than silently treating every stop as
perfectly regular (which would make mrc.MR_CV(0) == 1.0 for every stop,
erasing the mode-categorical gap), this module
only feeds a real, observed headway_cv into mrc_score's optional (b)
refinement -- rows with a null headway_cv fall back to the primary (a)
mode-categorical default (MR_mode) instead, leaving a
reliability_score_is_assumed boolean column so callers can tell which rows
had a real CV input.
compute_stop_scores(stops_df, region='global', weights=None, default_headway_cv=None, stop_score_mode='nested')
¶
Add mrc_score/speed_score/frequency_score/stop_score columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stops_df
|
Union[DataFrame, 'gpd.GeoDataFrame']
|
A pandas DataFrame or GeoDataFrame with |
required |
region
|
str
|
Region key forwarded to every |
'global'
|
weights
|
Optional[tuple[float, float, float]]
|
Only meaningful when |
None
|
stop_score_mode
|
str
|
Forwarded to |
'nested'
|
default_headway_cv
|
Optional[float]
|
No longer substituted into |
None
|
Returns:
| Type | Description |
|---|---|
Union[DataFrame, 'gpd.GeoDataFrame']
|
|
Union[DataFrame, 'gpd.GeoDataFrame']
|
|
Union[DataFrame, 'gpd.GeoDataFrame']
|
|