I’m very excited to share with you a package called timeseries for fastai v2 that I have been partly working on for last couple of months. It’s still a work in progress.
This extension mimics the unified fastai v2 APIs used for vision, text, and tabular. For those who already used fastai2.vision, they will feel familiar with the
timeseries APIs. It uses Datasets, DataBlock, and new TSDataLoaders and TensorTS classes. It has the following mapping:
TensorImage <---> TensorTS
Conv2D <---> Conv1D
The package includes 128 Univariate and 30 Multivariate time series datasets. Using URLs_TS class (similar to fastai URLs class) you can play with one of those 158 datasets.
We can train any time series dataset end-to-end with 4 lines of code (here is an example using
TSDataLoaders and a multivariate dataset called NATOPS )
path = unzip_data(URLs_TS.NATOPS)
dls = TSDataLoaders.from_files(bs=64,fnames=[path/'NATOPS_TRAIN.arff', path/'NATOPS_TEST.arff'])
learn = ts_learner(dls)
Using the InceptionTime architecture, and just
fastai2 default settings we can achieve around 98,5% accuracy in only 20 epochs. The following figure shows some of the predictions results (
The package also features
Class Activation Map for time series. It offers both CAM and GRAD-CAM as well as user-defined CAM. At the center of this feature, there is one single method called
show_cam() you need to use, and it is highly configurable. You can even plug-in your own CAM function, and the rest is taken care by the
Here below is a simple example of the univariate ECG200 dataset classification task (
Normal Heartbeat vs.
Myocardial Infarction). Like in vision, the colors represent the activation values at a given layer (in this example it’s located before the FC layer (last layer)). Notice how the
Myocardial Infarction plots (2nd, 3rd, and 4th) share similar activation zones that are quiet different from those corresponding to
Normal Heartbeat plots (1st and 5th). This eases the interpretation of the results obtained using this InceptionTime model.
Please give the timeseries package a try and share your feedback. You might also check out its documentation. If you find it interesting, please share it.
NB: I read some posts here where some of the new comers expressed the fact that is intimidating seeing some full-blown projects that are indeed impressive (I’m not considering mine as one of them) in comparison to theirs. To those I would say: What you are presenting here are both great and unheard of in other courses. Considering the fact that your projects are products obtained after attending just a couple of lessons, it is quiet impressive. Some of the other projects are implemented by veterans who already have more experience with both fastai and deep learning in general which explains the difference between different projects. Good luck in your journey!