10 Deep learning for timeseries

 

This chapter covers

  • Examples of machine learning tasks that involve timeseries data
  • Understanding recurrent neural networks (RNNs)
  • Applying RNNs to a temperature-forecasting example
  • Advanced RNN usage patterns

10.1 Different kinds of timeseries tasks

A timeseries can be any data obtained via measurements at regular intervals, like the daily price of a stock, the hourly electricity consumption of a city, or the weekly sales of a store. Timeseries are everywhere, whether we’re looking at natural phenomena (like seismic activity, the evolution of fish populations in a river, or the weather at a location) or human activity patterns (like visitors to a website, a country’s GDP, or credit card transactions). Unlike the types of data you’ve encountered so far, working with timeseries involves understanding the dynamics of a system—its periodic cycles, how it trends over time, its regular regime and its sudden spikes.

By far, the most common timeseries-related task is forecasting: predicting what will happen next in a series. Forecast electricity consumption a few hours in advance so you can anticipate demand; forecast revenue a few months in advance so you can plan your budget; forecast the weather a few days in advance so you can plan your schedule. Forecasting is what this chapter focuses on. But there’s actually a wide range of other things you can do with timeseries:

10.2 A temperature-forecasting example

10.2.1 Preparing the data

10.2.2 A common-sense, non-machine learning baseline

10.2.3 Let’s try a basic machine learning model

10.2.4 Let’s try a 1D convolutional model

10.2.5 A first recurrent baseline

10.3 Understanding recurrent neural networks

10.3.1 A recurrent layer in Keras

10.4 Advanced use of recurrent neural networks

10.4.1 Using recurrent dropout to fight overfitting

10.4.2 Stacking recurrent layers

10.4.3 Using bidirectional RNNs