Papers
Topics
Authors
Recent
Search
2000 character limit reached

Rarity-Gated Context Conditioning for Offline Imitation Learning-Based Maritime Anomaly Detection

Published 11 Jun 2026 in cs.LG and cs.AI | (2606.13311v1)

Abstract: Contextual anomaly detection aims to identify abnormal behavior conditional on context variables, but practical deployments often face highly imbalanced context distributions where rare regimes can be critical information. Under such frequency bias, context-conditioned models can produce unstable decisions and excessive false alarms in rare contexts. We propose Rarity-Gated Feature-wise Linear Modulation (RGFiLM), a rarity-aware conditioning module that combines feature-wise modulation (i.e., context-conditioned scaling and shifting of hidden features) with a gate controlled by a data-driven rarity score. The rarity score is estimated from the empirical distribution of context variables and regulates how strongly context modulates intermediate representations: the gate becomes more decisive under rare contexts while remaining conservative under frequent contexts. We evaluate RGFiLM on maritime trajectory anomaly detection using AIS motion sequences with ERA5 environmental context in an environment-sensitive detour scenario. When instantiated in a sequential anomaly scoring pipeline, RGFiLM achieves the best mean F1--False Positive Rate (FPR) trade-off among the compared context-agnostic and context-conditioned methods. These results suggest that explicitly accounting for context rarity is an effective approach for reducing false alarms in context-sensitive anomaly detection.

Summary

  • 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

Motivation and Problem Formulation

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 (sts_t), environmental context (ete_t), and action (ata_t) 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][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

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:

  • False Alarm Reduction in Rare Contexts: RGFiLM achieves superior F1 and FPR, with statistical significance in F1 and FPR reduction over non-gated approaches. The improvement is especially pronounced in rare environmental conditions, confirming the efficacy of explicit rarity-aware gating in mitigating frequency bias.
  • Gated Conditioning vs. Simple Fusion: While standard FiLM and learnable gating mechanisms confer measurable improvements over naive feature concatenation, the rarity-gated variant alone achieves consistent gains, isolating the benefit of explicit rarity-dependence in the gate.
  • Robustness Across Contextual Regimes: Stratified results show that RGFiLM not only retains leading mean F1 and FPR in frequent contexts, but offers maximum gains under rare (underrepresented) environmental circumstances. Figure 1

    Figure 1: Ablation by environmental rarity, visualizing how RGFiLM improves both F1 and FPR, particularly in rare regimes.

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.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.

Tweets

Sign up for free to view the 1 tweet with 5 likes about this paper.