This repository aims to implement TimeSeries classification/regression algorithms. It makes extensive use of fastai V2!
You will need to install fastai V2 from here and then you can do from within the environment where you installed fastai V2:
pip install timeseries_fastai
and you are good to go.
git clone https://github.com/fastai/fastai
cd fastai
conda env create -f environment.yml
source activate fastai
pip install fastai timeseries_fastai
The original paper repo is here is implemented in Keras/Tf.
- Notebook 01: This is a basic notebook that implements the Deep Learning models proposed in Time Series Classification from Scratch with Deep Neural Networks: A Strong Baseline.
The original paper repo is here
- Notebook 02: Added InceptionTime architecture from InceptionTime: Finding AlexNet for Time SeriesClassification.
You can run the benchmark using:
$python ucr.py --arch='inception' --tasks='all' --filename='inception.csv' --mixup=0.2
lr
= 1e-3opt
= 'ranger'epochs
= 40fp16
= True
import pandas as pd
from pathlib import Path
results_inception = pd.read_csv(Path.cwd().parent/'inception.csv', index_col=0)
results_inception.head(10)
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
</style>
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
acc | acc_max | train_loss | val_loss | |
---|---|---|---|---|
task | ||||
ACSF1 | 0.82 | 0.85 | 0.77 | 0.62 |
Adiac | 0.77 | 0.77 | 0.81 | 0.89 |
ArrowHead | 0.70 | 0.76 | 0.28 | 1.21 |
BME | 0.85 | 0.88 | 0.21 | 0.79 |
Beef | 0.77 | 0.83 | 0.50 | 0.53 |
BeetleFly | 0.70 | 0.85 | 0.14 | 0.79 |
BirdChicken | 0.95 | 0.95 | 0.14 | 0.20 |
CBF | 0.95 | 0.97 | 0.22 | 0.24 |
Car | 0.60 | 0.68 | 0.33 | 1.23 |
Chinatown | 0.95 | 0.96 | 0.05 | 0.27 |
from timeseries_fastai.imports import *
from timeseries_fastai.core import *
from timeseries_fastai.data import *
from timeseries_fastai.models import *
PATH = Path.cwd().parent
df_train, df_test = load_df_ucr(PATH, 'Adiac')
Loading files from: /home/tcapelle/SteadySun/timeseries_fastai/Adiac
x_cols = df_train.columns[0:-2].to_list()
dls = TSDataLoaders.from_dfs(df_train, df_test, x_cols=x_cols, label_col='target', bs=16)
dls.show_batch()
inception = create_inception(1, len(dls.vocab))
learn = Learner(dls, inception, metrics=[accuracy])
learn.fit_one_cycle(1, 1e-3)
epoch | train_loss | valid_loss | accuracy | time |
---|---|---|---|---|
0 | 3.939292 | 3.701253 | 0.025575 | 00:01 |