FluxML / FastAI.jl

Repository of best practices for deep learning in Julia, inspired by fastai
https://fluxml.ai/FastAI.jl
MIT License
589 stars 51 forks source link

Added Time Series Container and Block #199

Closed codeboy5 closed 2 years ago

codeboy5 commented 2 years ago

Added Time Series Container and Block. Currently can only load univariate time series. This is work in progress for issue #155 . I was planning to add loaddataset function for such datasets. Currently all datasets have the same root URL :- "https://s3.amazonaws.com/fast-ai-" . For time series datasets the root url is different so i think we can proceed by add root_url field in the FastAIDataset structure. How does this sound ?

codeboy5 commented 2 years ago

I am also changing so that we can read the data from .arff files instead of .tsv files since most datasets are available in that format.

codeboy5 commented 2 years ago

This allows us to run the following code, currently only uni variate time series are supported. The block and container will work for multi variate too but the process to read the input would change somewhat.

using FastAI

path = "/home/saksham/Desktop/GSOC/Adiac"
recipe = TimeSeries.TimeSeriesDatasetRecipe(file="Adiac_TRAIN.arff")
data, blocks = loadrecipe(recipe, path)
println(Datasets.testrecipe(recipe, data, blocks))
sample = getobs(data,5)
println(checkblock(blocks, sample))

which returns

Test Passed
true
codeboy5 commented 2 years ago

This allows us to do the following

path = datasetpath("adiac")
recipe = TimeSeries.TimeSeriesDatasetRecipe(file="Adiac_TRAIN.arff")
data, blocks = loadrecipe(recipe, path)
codeboy5 commented 2 years ago

Looking very good so far! I've left some comments. Unfortunately I am not familiar with time series using deep learning, so I don't know what the observations should look like and what encodings will be needed. Do you have a reference that gives an overview of these things?

Other than that, some tests would be great :) (see the rest of the library as reference for how to write these inline, and check ReTest.jl for how to run these interactively); dataset doesn't need a test since we don't want to download that on every CI run)

Let me see if I can find a good reference for this. This has some (https://timeseriesai.github.io/tsai/data.preparation.html) which we can refer to for encoding. I'll work on adding tests and look at resolving some of the comments you mentioned. I think going further we would also need to decide some models that we want to work on first.

lorenzoh commented 2 years ago

That's a good resource and probably a good reference for implementations here :+1:

The best way to proceed is to take an example task from tsai, e.g. classification, and implement the components (incl. the model) used there.

codeboy5 commented 2 years ago

Hey sorry, I was busy with some school stuff. So i am currently working on this tutorial and add this functionality to FastAI.jl .

lorenzoh commented 2 years ago

That seems like a great starting point!

Hey sorry, I was busy with some school stuff.

No worries, it's normal that PRs take time and are punctured by some inactivity 😄 👍

codeboy5 commented 2 years ago

I was previously using ARFFFiles.jl. It was not working with the multivariate time series, so I used this function from tsai with some modifications. We are able to now read .ts for both univariate and multivariate time series.