Awesome
TSC-Disc-Proto
This repo contains the official code of the project "Discriminative Prototypes learned by Dynamic Time Warping (DTW) for Time Series Classification (TSC)". This work is accepted by CVPR2021 as "Learning Discriminative Prototypes with Dynamic Time Warping". preprint
1. Dependent Packages and Platform
First we recommend to create a conda environment with all the required packages by using the following command.
conda env create -f environment.yml
This command creates a conda environment named TSC_Disc_Proto
. You can activate the conda environment with the
following command:
conda activate TSC_Disc_Proto
In the following sections, we assume that you use this conda environment or you manually install the required packages.
Note that you may need to adapt the environment.yml
/requirements.txt
files to your infrastructure. The configuration
of these files was tested on Linux Platform with a GPU (RTX1080).
If you see the following error, you may need to install a PyTorch package compatible with your infrastructure.
RuntimeError: No HIP GPUs are available
For example if your infrastructure only supports CUDA < 10, you may need to install the PyTorch package using CUDA 9.2.
pip install torch==1.7.1+cu92 torchvision==0.8.2+cu92 -f https://download.pytorch.org/whl/torch_stable.html
2. Download of Fish Dataset
In the paper, we train and evaluate our model on the Fish dataset. You can use the following command to easily download the dataset:
bash get_dataset.sh
3. Run
You can use the following command to load the pretrained model and evaluate it on Fish dataset
python main.py
You should see the following lines in the terminal.
#1. Build data loaders.
#2. Build the classifier with prototype sequences.
=====> Model on GPU(s).
7 of 7 parameters are trainable.
7 Classes 7 Weights to be trained in total.
#3. Build optimizer.
#4. Load the pretrained model.
#5. Evaluate
Test Error Rate: 7.43%.
Yoiu can use the following command to train a new model and evaluate it on Fish dataset:
python main.py --train
You should see the following lines in the terminal.
#1. Build data loaders.
#2. Build the classifier with prototype sequences.
=====> Model on GPU(s).
7 of 7 parameters are trainable.
7 Classes 7 Weights to be trained in total.
#3. Build optimizer.
#4. Training
It took ~4 minutes to train.
#5. Evaluate
Test Error Rate: 7.43%.
Note that the test error rate may varied around 6.00% ~ 9.00%.
4. Result Comparison
Error Rate (%) | |
---|---|
ED | 21.71 |
DTW | 17.71 |
DTW (opt) | 15.43 |
Ours (init) | 33.71 |
Ours | 7.43 |
The baseline DTW results are reported Here, ID 28 (Fish Dataset) in the Table.
5. Citations and Links
Our CVPR2021 Paper:
@inproceedings{chang2021dpdtw,
title={Learning Discriminative Prototypes with Dynamic Time Warping},
author={Xiaobin Chang, Frederick Tung, Greg Mori},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
year={2021}
}
UCR Datasets Paper:
@article{bagnall16bakeoff,
title={The Great Time Series Classification Bake Off: a Review and Experimental Evaluation of Recent Algorithmic Advances},
author={A. Bagnall and J. Lines and A. Bostrom and J. Large and E. Keogh},
journal={Data Mining and Knowledge Discovery},
volume={31},
issue={3},
pages={606-660},
year={2017}
}
Links: