Format the dataset

Classic machine-learning algorithms are fed with multiple observations, where each of them has a pre-defined size (that is, the feature size). While working with timeseries, we don't have a pre-defined length: we want to create something that works for both 10 days look-back, but also for three years look-back. How is this possible?

It's very simple, instead of varying the number of features, we will change the number of observations, maintaining a constant feature size. Each observation represents a temporal window of the timeseries, and by sliding the window of one position on the right we create another observation. In code:

def format_dataset(values, temporal_features): feat_splits = [values[i:i + temporal_features] ...

Get TensorFlow Deep Learning Projects now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.