johannfaouzi / pyts

A Python package for time series classification
https://pyts.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.76k stars 164 forks source link

Creating a sequence of GAF's from a timeseries #93

Open david-waterworth opened 3 years ago

david-waterworth commented 3 years ago

I'm looking to train a Connectionist Temporal Classification (CTC) classifier. The input is a sequence of tensors of length N and the output a sequence of length M, M<N. I want to use a Gramian Angular Field to encode the input sequence.

From what I understand pyts Gramian Angular Field encodes the entire input to a single output? So given a series of 1x1000 where 1 is the batch dimension and 1000 is the series length, I get back a single tensor 1x32x32, what I want is Bx32x32 where B is the number of windows.

Is there a way of doing this using pyts? I'm guessing I could just reshape the input from 1x1000 to say 10x100 but is there a transform which does this, perhaps with overlap etc?

johannfaouzi commented 3 years ago

Hi,

There is indeed a function in pyts to extract windows from time series: pyts.utils.windowed_view. It has two arguments:

Since machine learning usually requires several samples, the input must be a 2D array and the output is a 3D array, but you just have to reshape the single time series from a 1D array to a 2D array and discard the first dimension of the output.

Let me know if this answers your question and feel free to ask more questions if needed.

david-waterworth commented 3 years ago

Thanks yes this is what I was looking for