Traffic forecasting models are very good at predicting smooth average speed and flow. Operators, however, need something else: an advance warning that a given freeway segment will, within the next half hour, see a collision, a stalled vehicle, a weather slowdown, or several of these at once. Framed directly, this is a multi-label classification problem. Each sensor location and future time window gets an independent yes/no probability per hazard type, so the hazards are not forced to compete. The labels are extremely sparse, though, and the standard tool for sparse multi-label targets, asymmetric loss, has a blind spot in this setting. Asymmetric loss is a training objective that weakens the gradient from easy "no" labels while keeping full gradient for the rare "yes" labels. It treats every "no" as equally trustworthy. On a road graph, many "no" cells sit one sensor upstream or ten minutes before a recorded incident. Incident logs are imprecise in time and location, so these cells are often the incident itself, slightly mislocated. Penalizing them as full false alarms teaches the model to be timid exactly where it should be confident.
This note proposes to make the negative-side forgiveness of asymmetric loss depend on directional road-graph and time distance to the nearest recorded incident of the same type. The proposal then tests, against carefully tuned simpler alternatives, whether this improves node-level early warning. It also asks whether the resulting probabilities can still be calibrated well enough for dispatch decisions. The central bet is falsifiable and stated up front. In a well-tuned baseline, a large share of false alarms will turn out to be spatio-temporal near-misses. If that share is small, the method has nothing to fix and we will report that instead.
Core Claim
The problem has three ingredients, and they play different roles. Independent multi-label classification supplies the output form: one sigmoid per hazard type per node per horizon. Spatio-temporal traffic forecasting supplies the backbone and the regime, meaning a road graph, multi-horizon prediction, and real incident logs. Asymmetric loss supplies the mechanism we modify.
The claim is that the right negative-side treatment is distance-aware. Let $p$ be the predicted probability of hazard $k$ at node $i$ and horizon window $t$. Let $d$ be the directional distance from $(i,t)$ to the nearest recorded type-$k$ incident, combining graph hops along the direction of traffic propagation and time offset scaled by a speed $v$. Let $p_m=\max(p-m,0)$ be the shifted probability from asymmetric loss, with margin $m$. The negative-label loss becomes
$$\mathcal{L}_{\text{neg}} = -\Big(1-e^{-d^2/2s^2}\Big)\, p_m^{\gamma_-}\log(1-p_m),$$
where $\gamma_-$ is the negative focusing exponent and $s$ is a tolerance scale. The positive-label loss stays $-\log p$, which means $\gamma_+=0$. Negatives far from any incident behave exactly as in standard asymmetric loss. Negatives that are near-misses contribute almost nothing. The target itself is never changed, which is what separates this from soft-label approaches discussed below.
Relation to Prior Work
The loss mechanism comes from Asymmetric Loss For Multi-Label Classification. That paper decouples positive and negative focusing, avoiding the "symmetry trap" where focal loss suppresses moderately confident positives along with easy negatives. It also adds a probability margin to discard easy negatives and blunt missing-label noise. Its margin is uniform across samples, because in static images there is no notion of how close a negative is to a positive. Distribution-Balanced Loss adds a similar negative-tolerant threshold, plus reweighting for label co-occurrence, and is likewise distance-blind. Our change is to make tolerance a function of road-graph structure.
Towards Calibrated Multi-Label Deep Neural Networks constrains the design. It shows that heuristic asymmetric losses are not proper scoring rules, meaning their minimizer is not the true probability. This degrades calibration, and our modification makes that worse rather than better. We therefore treat calibration as a first-class outcome. We test whether post-hoc per-label rescaling recovers it, and we compare against that paper's proper asymmetric loss.
VarifocalNet supplies the main competing idea: replacing hard positive targets with continuous quality scores. Its spatio-temporal analogue, blurring incident labels over neighboring cells, is the strongest alternative we must beat.
On the forecasting side, STAEformer shows that a plain Transformer with learned spatio-temporal and periodicity embeddings reaches top accuracy on six flow benchmarks without a predefined graph. We use it as the fixed backbone so that only the loss varies. Incident-Guided Spatiotemporal Traffic Forecasting treats incidents as inputs that correct flow forecasts. It contributes the directional upstream/downstream topology we reuse to define $d$, and it motivates the gap: incidents there are conditioning signals, never prediction targets.
Two papers motivate the problem. Traffic Accident Prediction via Patch-Aware and Basis Representation frames accidents as single-corridor count regression with symmetric loss, and explicitly flags extreme imbalance as unsolved. Incomplete Label Multi-Task Deep Learning for Spatio-Temporal Event Subtype Forecasting is the closest prior multi-subtype spatio-temporal forecaster. It regularizes subtype ratios across geographic neighbors with a shallow model optimized by an iterative constrained solver. It shares information across space but does not address imbalance or label mislocalization, and it does not use a modern spatio-temporal backbone.
Research Program
The work has three stages, and the first is a diagnostic that can stop the project.
Stage one builds the task on XTraffic (Alameda, Contra Costa, Orange). XTraffic time-aligns 5-minute freeway flow with incident records over 521, 496 and 990 nodes, with roughly 14.6k, 5.5k and 18.7k incidents respectively, as described in the IGSTGNN paper. Labels per node, window and horizon (15, 30, 60 minutes) are the recorded incident categories, merged into coarser groups wherever a category is too rare to evaluate. We add one derived congestion label, defined as flow falling below a node-specific low percentile for its time of day. This label creates genuine co-occurrence with incidents. Splits are strictly chronological.
We then train STAEformer with independent sigmoids and tuned binary cross-entropy. On its false alarms in the validation period, we measure the fraction lying within one or two directional hops and 15 minutes of a same-type incident. We compare this fraction to the rate expected if false alarms were placed at random, with the base rate matched. If near-misses are not substantially over-represented, distance-aware tolerance has no mechanism to act on. In that case the project reduces to a careful benchmark of existing imbalance losses on this task, which is still useful but smaller.
Stage two implements the distance-aware loss. Distance is computed from training labels only, using the directional adjacency. Directional matters because a collision backs traffic up upstream, so the upstream cell, not the downstream one, is the plausible mislocalized positive.
Stage three studies calibration. We measure per-label expected calibration error and Brier score before and after per-label temperature scaling on a held-out month. We then ask whether any discrimination gain survives once probabilities are made usable.
A transfer check uses US-Accidents (A Countrywide Traffic Accident Dataset). Its weather and road-feature attributes give multiple co-occurring labels per accident, aggregated to a city road-segment grid. We also evaluate on the I-405 TIMS corridor, reduced to a single accident label, for contact with PABR.
Baselines
The naive reference point is a per-node, per-type, time-of-day-and-weekday historical incident rate. It is trivially calibrated and captures the strong periodicity of accidents. Any learned model that fails to beat it on the area under the precision-recall curve is not learning anything about the future.
The default learned baseline is STAEformer with independent sigmoids and binary cross-entropy. We give it a tuned positive-class weight and a per-label decision threshold chosen on validation. This is the strongest "no new loss" competitor, because a simple positive weight already counters much of the gradient imbalance.
The strongest existing loss-side method is standard asymmetric loss (Ridnik et al.) with tuned $\gamma_-$ and margin $m$, using the same backbone. Distribution-balanced loss (Wu et al.) is included because its reweighting targets label co-occurrence, which the congestion label creates. Strictly proper asymmetric loss (Cheng and Vasconcelos) is included as the calibration-preserving competitor.
On the forecasting side, PABR is the published incident forecaster. On the TIMS I-405 data it reports MSE 0.4630, MAE 0.2733, P95-MAE 0.82 and Top-K Recall 0.71. We will reproduce its protocol and compare on Top-K Recall by ranking our accident probabilities. Beating it means exceeding 0.71 Top-K Recall under the same split and K. For multi-label incident classification on XTraffic, no reported result was found on Lacuna. IGSTGNN reports only flow error there, a 5.65% average MAE advantage on Alameda, which is not comparable to our task. Our internal baselines therefore define the bar.
Fairness is enforced through four controls. Every loss gets the same backbone, input features (including past incidents, as in IGSTGNN), data, epochs and early-stopping rule (validation macro precision-recall area). Every loss also gets an identical budget of hyperparameter trials, so our extra scale $s$ is drawn from the same trial count rather than added on top. All methods are run over three seeds.
The key ablations isolate the ingredient. The first uses uniform tolerance, meaning asymmetric loss with a larger margin and no distance. The second uses undirected rather than directional distance. The third uses distance tolerance with $\gamma_-=0$, separating forgiveness of near-misses from suppression of easy negatives.
"Beating" a baseline has a precise meaning: a gain in macro precision-recall area under the strict, exact-cell metric, consistent across all three counties and seeds. A gain only under a tolerant hit-rate metric, which naturally favors our method, does not count on its own.
Why not just…?
Why not just use binary cross-entropy with a positive weight and tuned thresholds? This is the simplest fix and genuinely competitive. The VOC-MLT and COCO-MLT results in the distribution-balanced loss paper (70.86 vs 78.94 and 41.27 vs 53.55 mAP) are for unweighted BCE, so they do not settle the matter. A positive weight rescales all negatives uniformly, so it cannot distinguish a near-miss from a far negative. The stage-one diagnostic predicts that its residual false alarms cluster near incidents, and the main comparison tests whether removing that cluster helps. If weighted BCE ties our loss, we will say so.
Why not just blur the labels over space and time and train with a proper loss? This is the most serious threat. It is the spatio-temporal version of VarifocalNet's soft targets, and it stays a proper scoring rule for the blurred target. The cost is that the model then predicts "incident nearby," not "incident here," inflating probability at neighbors. Our loss leaves the target sharp and only withdraws the penalty. We run blurred-target BCE with the same kernel shape and the same tuning of the kernel width. We compare under strict node-level metrics, where we expect blurring to lose precision. We also compare under tolerant metrics, where blurring may win. If blurring matches us on both, the distance-aware loss offers nothing and blurring should be recommended.
Why not just predict at coarser resolution, such as corridor segments of several nodes? Coarse labels absorb mislocalization and are trivially calibrated with standard loss. They also discard the node-level localization operators need for dispatch. We train a coarse-label model and evaluate both models at the coarse level. If our node-level model, after aggregation, is no better than the coarse model, then node-level prediction adds nothing at that resolution. In that case its value rests only on finer localization, which we measure separately.
Why not just use off-the-shelf asymmetric loss with a bigger margin? A uniform margin also forgives near-misses, but it forgives every moderately low-confidence negative everywhere, which erodes precision far from incidents. This is exactly the uniform-tolerance ablation. The two are distinguished by false-alarm rates on cells more than three hops and an hour from any incident.
Decisive Checks
Three results decide the project. The first is the near-miss over-representation ratio from stage one; without it the mechanism is moot. The second is the strict node-level macro precision-recall area of the distance-aware loss against the best of tuned weighted BCE, standard asymmetric loss and blurred-target BCE, across three counties and seeds. The third is post-temperature-scaling calibration error compared with strictly proper asymmetric loss. Dispatch relies on these probabilities, so a discrimination gain that cannot be calibrated back to within the proper-loss baseline's error is not a usable gain.
We will also report results per horizon and per hazard type. Asymmetric losses may help rare collision labels while hurting the common congestion label, and an average would hide that trade-off.
References
- Asymmetric Loss For Multi-Label Classification
- Distribution-Balanced Loss for Multi-label Classification in Long-Tailed Datasets
- Towards Calibrated Multi-Label Deep Neural Networks
- VarifocalNet: An IoU-Aware Dense Object Detector
- Spatio-Temporal Adaptive Embedding Makes Vanilla Transformer SOTA for Traffic Forecasting
- Incident-Guided Spatiotemporal Traffic Forecasting
- Traffic Accident Prediction via Patch-Aware and Basis Representation in Time Series Modeling
- Incomplete Label Multi-Task Deep Learning for Spatio-Temporal Event Subtype Forecasting
- A Countrywide Traffic Accident Dataset