TimeSeries

Thank you for this library! I’ll try it next week.

1 Like

Now added to the unofficial fastai extensions repository :slight_smile:

3 Likes

@farid @oguiza I’d love to see a blog post giving a little guided your of this module. Perhaps using fastpages or some other notebook blogging thing, for instance… :slight_smile:

If you do that, please at-mention me so I don’t miss it.

5 Likes

Yes indeed. A couple of days ago, I cloned fastpages template for this purpose. I’m planning to write a couple of blog posts in a top-down style. There will be an introduction for those who are not familiar with timeseries, and gradually followed by more in-depth posts. The goal is to show the users, with different background, how to easily process their own data using the timeseries module. Let me know what you think about that @jeremy.

Meanwhile, for those who are interested, there is an illustrated example, in the README, that show how to process NATOPS dataset. There is a brief description of the dataset, and couple of images that show what are the timeseries and the labels (classes) of the dataset. Unfortunately, I didn’t have time to add more prose (in my todo list :slightly_smiling_face:).

Timeseries

The data is generated by sensors on the hands, elbows, wrists and thumbs. The data are the x,y,z coordinates for each of the eight locations (24 channels in total).

Classes (Labels)

The six classes are separate actions, with the following meaning:
1: I have command 2: All clear 3: Not clear 4: Spread wings 5: Fold wings 6: Lock wings

5 Likes

Sounds amazing!

3 Likes

This is great!
@takotab and I have been working on something similar, he has been working with a package based on V2 for ts forecasting and I have been porting my repo timeseries_fastai to V2 as an excercise to get familiar with V2.
Probably we should mutualize all this awesome work to get something smooth and concise.
What I was discussing the other day with @takotab is that there are mainly 3 taks on TS:

  1. Classification of independent timeseries, as with images. (vision api): Input: TS, output: CategoryLabel, What I was doing.
  2. Regression of indepedent timeseries, as with images: Input: TS, output: Float or Tensor.
  3. Forecasting/Generation: Input TS, output TS (can be future, past or equivalent). This is similar to Image to Image, or Image to mask tasks.

For this 3 tasks, the underlying timeseries Item should be the same, but the preprocessing to construct the pairs x,y for the supervised learning, are different.
After reading more and more fastaiV2 I think that we should build something similar to TabularPandas structure, to store timeseries as an underlying pandas dataframe. For multichannel timeseries it may be challenging.

2 Likes

It sounds great that both you are all already collaborating.

I need to go back to my initial notebooks that I created a couple of months ago in order to recollect the different challenges that I faced when I was using the TabularPandas for the multivariate timeseries, as that was my main focus. My approach was if I can solve for the multivariate timeseries case, the univariate case will be automatically solved.

We can explore on how to find a common ground for both Classification/Regression and Forecasting timeseries. I’m also also interested in Probabilistic Forecasting. I gathered some information about that topic, and that was a couple a month ago. As soon as I have some time, I can share that with those who are interested in.

1 Like

Thanks for sharing all this @farid, @tcapelle, @takotab ! It’s a great start for TimeSeries in v2.

Starting this month, I’ll have more time available, and would like to start to port functionality I’ve built in the past to v2. This includes timeseriesAI as well as other fastai extensions, mainly focused on semi-supervised/ self-supervised learning. I have to do it since it’s what I use in my daily work.

I think it’d be great if we join efforts and develop the TimeSeries for fastai v2 as a team instead of working in parallel.

I’d be more than happy to share all the code I have (core functionality, augmentations, models, etc), as well as ideas and learnings from all the time I’ve been using timeseriesAI (for example how to work with larger than memory datasets).

If you agree, I think we should start discussing the scope of the project, and how to organize the work.

For example, in scope we should decide this like:

  • Tasks included: agree with the ones @tcapelle has mentioned. Maybe include anomaly detection(?). In my case, I’m very focused on classification/ regression.

  • Type of time series:

    • Time series: univariate, multivariate
    • Sequential data
    • Space-time series
    • Temporal sequences (like Rossman)

    Personally I’d start with univariate and multivariate time series/ sequential data, and maybe expand in the future.

  • Which approaches should we use?

    • Raw data
    • Raw to image data?

Please, let me know what you think, and if agree we may raise this in the Time Series thread to check if anybody else is interested.

2 Likes

I think you should proceed with the blog post you are creating and publish it @fared since it seems you’ve made substantial progress. I don’t have any problem with that :slightly_smiling_face:

This! we have @oguiza on board…
We should maybe organize a call to be able to talk/share ideas.
+1 for anomaly detection (not sure what do you mean).
I think the underlying solution is very important, because we need it to be fast, and fitting in memory is not always an option.
Visualizing multichannel timeseries is not always easy or necessary, but for univariate it is a must. Probably for univariate the pandas DataFrame is the way to go, but for multivariate maybe it should be something else.
I have a current project where I will need to assemble Images plus Timeseries, and I was hoping to build on V2.

1 Like

Welcome on board @oguiza!


Awesome progress. You also added a lot of documentation, nicely done.

I think it makes a lot of sense to collaborate and try to make a structure for the 4 problems. I feel like anomaly detection is the same as Classification, but feel free to correct me on that one. The 4 problems I come to are:

  • Classification,
  • Regression
  • Forecast
  • Imputation (interpolation)

The first 3 are clear I think the last one becomes clear with this picture:

So this is filling in the blanks. This can be nicely done with a nbeats style model.

This makes sense. I’m not sure I’m ready for it, I would like to go a little deeper into the libary @farid build (could you also open the the docs on a github page?). Than I can ask better questions during the call.

Very interesting to hear you made the same call. Would love to talk about that. Although I think (already discussed this with @tcapelle ) it can be done if we store the timeserie in a cell of the dataframe as a Series or just as an array. Like it is done below in the colums ts_1, pred respectivly:

df = pd.DataFrame(data={'pred':[np.arange(10.),
                           np.arange(12.)],
                   'ts_0':[np.ones(10)[None,:],
                           np.ones(12)[None,:]],
                   'ts_1':[pd.Series(np.arange(1,11)+np.random.randn(10)),
                           pd.Series(np.arange(1,13)+np.random.randn(12))],
                   'var_0':[0.,1.],
                   'con_0':[0,1]})
df

I think either ts_1 or pred is the way forward. So a column for every feature/timeserie. Where every ts has of the same row must have the same length. This way you can do multivariate for different instances (rows).

This way also has the potential to unite it with the current tabular module. However, the forecasting Dataloader becomes quite complicated so that part will need to be separate. But things like transforms and proccs could/should be shared I think.

1 Like

@sachinruk build a pytorch/fastai implementation of facebooks prophet maybe interesting to keep in the loop. https://github.com/sachinruk/ProFeTorch

1 Like

I’m ok for a call. I think it’d be helpful to discuss scope and potential approaches.

What I mean is that this a task where you use unsupervised learning techniques to identify outliers in your data. I know it’s a task some people are interested in, but it’s not my case. In my case I’m mostly interested in classification/ regression.

Not sure what you mean. It’d be interesting to discuss during the call.

1 Like

@takotab, awsome job for being able to develop a fastai v2 version of the N-BEATS article.

In my repo, I included documentation that I generated using nbdev_buid_docs but I have some issues that prevent generating the css, js, images folders. I will post the issue in the nbev thread later.

A couple month ago, I played with Amazon Labs’ time series forecasting repo called GluonTS (maybe you are already familiar with. If it’s the case, please ignore the rest of the post). As everybody might guess, their implementation uses Amazon MXNet. I must say it’s quiet impressive what they have achieved. They implemented almost all the architecture that you can think of ( DeepFactor, DeepAR, DeepState, GP Forecaster, GP Var, LST Net, N-BEATS, NPTS, Prophet, R Forecast, seq2seq, Simple FeedForward, Transformer, Trivial, and WaveNet). I think it’s worth exploring it for those interested in time series forecasting.

They use their models for both univariate and multivariate timeseries (with millions of timeseries as they describe in some of their papers). They also leverage covariate information like day of week, month, year, or any other time series’ related information.

GLuonTS Tutorials

6 Likes

Sounds like we might want to aim for a port to fastai2 - is that what you’re thinking, @farid?

2 Likes

@jeremy, I think it would be fantastic to have something like that in fastai2. That was my initial thought when I discovered GluonTS but it’s a lot of work. I think it would be doable if we pool our efforts. We can choose the most efficient architectures and gradually port them to fastai2. @takotab already implemented the N-BEATS model to fastai v2. So that’s already a good start :slightly_smiling_face:

1 Like

@farid I believe you’re part of the fast.ai Live group - this might make for a great project during the course…

3 Likes

@jeremy, yes I am, and yes indeed that would be a great project to implement during the course, and to share with the fastai community.

2 Likes

Thank you for sharing GluonTS, didn’t know about it! Is the N-beats model implemented there? I cannot find it.

1 Like