Skip to content

Repository files navigation

Shapelet Matching

Code for Multi-source Transfer Learning of Time Series with a Shapelet-based Distance Measure, by Jiseok Lee and Brian Kenji Iwana.

Shapelet Matching overview

Installation

Python 3.11 or 3.12, with uv.

uv sync --locked --extra train

Use the 2018 UCR Time Series Archive, with files under data/<dataset>/<dataset>_{TRAIN,TEST}.tsv.

Usage

Example with Coffee as the target and GunPoint and Chinatown as sources:

# Extract shapelets
NUMBA_NUM_THREADS=4 uv run --locked python generate_shapelet.py \
  --datasets Coffee GunPoint Chinatown \
  --data-dir data --length-shapelet 15 --nb-candidate 10

# Compute dataset distances
uv run --locked python calculate_shapelet_distance.py \
  --datasets Coffee GunPoint Chinatown \
  --metric shapelet_matching --source-duplication

# Pre-train and fine-tune
uv run --locked --extra train python main.py \
  --target Coffee --dataset-number 2 \
  --metric shapelet_matching_mean_source_duplication_len15_nb10 \
  --model vgg --seed 0 --gpus -1 \
  --save-pre-trained-model --save-fine-tuned-model

For the full archive, omit --datasets from extraction and distance calculation, then use --target experiment --dataset-number 16 for training. The example uses CPU (--gpus -1). Additional options are available via --help.

Outputs are saved to shapelets/, score/, result/, and model_save/.

The released VGG differs from the manuscript's architecture; the paper's Transformer models are not included. See implementation notes and validation for details.

Citation

@article{lee2026multi,
  title = {Multi-source transfer learning of time series with a shapelet-based distance measure},
  author = {Jiseok Lee and Brian Kenji Iwana},
  journal = {Pattern Recognition},
  pages = {114898},
  year = {2026},
  issn = {0031-3203},
  doi = {https://doi.org/10.1016/j.patcog.2026.114898},
}

This work extends our conference implementation. Shapelet discovery is adapted from STUMPY.

License: Apache 2.0. Contact: jiseok.lee@human.ait.kyushu-u.ac.jp

About

Official code for "Multi-source Transfer Learning of Time Series with a Shapelet-based Distance Measure" (Pattern Recognition, 2026).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages