- The paper introduces a rarity-gated feature-wise linear modulation (RGFiLM) that tailors context conditioning based on rarity scores, mitigating frequency bias.
- It leverages offline imitation learning with AIS and ERA5 data to enhance anomaly detection accuracy and lower false positives in rare environmental conditions.
- Empirical results show RGFiLM outperforms conventional methods with superior F1 scores and reduced FPR, ensuring robust performance in underrepresented contexts.
Rarity-Gated Context Conditioning for Robust Contextual Maritime Anomaly Detection
Contextual anomaly detection (CAD) recognizes that abnormality is often conditional, not absolute: a behavior is only "anomalous" given its operational or environmental context. This is critical in maritime domains, where trajectory deviations may be reasonable responses to rare but hazardous weather, yet the same deviation is suspicious in calm conditions. However, most existing CAD approaches, when trained on highly imbalanced environmental data, suffer from frequency bias: normal regimes dominate, leading to high false positives and unreliable performance in safety-critical, rare contexts. Current remedies, such as neighborhood-based smoothing or global fallback, often underweight rare conditions, which is precisely when careful contextualization is needed.
To address this, the authors introduce a rarity-aware conditioning mechanism—Rarity-Gated Feature-wise Linear Modulation (RGFiLM)—that dynamically calibrates the strength of contextual conditioning based on the estimated rarity of the context. This mechanism is embedded within offline imitation learning frameworks for sequential decision-based anomaly detection on maritime vessel trajectories, leveraging Automatic Identification System (AIS) and exogenous environmental (ERA5) data.
Methodology: Rarity-Gated Feature-wise Linear Modulation (RGFiLM)
RGFiLM enhances context integration in sequential models by interpolating between context-agnostic and context-modulated representations according to a learned, data-driven rarity score. This score quantifies how unusual a given environmental context is, providing the model with explicit information about training coverage sparsity.
The core modeling steps are:
- Contextual Representation: Vessel state (st​), environmental context (et​), and action (at​) sequences are encoded to latent representations via sequence and environment encoders. FiLM-style modulation generates feature-wise scaling and shifting of latent states based on context.
- Rarity Score Computation: The rarity of context is quantified using Mahalanobis distance on selected variables (e.g., wave height, wind speed), normalized via the chi-squared CDF to the range [0,1].
- Rarity-Aware Gating: A neural gating module, conditioned on environment and rarity score, blends the original and context-modulated latent representations. The gate is sharper (i.e., more decisive) in rare regimes, becoming smoother (i.e., more conservative) in frequent contexts.
- Integration with Decision-Based Anomaly Detection: RGFiLM-modulated representations replace state encodings in decision-modeling anomaly detectors (specifically OIL-AD). The scoring pipeline is unchanged beyond the representation step, ensuring fair attribution of performance differences to the conditioning mechanism.
This architecture allows the model to (i) leverage exogenous context when it is informative and needed (rare/emergent environments), (ii) avoid overfitting to noise in underrepresented conditions, and (iii) remain robust and not degrade in well-covered regimes.
Figure 1: Ablation by environmental rarity. (a) FPR and (b) F1 score on frequent and rare trajectories, where rare trajectories are the 20% most environmentally rare according to the trajectory-level rarity score.
Experimental Setup and Evaluation
A comprehensive synthetic anomaly experiment is constructed using real-world AIS trajectories in the Bass Strait region, temporally and spatially aligned with ERA5 environmental variables. After data cleaning and state/action extraction, synthetic detours (environment-invariant) are injected into otherwise normal maritime trajectories. This design explicitly tests the model's ability to contextualize behavioral anomalies in both common and rare environmental settings.
Performance is measured along F1, precision, recall, and false positive rate (FPR) across 20 random seeds. Ablation studies stratify performance by context rarity, evaluating both frequent (bottom 80%) and rare (top 20%) environmental regimes. RGFiLM is benchmarked against context-agnostic, simple concatenation, standard FiLM, non-rarity-gated FiLM, and conventional CAD algorithms (ROCOD, CAD for MTS).
Key Results and Empirical Findings
RGFiLM demonstrates the best mean F1 (0.595) and lowest mean FPR (0.097) on the detour detection task, outperforming both context-agnostic and conventional context-conditioned methods. Notably:
Implications and Future Directions
The rarity-aware context conditioning paradigm bridges a critical gap in practical CAD deployments for safety-critical settings such as maritime anomaly detection. By dynamically tuning context utilization based on statistical coverage, RGFiLM enables robust, adaptive detection with minimal increase in model complexity. The approach is modular and can be incorporated into a broad class of sequential models, not only for maritime but also for other domains where environmental or operational context is variable and information-rich but highly imbalanced.
Future research directions include:
- Broader Anomaly Mechanisms: Extending the framework beyond trajectory detours to encompass heterogeneous anomaly types, including complex multi-step decision deviations and adversarial behaviors.
- Domain Adaptation and Generalization: Adapting rarity estimation for domain shifts and incomplete coverage in new operational theaters and variable environmental periods.
- Alternative Rarity Estimators: Incorporating advanced density models for high-dimensional or non-Gaussian contexts, possibly improving rarity sensitivity and discrimination.
- Online and Real-Time Extensions: Deploying RGFiLM within streaming anomaly detectors, enabling continual rarity recalibration and rapid adaptation to distributional changes.
Conclusion
Rarity-Gated FiLM (RGFiLM) systematically addresses frequency bias in contextual anomaly detection by modulating context utilization in proportion to context rarity, improving reliability in underrepresented regimes. Empirical evidence shows significant reductions in false positive rates and enhanced detection accuracy, particularly in rare but safety-critical maritime environments. The rarity-aware conditioning principle is broadly applicable and extends the robustness and interpretability of context-sensitive learning in sequential anomaly detection.