Skip to main content

A timeseries lib on top of fastai2

Project description

timeseries_fastai

This repository aims to implement TimeSeries classification/regression algorithms. It makes extensive use of fastai V2!

Installation

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.

TL;DR

git clone https://github.com/fastai/fastai2
cd fastai2
conda env create -f environment.yml
source activate fastai2
pip install fastai2 timeseries_fastai

Time Series Classification from Scratch with Deep Neural Networks: A Strong Baseline

The original paper repo is here is implemented in Keras/Tf.

InceptionTime: Finding AlexNet for Time SeriesClassification

The original paper repo is here

Results

You can run the benchmark using:

$python ucr.py --arch='inception' --tasks='all' --filename='inception.csv' --mixup=0.2

Default Values:

  • lr = 1e-3
  • opt = 'ranger'
  • epochs = 40
  • fp16 = 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; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
acc acc_max train_loss val_loss
task
Adiac 0.83 0.83 1.54 1.31
ArrowHead 0.84 0.89 0.47 0.60
Beef 0.57 0.60 1.22 1.27
BeetleFly 0.85 1.00 0.29 0.38
BirdChicken 0.80 0.95 0.25 0.55
Car 0.85 0.85 0.58 0.74
CBF 0.99 1.00 0.44 0.37
ChlorineConcentration 0.77 0.77 0.61 0.70
CinCECGTorso 0.65 0.68 0.64 1.06
Coffee 1.00 1.00 0.33 0.21

Getting Started

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/tc256760/Documents/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()

png

inception = create_inception(1, len(dls.vocab))
learn = Learner(dls, inception, metrics=[accuracy])
learn.fit_one_cycle(5, 1e-3)
epoch train_loss valid_loss accuracy time
0 3.948751 3.637887 0.028133 00:02
1 3.705492 3.507715 0.094629 00:02
2 3.418483 5.099520 0.038363 00:02
3 3.108469 2.665389 0.248082 00:02
4 2.820438 2.508861 0.304348 00:02

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for timeseries-fastai, version 2.0.0
Filename, size File type Python version Upload date Hashes
Filename, size timeseries_fastai-2.0.0-py3-none-any.whl (15.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size timeseries_fastai-2.0.0.tar.gz (16.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page