TimeSliver

March 18, 2026 · View on GitHub

TimeSliver is a novel time series classification model with built-in temporal attribution for interpretability. It uses SAX (Symbolic Aggregate approXimation) encoding and multi-scale motif detection to classify time series data.

Overview

TimeSliver identifies which time points in a sequence are most important for classification decisions. The model architecture combines:

  • SAX Encoding: Discretizes continuous time series into symbolic representations
  • Multi-scale CNNs: Captures motifs at different temporal scales
  • Motif-Document Interaction: Learns relationships between CNN features and SAX representations
  • Temporal Attribution: Computes per-time-point importance scores

Architecture

TimeSliver Architecture

Workflow Diagram

┌─────────────────────────────────────────────────────────────┐
│                    TRAINING PIPELINE                        │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  ┌──────────────┐    ┌──────────────┐    ┌──────────────┐  │
│  │ 1. Train     │───▶│ 2. Test      │───▶│ 3. Temporal  │  │
│  │    Model     │    │    Model     │    │  Attribution │  │
│  └──────────────┘    └──────────────┘    └──────────────┘  │
│                                                 │           │
│                                                 ▼           │
│                                        ┌──────────────┐     │
│                                        │ importance_  │     │
│                                        │ {split}.npy  │     │
│                                        └──────────────┘     │
│                                                 │           │
│                                                 ▼           │
│  ┌──────────────────────────────────────────────────────┐  │
│  │              MASKED TRAINING (Optional)               │  │
│  ├──────────────────────────────────────────────────────┤  │
│  │  ┌──────────────┐         ┌──────────────┐           │  │
│  │  │ 4. Train     │────────▶│ 5. Test      │           │  │
│  │  │  w/ Masking  │         │  w/ Masking  │           │  │
│  │  └──────────────┘         └──────────────┘           │  │
│  └──────────────────────────────────────────────────────┘  │
│                                                             │
└─────────────────────────────────────────────────────────────┘

Dataset Parameters

DatasetClassesBins (n)Positional Encoding
EEG Sleep Stage525Yes
FordA240No
FreqSum290No
SeqComb-MV420Yes
SeqComb-UV420Yes
LowVar440No
Audio1010No

Installation

1. Clone the Repository

git clone <repository-url>
cd TimeSliver

2. Create Conda Environment

conda env create -f environment.yml
conda activate torch

3. Prepare Data

Place your data files in the respective data/ folders:

  • x_train.npy, x_valid.npy, x_test.npy - Input features
  • y_train.npy, y_valid.npy, y_test.npy - Labels
  • sax_train.npy, sax_valid.npy, sax_test.npy - SAX-encoded data

Usage

Quick Start (Any Dataset)

Replace <dataset> with: eeg_sleepstage_classification, fordA, synthetic_data, seqcomb_mv, seqcomb_uv, or larvar

cd <dataset>/main

# Step 1: Train the model
python train_model.py --device cuda

# Step 2: Test the model
python test_model.py --device cuda

# Step 3: Compute temporal attribution scores
python temporal_attribution.py --split all --device cuda

Detailed Instructions by Dataset

EEG Sleep Stage Classification

cd eeg_sleepstage_classification/main

# Train base model
python train_model.py --epochs 2500 --lr 0.0005 --device cuda

# Test on test set
python test_model.py --device cuda

# Compute attribution scores for all splits
python temporal_attribution.py --split all --device cuda

# Train with masking (using top 20% important time points)
python train_with_masking.py --top-percent 20 --device cuda

# Test masked model
python test_with_masking.py --device cuda

FordA Dataset

cd fordA/main

# Train base model
python train_model.py --epochs 2500 --lr 0.001 --device cuda

# Test on test set
python test_model.py --device cuda

# Compute attribution scores
python temporal_attribution.py --split all --device cuda

# Train with masking
python train_with_masking.py --top-percent 30 --device cuda

# Test masked model
python test_with_masking.py --device cuda

FreqSum Data

cd synthetic_data/main

# Train base model
python train_model.py --epochs 2500 --lr 0.001 --device cuda

# Test on test set
python test_model.py --device cuda

# Compute attribution scores
python temporal_attribution.py --split all --device cuda

# Train with masking
python train_with_masking.py --top-percent 20 --device cuda

# Test masked model
python test_with_masking.py --device cuda

SeqComb-MV (Multivariate)

cd seqcomb_mv/main

# Train model
python train_model.py --epochs 2500 --lr 0.002 --device cuda

# Test on test set
python test_model.py --device cuda

# Compute attribution scores
python temporal_attribution.py --split all --device cuda

SeqComb-UV (Univariate)

cd seqcomb_uv/main

# Train model
python train_model.py --epochs 2500 --lr 0.002 --device cuda

# Test on test set
python test_model.py --device cuda

# Compute attribution scores
python temporal_attribution.py --split all --device cuda

LowVar Dataset

cd larvar/main

# Train model
python train_model.py --epochs 2500 --lr 0.002 --device cuda

# Test on test set
python test_model.py --device cuda

# Compute attribution scores
python temporal_attribution.py --split all --device cuda

Command Line Arguments

train_model.py

ArgumentDefaultDescription
--epochs2500Number of training epochs
--lrvariesLearning rate
--batch-sizevariesBatch size for training
--deviceautoDevice (cuda, cuda:0, cpu)
--d-outvariesCNN output channels
--max-m1Number of motif scales
--no-tensorboard-Disable TensorBoard logging

test_model.py

ArgumentDefaultDescription
--splittestData split (train, valid, test)
--batch-sizevariesBatch size for testing
--deviceautoDevice to use
--model-pathbest.pthPath to model checkpoint

temporal_attribution.py

ArgumentDefaultDescription
--splitallSplit to process (train, valid, test, all)
--batch-size1024Batch size for processing
--deviceautoDevice to use
--model-pathbest.pthPath to model checkpoint

train_with_masking.py (EEG, FordA, Synthetic only)

ArgumentDefaultDescription
--top-percentrequiredPercentage of top time points to keep (1-100)
--methodmainAttribution method (main, transformer, captum)
--sub-methodNoneSub-method for transformer/captum
--epochsvariesNumber of training epochs

test_with_masking.py (EEG, FordA, Synthetic only)

ArgumentDefaultDescription
--splittestData split to evaluate
--top-percentsavedOverride masking percentage
--methodsavedOverride attribution method

Output Files

After training and attribution, the following files are saved in the model/ directory:

FileDescription
best.pthBest model checkpoint (base training)
best_masking.pthBest model checkpoint (masked training)
save_dict.npyModel configuration (q, d, max_m)
init_lr.npyInitial learning rate
importance_train.npyAttribution scores for training set
importance_valid.npyAttribution scores for validation set
importance_test.npyAttribution scores for test set
predicted_label.npyPredicted labels from testing

Notes

  • Model checkpoints: Automatically saved when validation accuracy improves.
  • Attribution scores: Higher values indicate more important time points for classification.

Documentation

Each dataset folder contains a claude.md file with detailed documentation specific to that dataset, including architecture details and parameter descriptions.

Citation

If you use TimeSliver in your research, please cite:

@inproceedings{
pandey2026timesliver,
title={{TIMESLIVER}: {SYMBOLIC}-{LINEAR} {DECOMPOSITION} {FOR} {EXPLAINABLE} {TIME} {SERIES} {CLASSIFICATION}},
author={Akash Pandey and Payal Mohapatra and Wei Chen and Qi Zhu and Sinan Keten},
booktitle={The Fourteenth International Conference on Learning Representations},
year={2026},
url={https://openreview.net/forum?id=MDRp9XhGtS}
}