11 Evaluation tools (trajlab.analysis.quality)
Main function (outside the processing chain):
from trajlab.analysis.quality.lane_metrics import evaluate_lanes
metrics = evaluate_lanes(tracks, gt=ground_truth) # without gt: the ground-truth-free measures only
Purpose
Tools to judge the processed data with and without ground truth: lane metrics, the in-lane overtaking
measure, synthetic scenarios with known truth, realistic degradation of clean data, the perspective
diagnostics, and the exiD ground truth. They are used by the ANT 2027 application
(applications/ant2027/) and the tests; none of them is part of the processing chain. Most live in
trajlab.analysis.quality; the synthetic scenarios, the perspective diagnostics and the exiD reader are
in the modules named in the table.
Modules
| Module | Main functions | Purpose |
|---|---|---|
trajlab.analysis.quality.lane_metrics |
evaluate_lanes, lane_accuracy, match_events, consistency_metrics, conflict_rows, label_flicker, method_agreement, in_lane_overtakings, vehicle_km |
lane labels against ground truth; ground-truth-free plausibility |
trajlab.io.synthetic |
make_scenario, Vehicle, LaneChange, default_scenario, merge_scenario |
straight multi-lane roads with scripted vehicles and exact truth |
trajlab.analysis.quality.synthetic_battery |
FAMILIES, run_battery, truth_labels, truth_overtakings |
six scenario families × noise × rate |
trajlab.analysis.quality.degradation |
ErrorModel, degrade, ar1_noise, summarise_noise |
realistic errors added to clean trajectories |
trajlab.processing.perspective.model |
class_offsets, summarise_offsets, fit_lateral_model, longitudinal_bound |
HGV offset diagnostics (02) |
trajlab.io.readers.exid |
read_exid, map_exid_lanes, exid_ground_truth, exid_evaluation_case |
exiD reader, lanelet → lane mapping and lane ground truth |
Measures with ground truth
- Lane accuracy: share of rows whose label equals the true lane; per lane and as a confusion matrix; sequence accuracy per vehicle.
- Lane-change events: estimated and true events matched per vehicle and direction within ±1.0 s (greedy, closest first) → precision, recall, F1, mean absolute error of the crossing time.
Measures without ground truth
- In-lane overtakings (central measure of the paper of Baumann et al., submitted to ANT 2027; the
deadband and the persistence are chosen for this library): two vehicles that swap
their longitudinal order while both stay in the same lane. On motorways this is physically
impossible (motorcycles excluded), so every event is a lane-assignment or position error. For pairs
in one lane outside lane changes and excursions at consecutive common time steps, the order is
$\operatorname{sign}(s_i - s_j)$ where $|s_i - s_j| > 1$ m (deadband); runs shorter than 0.5 s are
ignored, every change of order is one event. The deadband is needed because with the persistence
rule alone, white position noise of two vehicles at equal
sproduces sign runs ≥ 0.5 s; a real overtaking in one lane passes through the band anyway. Rates per vehicle-hour and per 100 vehicle-km, normalized by the exposure of all non-excluded vehicles, by class pair (car–car, car–HGV, HGV–HGV). Requires common timestamps (10). - Counter-metrics (
consistency_metrics): label transitions and flicker (A→B→A within 2 s) per vehicle-km, conflict rate (overlap + 1 m), lateral residual (mean $|d - $ lane center$|$). - Geometry diagnostics of Step 4 (06): lost-lane windows, center spread along
s. - Stitching: artificial gaps in real tracks (04).
Synthetic data
make_scenario samples scripted vehicles (lane, speed, lane changes with a cosine lateral profile,
excursions, ranges) on a straight road at a given rate with optional white noise. The battery
(run_battery) runs six families (lane changes, slow drifts, excursions, aborted changes, merges
from an auxiliary lane, dense traffic) over noise levels and rates. A further family (hgv_lanes in
tests/scenarios.py) has slow HGVs in lane 1 (constant speed per lane, so every in-lane overtaking
is an error), a per-vehicle lateral position in the lane (SD 0.25 m), a per-HGV offset spread
(±0.3 m), and degrades the positions with the measured drone error model.
Degradation (ErrorModel, degrade)
Errors measured on our own drone recordings (the defaults of ErrorModel), applied to clean trajectories without
changing their lane labels: AR(1) noise longitudinal and lateral ($e_t = \phi e_{t-1} + \sqrt{1-\phi^2}\,\sigma w_t$,
$\phi = e^{-\Delta t/\tau}$; lateral σ = 3.7 cm, τ = 1.5 s; longitudinal σ = 0.37 m, τ = 25.8 s), outlier
bursts along the direction of travel, optional fragmentation and an optional HGV perspective offset
$\kappa(d - d_c)$. Seeded and rate-independent.
exiD ground truth
read_exid, map_exid_lanes, exid_ground_truth: exiD v2.1 (Moers et al. 2022) with lanelet → lane
mapping by lateral order per bin (rules in the module docstring of trajlab.io.readers.exid; exiD's
laneChange flag is not used for chaining, because exiD links on-ramps to lane 1 without a lane
change). The evaluation crops the input to the carriageway: ramp samples beyond the gore pull the
road-edge alignment. The other readers are described in readers.md.
Validation
tests/analysis/quality/test_lane_metrics.py, tests/analysis/quality/test_synthetic_battery.py,
tests/analysis/quality/test_degradation.py, tests/io/test_datasets.py,
tests/processing/perspective/test_perspective.py.