Segmenting Hybrid Trajectories using Latent ODEs

Ruian Shi, Quaid Morris

This paper introduces LatSegODE, a framework that combines the representational power of Latent Ordinary Differential Equations (ODEs) with classical changepoint detection to model "hybrid systems"—time series where smooth, continuous dynamics are interrupted by sudden jumps or shifts in behavior.

LatSegODE enables Latent ODEs to handle discontinuous hybrid trajectories by using the PELT algorithm to automatically segment data into smooth pieces. By using marginal likelihood as a scoring function, the model naturally avoids over-segmentation and significantly outperforms standard continuous models in both reconstruction and future-state extrapolation.

The Challenge of Hybrid Systems

Many real-world systems are "hybrid": they follow smooth physical laws most of the time but experience sudden shocks. For example, in a predator-prey system, a sudden migration event causes a "jump" in population, or a change in the environment might abruptly shift the interaction rates between species (a "mode switch").

Standard Neural ODEs and Latent ODEs are designed for continuous flows. When they encounter a discontinuity, they fail in two primary ways:

  1. Numerical Instability: Adaptive ODE solvers struggle to integrate across a jump, often slowing down or failing due to high local error.
  2. Representational Collapse: The model tries to "average" across different dynamical regimes, leading to poor fits and an inability to predict (extrapolate) how the system will behave after a change.
A Lotka-Volterra hybrid trajectory showing jump discontinuities and mode shifts.

The LatSegODE Approach

The authors propose LatSegODE, which treats a complex hybrid trajectory as a sequence of independent smooth segments.

  • The Base Model: The framework first trains a standard Latent ODE on "Smooth Dynamical Flows" (SDFs)—the continuous parts of the data.
  • Optimal Segmentation: At test time, the model uses the Pruned Exact Linear Time (PELT) algorithm to search for the best places to "restart" the ODE. Each restart provides a new initial latent state, effectively allowing the model to "jump" to a new trajectory.
  • Marginal Likelihood as a Scoring Function: Typically, segmentation algorithms require a manual penalty term ($\beta$) to prevent them from putting a changepoint at every single data point. The authors discovered that by using the marginal likelihood (estimated via Monte Carlo importance sampling) as the scoring function, they could set $\beta=0$. Thanks to Bayesian Occam’s Razor, the marginal likelihood naturally penalizes overly complex models with too many segments.

Key Insights and Generalization

By assuming segments are independent, LatSegODE can generalize to new sequences of dynamics it hasn't seen before. A vanilla Latent ODE tries to encode the entire history into one state, whereas LatSegODE only needs to recognize the current "mode."

Furthermore, because the model identifies the underlying dynamical mode of the final segment, it can extrapolate much further into the future than models that are "confused" by earlier discontinuities. This demonstrates a powerful way to use "black-box" deep learning architectures inside principled statistical search algorithms.

Key Results

The model was evaluated on three distinct types of data: 1D Sine Wave Hybrid Trajectories, Lotka-Volterra (predator-prey) Hybrid Trajectories, and UCI Character Trajectories (pen-tip movements). LatSegODE consistently outperformed baselines like GRU-ODE and vanilla Latent ODEs in both reconstruction and segmentation accuracy.

  • Lotka-Volterra: LatSegODE achieved a Test MSE of 0.068, compared to 0.6155 for a vanilla Latent ODE. It also achieved a Rand Index (a measure of segmentation quality) of 0.9464, far surpassing classical changepoint methods like RPT-RBF (0.7956).
  • UCI Characters: The model was highly accurate in segmenting real-world pen strokes, reaching an F1 score of 0.977.
Comparison on Lotka-Volterra: LatSegODE (bottom) accurately captures dynamics and changepoints, while the vanilla Latent ODE (top) fails to generalize to mode switches.

Limitations and Future Work

While highly effective, LatSegODE currently requires a training set of smooth segments (or a simulator) to learn the base dynamics; it cannot yet learn the dynamics and the segmentation simultaneously from scratch on raw hybrid data. Additionally, running PELT requires evaluating the marginal likelihood for many possible segments, which can be computationally expensive for very long trajectories. Finally, if the base model is slightly inaccurate, the system might "over-segment" to compensate for accumulated error in periodic solutions.

Summary updated

BibTeX
@inproceedings{shi2021segmenting,
  author = {Ruian Shi and Quaid Morris},
  title = {{Segmenting Hybrid Trajectories using Latent ODEs}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
  url = {https://openreview.net/forum?id=FaHllPiM98},
}
Figure