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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.