Skip to content

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
  • Loading branch information
suiguoxin committed Dec 6, 2023
1 parent 7837855 commit 9229a84
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
File renamed without changes.
46 changes: 21 additions & 25 deletions docs/contiformer.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
# CinC2020
# Contiformer

This document gives an example on how to use the PhysioPro framework for [ContiFormer: Continuous-Time Transformer for Irregular Time Series Modeling](https://seqml.github.io/contiformer/).

The example is based the solution of the 1st ranked team [Prna](https://ieeexplore.ieee.org/document/9344053).
## Classification

Here we take the `Heartbeat` classification task from [UEA & UCR Time Series Classification Repository](http://timeseriesclassification.com/dataset.php) as an example.

## Scripts

1. Download the dataset
```bash
# prepare data and features
cd data/

# training data
mkdir -p CinC2020/training_data
wget -r -N -c -np https://physionet.org/files/challenge-2020/1.0.2/ # 10G
find physionet.org/files/challenge-2020/1.0.2/training -name "*.hea" -exec mv {} CinC2020/training_data \;
find physionet.org/files/challenge-2020/1.0.2/training -name "*.mat" -exec mv {} CinC2020/training_data \;
cd PhysioPro
mkdir data
wget http://www.timeseriesclassification.com/aeon-toolkit/Archives/Multivariate2018_ts.zip -P data

# features
wget https://physionet.org/static/published-projects/challenge-2020/1.0.2/sources/Prna.zip
unzip Prna.zip && rm Prna.zip
mv Prna/physionet2020-submission/feats Prna/physionet2020-submission/records_stratified_10_folds_v2.csv Prna/physionet2020-submission/top_feats.npy CinC2020
rm -rf Prna
unzip data/Multivariate2018_ts.zip -d data/
rm data/Multivariate2018_ts.zip
```

# weights
wget https://raw.githubusercontent.com/physionetchallenges/evaluation-2020/master/weights.csv -P CinC2020

# run training
cd ..
mkdir -p outputs/cinc2020
python -m physiopro.entry.train docs/configs/cinc2020.yml
```
2. Run `Heartbeat` classification task with `TSRNN` model
```bash
# create the output directory
mkdir -p outputs/Multivariate_ts/Heartbeat
# run the train task
python -m physiopro.entry.train docs/configs/contiformer_classification.yml
# tensorboard
tensorboard --logdir outputs/
```

The results will be saved to `outputs/Multivariate2018_ts/Heartbeat` directory.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def setup():
install_requires=[
"torch==2.0.1",
"torchvision==0.15.2",
"torchcde==0.2.5",
"utilsd==0.0.18.post0",
"pandas>=2.0.3",
"scipy>=1.10.1",
Expand Down

0 comments on commit 9229a84

Please sign in to comment.