Time series/ sequential data study group

Thank you so much for your quick response @oguiza . I went thorough the example data set and I am working with KwH data from smart meters as well.

Let me explain the context.
There is a load profile that varies through out the day for each household. If the house has a smart meter that collects power usage 15 mins we can estimate the load profile.
Lets say, there are house that do not have a smart meter and only have a reading every 2 months, I would like to estimate the 15 min load profile for these house holds. Its more like interpolating than predicting.

The features I have motioned are the rooftype, size of the house, etc.,

Ok, I understand. I misread what you described in your previous post. Sorry about that!

If I understand it correctly now, you want to build a 15 minute profile based on a 2 monthly reading.
It sounds like a very challenging task. Basically you’d need to build 5740 (4 x 24 x 60) datapoints based on 1 (plus static data). Would a human be able to do what you are trying to do?

If you still want to try it, you could use the 15 min data to generate the aggregated 2 month readings. Then you could train the network using those 2 month data as input and the 15 min data as target.
You will need to modify the model’s head to generate an output of the desired shape.

1 Like

Interesting! For some reason I thought that changing the input dimensions was not allowed unless you did fancy things like dynamic axes when exporting the network. Very nice gist! :wink:

1 Like

Is there any reason why you would want to shuffle the splits for your data?

I was thinking surely as it’s a time series problem you want to have all your training data before your valid data?

That holds for a forecasting problem. For classification and regression each item in the dataset should be independent, so you can randomly shuffle the splits.

1 Like

Thank you for clarifying @vrodriguezf. And what about dataloaders? I presume you don’t shuffle your splits, you won’t want to shuffle your dataloaders?

(Apologies, I’m exploring time series problems for the first time).

Also is there an example of a time series regression problem you can think of?

I think it’s the same idea with the training dataloader. You want to shuffle your batches for classification and regressionm and you can think of not shuffling them for forecasting, to simulate that the batches are being fed to the model “from left to right” in the time series.

You can find many time series regression cases here:

1 Like

Hi @ModdingLeo,

I pretty much agree with @vrodriguezf that the general approach is shuffling data in classification and regression. In the case of forecasting, it’s debatable in my opinion. In my experience, I usually get better forecasts when shuffling data, but others may disagree. At least, I think it may be worthwhile testing both approaches.

As to regression data, I have included in the tsai library a function to download data from the web Victor has shared.
You can see all datasets available using this:

Monash_list

#output
['AppliancesEnergy',
 'AustraliaRainfall',
 'BeijingPM10Quality',
 'BeijingPM25Quality',
 'BenzeneConcentration',
 'Covid3Month',
 'FloodModeling1',
 'FloodModeling2',
 'FloodModeling3',
 'HouseholdPowerConsumption1',
 'HouseholdPowerConsumption2',
 'IEEEPPG',
 'LiveFuelMoistureContent',
 'NewsHeadlineSentiment',
 'NewsTitleSentiment']

and then use this function to download the required dataset:

dsid = "AppliancesEnergy"
X_train, y_train, X_valid, y_valid = get_Monash_data(dsid)
X, y, splits = get_Monash_data(dsid, split_data=False)

If interested, you can see this regression tutorial nb available in tsai.

1 Like

Hi @oguiza thank you for the response + including the regression data in the library.

In the case of forecasting, it’s debatable in my opinion. In my experience, I usually get better forecasts when shuffling data, but others may disagree. At least, I think it may be worthwhile testing both approaches.

Yes I’ve been testing with and without shuffling on some data I’m looking to forecast. Shuffling did produce a better result but my concern is the shuffling could lead to datasets at e.g. 01/01/2020 datasets being incorporated before 01/01/2019, providing an element of knowing the future.

Some context, this is the dataset I’ve been playing around with. (Predicting maintenance, could potentially be univariate and multivariate).

If interested, you can see this regression tutorial nb available in tsai .

Yes this and the other notebooks have been great to understand the library. Really appreciate it!

Bear in mind that shuffling only occurs in the training set. The validation set is not shuffled. Thus there’s no leakage in the data you are interested in.
You can confirm where shuffling occurs doing this:

X, y, splits = get_UCR_data(dsid, split_data=False)
dls = get_ts_dls(X, y, splits=splits, tfms=[None, TSClassification()])
learn = ts_learner(dls, InceptionTime)
learn.dls.train.shuffle, learn.dls.valid.shuffle
# output
# (True, False)
1 Like

Hi @oguiza, @s.s.o, @geoHeil, and @interneuron,

I finally got tsai to import after having no electricity for four days. We had a major ice storm in Portland, Oregon that knocked out power to 1/3 of the city. Fortunately I had wood heat, oil candles, and a camping stove!

The final issue, after fixing the corrupted conda environment, was an obtuse import error. The solution was to install PyTorch 1.6+ and restart Linux. Now I can run MiniROCKET.

geoHeil - I will try mamba next time I get into trouble.

Thanks for your help and suggestions!

:slightly_smiling_face:

1 Like

For my forecasting/regression task I have a larger percentage of lower values of y that are being predicted than higher values of y. I’m finding the higher values of y are being overpredicted with high residuals whilst the lower values of y are being predicted with low residuals.

In classification tasks I have weighted class to handle them slightly better than leaving them having no weights.

Is there a way in tsai to weight regression/forecasting tasks or is there another way to handle this sort of challenge?

I’m also considering generating synthetic data.

Hi @ModdingLeo,
There isn’t any weighted mse loss yet, but I may add a generic one since I’ve seen the same issue you mention sometime in the past.
You could try something like this (I haven’t tried this approach yet with a real dataset):

def weighted_mse_loss(inp, targ, weight_fn=None):
    "Weighted mean squared error between `inp` and `targ`."
    if weight_fn is not None:
        return (F.mse_loss(*flatten_check(inp,targ), reduction='none') * weight_fn(targ)).mean()
    else:
        return F.mse_loss(*flatten_check(inp,targ))

In this way you can pass any weight function that has a targ argument. For example:

def weight_fn(targ, min=0, max=10):
    targ = TensorBase(targ.contiguous()).view(-1)
    weight = 1 + torch.clamp((targ - min)/(max - min), 0, 1)
    return weight

loss_func = partial(weighted_mse_loss, weight_fn= weight_fn)
3 Likes

Does anyone know of a Pytroch implementation of Exponential Smoothing (ES)? Since ES is a local model, each time series in a training dataset would require its own set of ES params (alpha, beta, etc.). Just wondering how this would be implemented in Pytorch.

Hi!

did you get anywhere with this problem? I am facing a similar one at the moment.

I normally deal with this issue by first spacing the series evenly…However, there are recent papers about the use of deep neural networks for irregular data, take a look at this:

2 Likes

Very interesting @vrodriguezf!
Thanks a lot for sharing.

Awesome thanks for the response!

Hi, I am a noob interested in the domain of TSC and have a question about the UCR dataset.

While reimplementing some of the models in the literature, or experimenting with new architectures I am overwhelmed by the size of the UCR Archive which most recently now holds 128 datasets.

Due to limited computing resources, it would be ideal to establish a baseline of 30-40 datasets which represent most of the characteristics of the archive. I know this has already been partially discussed in this group before, but how would I go about selecting 30-40 representative datasets?
My initial approach was selecting datasets with a train size of at least 100 or more, however this still leaves about 80 datasets which is far too much for my available resources. Additionally, some DL models seem to perform well even with small train sizes, so it could be interesting to observerve that as well.
Is there any paper or reference I can use as a guideline for selecting 30-40 representative datasets (e.g. from previous studies/references etc.)?

Hi this PDE approach that you are talking about seems really interesting. I wanted to ask, have you looked at neural ode’s and similar models. I have been reading about them and they are basically using ode’s for this very thing.