SlidingWindow for classification tasks #711
-
Hello, The task I want to currently execute is a classification task, where a huge time series needs to be splitted into segments, so each segment can be classified individually. For this, applying a sliding window seems reasonable, though I am having troubles to map the labels to each segment. I see that there is a parameter y_func, but it seems confusing to me, how a function is applied on the time series. Thanks in advance :) |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Please, take a look at the documentation: https://timeseriesai.github.io/tsai/data.preparation.html?q=SlidingWindow#slidingwindow |
Beta Was this translation helpful? Give feedback.
-
Thanks for the answer. I played around a little with y_func, but it does not give me the capabilities to achieve my task i think. Basically I did the following:
This creates non_overlapping segments of size window_length, where the labels for a segment are all the labels from the next segment. Then I prepend the original labels to y from the first segment. Next, I need to collapse the labels for each segment to one label with the following function:
It would be nice though to consider this usecase in SlidingWindow, as it is needed for many classification tasks, where each segment only has one label that is derived from the underlying collection of labels. Correct me if I'm wrong, that this is currently not possible with the parameters in the current implementation of SlidingWindow. Also, this might not be the most beatiful implementation to solve the problem, but it did the job :) |
Beta Was this translation helpful? Give feedback.
-
Why don't you pass the func you want to use to y_func as a SlidingWindow argument? |
Beta Was this translation helpful? Give feedback.
-
Ok, I tried to work again with the parameter y_func and I found out the mistake i made. I misinterpreted the horizon paramater as it says in the docs number of future datapoints to predict. This caused me some confusion, as also negative values are allowed, which means not only future datapoints are to be considered with this parameter. The updated code therefore:
Next, SlidingWindow can be applied with a negative value for horizon, to keep the labels unshifted:
|
Beta Was this translation helpful? Give feedback.
Ok, I tried to work again with the parameter y_func and I found out the mistake i made. I misinterpreted the horizon paramater as it says in the docs number of future datapoints to predict. This caused me some confusion, as also negative values are allowed, which means not only future datapoints are to be considered with this parameter.
The updated code therefore: