WETW: Learning Pair-Specific Weighted Euclidean Distances for Efficient DTW Search

Christos Panourgias, Qitong Wang, George Tzagkarakis, Themis PalpanasarXiv 2026 · arXiv

Dynamic Time Warping (DTW) is the gold standard for measuring similarity between time series that are misaligned in time. However, its quadratic computational cost makes it a notorious bottleneck for large-scale search. WETW (Weighted Euclidean Time Warping) offers a clever solution: instead of performing expensive alignments, it learns to predict pair-specific weights for fixed-length embeddings, mimicking the behavior of DTW at a fraction of the cost.

TL;DR

WETW is a learned distance metric that adapts to specific pairs of time series embeddings, achieving up to 40x speedups over state-of-the-art exact search methods. By combining a specialized encoder (WESEE) with a "filter-and-verify" pipeline, it maintains high recall (0.93) on long series where traditional pruning methods fail.

What Problem Does This Paper Address?

Similarity search in time series often relies on DTW because it can handle shifts and speed variations in patterns. The problem is that DTW requires dynamic programming, which is $O(n^2)$ relative to the series length. While exact search methods use "lower bounds" (like $LB_{Keogh}$) to prune candidates, these bounds often become "loose" and ineffective for complex, oscillating signals like audio, seismic data, or EEG.

Existing deep learning approaches try to map series into an embedding space where a simple Euclidean distance can be used. However, the authors argue that a fixed distance rule is fundamentally flawed for DTW. Because DTW aligns every pair differently, the "importance" of different features should change depending on which two series you are comparing.

Methods

The authors introduce a framework consisting of three main components:

  1. WESEE (Weighted Euclidean SEries Encoder): A residual convolutional encoder. Unlike standard encoders that use global pooling (which destroys timing information), WESEE includes a Temporal Feature Extractor (TFE). This multi-scale branch keeps track of when patterns occur, which is vital for preserving DTW-like relationships.
  2. WETW (Weighted Euclidean Time Warping): This is the core innovation. Instead of a static distance, WETW uses a small, symmetric MLP (the weight generator) to predict a unique weight for each embedding dimension based on the pair being compared.
  3. The distance is calculated as: $\hat{d}_{ij} = s \sqrt{\sum w_k (e_{i,k} - e_{j,k})^2}$
    • This effectively allows the model to "mask" or "highlight" specific dimensions for each comparison, just as DTW selects specific coordinates during alignment.
  4. WETW-FV Pipeline: A three-stage "Filter-and-Verify" search strategy (see Figure 4):
  5. Stage 1: A very cheap Euclidean search on all embeddings to get a broad candidate set.
  6. Stage 2: WETW rescores the top candidates to create a refined shortlist.
  7. Stage 3: Exact DTW is run only on the final tiny shortlist to ensure the returned distances are 100% accurate.
Fig. 3: (Left) WESEE encoder architecture. (Right) WETW architecture.

Datasets

The authors evaluated their method on eight diverse datasets from the Monash MONSTER archive and seismic repositories, covering:

  • Audio: AudioMNIST-DS, AudioMNIST (up to 48k points).
  • Medical/Bio: DREAMER-A (EEG/ECG), FruitFlies, MosquitoSound.
  • Nature/Geophysics: WhaleSounds, CornellWhale, Seismic.
  • Finance: LenDB.

Series lengths ranged from 256 to 48,000 points, with database sizes up to 840,000 series.

Key Insights and Ideas

  • DTW as a Mask: The authors introduce the "Maximal Extension Representation" (MER). They show that DTW is mathematically equivalent to a Euclidean distance between expanded series where a pair-specific binary mask selects which points contribute. WETW generalizes this by learning continuous weights.
  • Timing is Everything: Global max pooling is a standard feature in many time-series encoders, but it’s a "DTW-killer." By discarding temporal location, it makes it impossible to distinguish between series that have the same patterns in different orders. The TFE branch in WESEE is essential for high recall.
  • Ranking > Regression: Simply training a model to predict the DTW distance value (regression) isn't enough for search. The authors found that adding a ranking regularization term—which explicitly penalizes the model for misordering neighbors—was the "aha moment" that raised recall@1 from 0.79 to 0.95.

Key Results

WETW-FV consistently outperforms both exact methods and learned baselines:

  • Speed: On average, it is 11.4x faster than the fastest exact methods (UCR Suite, MESSI-DTW) at a mean recall@10 of 0.93.
  • Scalability: For very long series (48,000 points), the speedup jumps to 40x (see Figure 1).
  • Accuracy: WETW halves the distance estimation error compared to the best static distance (like a full-matrix Mahalanobis distance) on the same embeddings.
  • Efficiency: A training set of only ~15% of the database is sufficient to reach 0.95 recall, and the one-time cost of generating DTW targets for training is repaid after just a few thousand queries.
Fig. 1: Mean recall@10 versus seconds per query (geometric mean) for 10-NN search over eight datasets. Each curve has nine points, with shortlists from 0.5% to 50% of the database.

Limitations and Future Work

  • Univariate Focus: The current work focuses on univariate series. Extending this to multivariate data is a logical next step.
  • Fixed Length: The encoder currently assumes fixed-length series.
  • Supervision Cost: While the "break-even" point for training is low, generating the initial DTW targets for the training set still requires significant computation. The authors suggest exploring more efficient ways to select training pairs in the future.

Overall, WETW represents a significant step forward in making DTW search practical for the massive, high-frequency datasets common in modern science and industry.

Summary updated

Abstract

Dynamic Time Warping (DTW) is the standard distance for similarity search over time series that are misaligned in time, but its cost is quadratic in the series length and lower bounds often prune few candidates, so search over large collections of long series is slow. Learned approximations embed the series to make comparisons cheap, yet compare every pair with the same fixed rule, usually the Euclidean distance, although DTW aligns each pair differently. We observe that, once a pair is aligned, DTW is a Euclidean distance over coordinates selected for that pair. Building on this view, we propose Weighted Euclidean Time Warping (WETW), a learned distance that adapts the comparison of fixed-length embeddings to each pair. A small symmetric network predicts one weight per embedding di- mension and pair without computing an alignment, which halves the error of the best static distance on the same embeddings. The embeddings come from the Weighted Euclidean SEries Encoder (WESEE), whose multi-scale Temporal Feature Extractor keeps the timing information that global pooling removes and raises recall@1 from 0.90 to 0.95, although WETW works with any encoder. We also show that fitting DTW distances is not enough for search, as regression alone misorders the closest neighbours, and that ranking regularization raises recall@1 from 0.79 to 0.95. Our filter-and-verify pipeline, WETW-FV, uses WETW to build a shortlist and exact DTW to check it, so the search is approximate but every returned distance is exact. Over eight datasets, WETW-FV is 11.4x faster than the fastest exact method among the UCR Suite, lower bounds and MESSI-DTW, at a mean recall@10 of 0.93, while the best learned baseline reaches 0.59 at the same speed. On 48K-point series, WETW- FV remains 40x faster than the UCR Suite at a recall@10 of 0.91.
BibTeX
@misc{panourgias2026wetw,
  author = {Christos Panourgias and Qitong Wang and George Tzagkarakis and Themis Palpanas},
  title = {{WETW: Learning Pair-Specific Weighted Euclidean Distances for Efficient DTW Search}},
  year = {2026},
  eprint = {2611.17412},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.17412},
}
Figure