Anomaly Detection in Trajectory Data with Normalizing Flows

Madson Luiz Dantas Dias, César Lincoln C. Mattos, Ticiana L. Coelho da Silva, José Antônio Fernandes de Macêdo, Wellington C. P. SilvaIJCNN 2020 · DOI

TL;DR

This paper introduces GRADINGS, a novel approach for detecting anomalous trajectories by leveraging normalizing flows for density estimation. By breaking down trajectories into segments and aggregating their likelihood scores, GRADINGS effectively handles the high dimensionality and variable lengths inherent in trajectory data, outperforming traditional methods.

What Problem Does This Paper Address?

Detecting unusual patterns in trajectory data, such as unexpected movements of vehicles or individuals, is crucial for many applications. However, this task is challenging due to the high dimensionality of trajectory data (many points per trajectory) and the fact that trajectories can vary significantly in length. Traditional anomaly detection methods often struggle with these characteristics. This paper aims to address this by treating anomaly detection as a density estimation problem, where "normal" trajectories are expected to have a high probability under a learned model, while "anomalous" ones will have a low probability.

Methods

The core of the proposed method, GRADINGS, lies in using Normalizing Flows (NFs) for density estimation. NFs are a class of generative models that can learn complex probability distributions by transforming a simple base distribution (like a Gaussian) through a series of invertible neural network layers. A key advantage of NFs is their ability to compute exact likelihoods for data points, which is essential for anomaly detection.

GRADINGS tackles trajectory data by:

  1. Segmenting Trajectories: Instead of analyzing entire trajectories at once, GRADINGS breaks them down into fixed-size segments (e.g., 10, 20, or 30 location points). This addresses the variable length issue.
  2. Density Estimation with NFs: For each segment, an NF model estimates its probability density. The paper explores two types of NFs:
  3. Real-NVP (Real-valued Non-Volume Preserving): Uses coupling layers where transformations depend on untransformed dimensions.
  4. MAF (Masked Autoregressive Flow): An autoregressive flow that models conditional distributions, allowing for more flexible generalizations and potentially better performance on sequential data.
  5. Anomaly Scoring: The negative log-likelihood of a segment under the trained NF model serves as its anomaly score.
  6. Trajectory-level Aggregation: To get a single anomaly score for an entire trajectory, the anomaly scores of its constituent segments are aggregated. The paper investigates using the average and median as aggregation functions.

Datasets

The experiments were conducted using the Microsoft GeoLife dataset [11]-[13]. Specifically, a subset of trajectories located in Beijing, China, was used, comprising car and bus trajectories. Two scenarios were defined:

  • CAR × BUS: Car trajectories were treated as "normal" (in-distribution), and bus trajectories as "anomalous" (out-of-distribution).
  • BUS × CAR: The roles were reversed, with bus trajectories as normal and car trajectories as anomalous.

The data was preprocessed by converting timestamps into a cyclical representation (sin/cos of hour of the week) to capture temporal periodicity.

Key Insights and Ideas

  • Segmenting is Key: Breaking down long, variable-length trajectories into fixed-size segments is a crucial step that makes them amenable to standard density estimation techniques.
  • Normalizing Flows Shine: NFs provide an effective way to model the complex densities of trajectory segments, offering exact likelihoods that are directly usable as anomaly scores.
  • Aggregation Matters: Aggregating segment anomaly scores into a single trajectory score is vital. The median aggregation function proved particularly effective, likely due to its robustness to individual outlier segments.
  • Autoregression Advantage: The Masked Autoregressive Flow (MAF) variant of GRADINGS generally outperformed the Real-NVP, suggesting that modeling the sequential dependencies within segments is beneficial for trajectory anomaly detection.

Key Results

  • Superior Performance: GRADINGS, especially the MAF-based variant, consistently outperformed traditional methods like Gaussian Mixture Models (GMM) and Local Outlier Factor (LOF) in terms of Area Under the ROC Curve (AUROC) and False Positive Rate at 80% True Positive Rate (FPR80).
  • Median Aggregation Wins: Using the median as the aggregation function for segment scores significantly improved performance compared to the average aggregation.
  • Segment Length Trade-offs: For median aggregation, longer segments (e.g., 30 points) generally led to better results. For average aggregation, performance tended to decrease with longer segments.
  • MAF vs. RealNVP: MAF generally achieved better results than RealNVP, particularly in the CAR × BUS scenario.

Limitations and Future Work

Limitations:

  • The paper focuses on specific types of NFs (Real-NVP, MAF) and may not explore the full spectrum of NF capabilities.
  • The choice of segment length is a hyperparameter that needs tuning.

Future Work:

  • Investigate the use of convolutional flows (like Glow) for trajectory data, which could better capture spatial relationships.
  • Explore more complex invertible transformations for NFs.
  • Evaluate GRADINGS on a wider variety of trajectory datasets and anomaly types.
  • Further explore different aggregation strategies for segment anomaly scores.

Summary updated

BibTeX
@inproceedings{dias2020anomaly,
  author = {Madson Luiz Dantas Dias and César Lincoln C. Mattos and Ticiana L. Coelho da Silva and José Antônio Fernandes de Macêdo and Wellington C. P. Silva},
  title = {{Anomaly Detection in Trajectory Data with Normalizing Flows}},
  booktitle = {IJCNN},
  year = {2020},
  doi = {10.1109/ijcnn48605.2020.9206939},
}
Figure