liveBook · Manning

Chapter 13: Timeseries forecasting

What you will learn in chapter 13 of Deep Learning with Python, Third Edition

Introduces timeseries forecasting as predicting the near future from the recent past, where temporal order matters.

After this chapter you will be able to

What it builds on

Section by section

Introduction

Introduces timeseries forecasting as predicting the near future from the recent past, where temporal order matters.

Key terms: timeseries, temporal order, forecasting

13.1 Different kinds of timeseries tasks

This section defines timeseries data and distinguishes forecasting from other tasks involving data streams.

Key terms: timeseries, dynamics, periodic cycles, trends, forecasting, anomaly detection, unsupervised learning, classification, event detection

13.2 A temperature forecasting example

The section introduces a 24-hour temperature forecasting task, examines patterns in the Jena weather data, and explains why its train, validation, and test splits must preserve time order.

Key terms: timeseries, temperature, features, Jena, periodicity, yearly periodicity, daily periodicity, training, validation, test

13.2.1 Preparing the data

The section prepares numerical weather data as normalized, windowed training, validation, and test datasets for predicting temperature 24 hours ahead.

Key terms: normalize, mean, standard deviation, training data, timeseries_dataset_from_array, sequences, targets, sequence_length, on the fly, raw_data

13.2.2 A commonsense, non-machine-learning baseline

The section establishes and evaluates a commonsense temperature forecast that later models must beat.

Key terms: commonsense baseline, sanity check, temperature timeseries, daily period, mean absolute error (MAE), validation MAE, test MAE

13.2.3 Let’s try a basic machine learning model

This section tests a small densely connected temperature-forecasting model against a commonsense baseline and explains why a trainable model may fail to find a simple, effective solution.

Key terms: commonsense baseline, no-learning baseline, validation losses, densely connected networks, flattening, Dense layers, regression, mean squared error (MSE), MAE, compile()

13.2.4 Let’s try a 1D convolutional model

The section tries a 1D ConvNet for temperature forecasting and explains why its assumptions make it perform poorly on weather data.

Key terms: temporal ConvNet, Conv1D, translation invariance assumption, window length, MaxPooling1D, daily cycles, validation MAE, translation invariance, order information, max pooling

13.3 Recurrent neural networks

This section explains why preserving sequence order matters for temperature forecasting and reports that an LSTM model modestly outperforms a commonsense baseline.

Key terms: timeseries, flattened, pooling, sequence, causality, order, LSTM-based model, validation MAE, test MAE, commonsense baseline

13.3.1 Understanding recurrent neural networks

This section contrasts memoryless feedforward networks with RNNs and explains a simple RNN’s stateful forward pass and outputs.

Key terms: feedforward networks, recurrent neural network (RNN), state, internal loop, independent sequences, single data point, forward pass, timesteps, initial state, step function

13.3.2 A recurrent layer in Keras

This section shows how Keras recurrent layers handle sequence inputs and outputs, then explains why LSTM uses a carry track instead of relying on SimpleRNN for long-term information.

Key terms: SimpleRNN, batch_size, timesteps, input_features, Input(), return_sequences, full sequences, last output, rank-3 tensor, rank-2 tensor

13.3.3 Getting the most out of recurrent neural networks

Previews three advanced RNN techniques that will be used to refine the temperature forecasting model.

13.3.4 Using recurrent dropout to fight overfitting

Explains how temporally consistent dropout regularizes recurrent networks, then shows its effect and runtime tradeoffs in a temperature-forecasting LSTM.

Key terms: dropout mask, timestep, recurrent dropout mask, recurrent activations, dropout, recurrent_dropout, LSTM, validation MAE, test MAE, cuDNN kernel

13.3.5 Stacking recurrent layers

This section explains when stacking recurrent layers can increase model capacity, how Keras passes sequences between those layers, and what the stacked GRU achieved in the temperature-forecasting example.

Key terms: capacity, expressive power, overfitting, dropout, recurrent layer stacking, intermediate layers, full sequence of outputs, rank-3 tensor, last timestep, return_sequences=True

13.3.6 Using bidirectional RNNs

This section explains how bidirectional RNNs combine forward and reversed sequence processing, and why that helps some tasks but not the temperature-forecasting example.

Key terms: order dependent, chronological order, antichronological order, commonsense baseline, bidirectional RNN, chronological, antichronological, representations, Bidirectional layer, plain LSTM layer

13.4 Going even further

The section suggests ways to improve the temperature forecaster through empirical iteration, then explains limits imposed by the available weather data and cautions against applying the same approach to financial markets.

Key terms: recurrent layer, dropout, learning rate, Adam optimizer, sampling rate, feature engineering, no-learning baseline, single location, wide grid of different locations, past performance

13.5 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 12: Object detection Chapter 14: Text classification →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.