Skip to content

transitlos.scoring.stop_score

Combines the MRC, speed and frequency sub-scores into one stop-level score.

Default structure ("nested"):

stop_score = sqrt(MRC * V) * H

MRC (mode / reliability / comfort) and V (speed) are pooled by an equal geometric mean (a faster vehicle can make up for a lower mode category and vice versa); H (headway) multiplies the result, so a service that hardly ever comes is not rescued by being fast or comfortable. The flat weighted geometric mean of the three is kept as an option (mode=).

stop_score(mrc_score, speed_score, frequency_score, weights=None, region='global', mode=DEFAULT_AGGREGATION_MODE, p=None)

Compute stop_score from the three MRC/V/H sub-scores.

Parameters:

Name Type Description Default
mrc_score float

Sub-score from mrc.mrc_score. Must be in [0, 1].

required
speed_score float

Sub-score from speed.speed_score. Must be >= 0 (may exceed 1.0 up to 1.15, see module docstring).

required
frequency_score float

Sub-score from frequency.frequency_score. Must be in [0, 1].

required
weights tuple[float, float, float] | None

Only meaningful for mode="harmonic"/mode="geometric" (the legacy flat three-way mean) -- (w_mrc, w_v, w_h), must sum to 1 within floating-point tolerance; defaults to equal thirds. Must be left None for the default mode="nested", which has no weight parameter by construction (a plain, equal, unweighted geometric mean of MRC and V) -- passing weights with mode="nested" raises ValueError rather than silently ignoring it.

None
region str

Region key into parameters.REGIONS. Kept for backward compatibility -- every region shares identical, universal weights.

'global'
mode str

Aggregation structure. One of: - "nested" (default, 2026-09-29): stop_score = sqrt(MRC * V) * H. - "harmonic": the pre-2026-09-29 flat weighted harmonic mean (p=-1) of all three sub-scores -- kept for comparison/ back-compatibility. - "geometric": the flat weighted geometric mean (p=0) of all three sub-scores -- the form before the harmonic-mean revision, also kept for comparison/back-compatibility.

DEFAULT_AGGREGATION_MODE
p float | None

Deprecated escape hatch for mode in ("harmonic", "geometric") only: an explicit generalized-mean exponent overriding the mode's default (-1.0 / 0.0 respectively), for callers that need some other point on the flat M_p family for comparison purposes. Ignored (must be None) for mode="nested".

None

Returns:

Type Description
float

A float in [0, 1]: stop_score under the requested aggregation

float

structure, hard-capped at 1.0 (see module docstring's "2026-09-29

float

hard cap" note -- V(speed) itself may still exceed 1.0, but the

float

composite stop_score never does).

Raises:

Type Description
ValueError

If mrc_score/frequency_score is outside [0, 1], speed_score is negative, mode is unrecognized, weights/p are passed with mode="nested", or (for the legacy modes) the weights do not sum to 1 within tolerance.