Deep Learning for Time Series Cookbook

Book description

Learn how to deal with time series data and how to model it using deep learning and take your skills to the next level by mastering PyTorch using different Python recipes

Key Features

  • Learn the fundamentals of time series analysis and how to model time series data using deep learning
  • Explore the world of deep learning with PyTorch and build advanced deep neural networks
  • Gain expertise in tackling time series problems, from forecasting future trends to classifying patterns and anomaly detection
  • Purchase of the print or Kindle book includes a free PDF eBook

Book Description

Most organizations exhibit a time-dependent structure in their processes, including fields such as finance. By leveraging time series analysis and forecasting, these organizations can make informed decisions and optimize their performance. Accurate forecasts help reduce uncertainty and enable better planning of operations. Unlike traditional approaches to forecasting, deep learning can process large amounts of data and help derive complex patterns. Despite its increasing relevance, getting the most out of deep learning requires significant technical expertise.

This book guides you through applying deep learning to time series data with the help of easy-to-follow code recipes. You’ll cover time series problems, such as forecasting, anomaly detection, and classification. This deep learning book will also show you how to solve these problems using different deep neural network architectures, including convolutional neural networks (CNNs) or transformers. As you progress, you’ll use PyTorch, a popular deep learning framework based on Python to build production-ready prediction solutions.

By the end of this book, you'll have learned how to solve different time series tasks with deep learning using the PyTorch ecosystem.

What you will learn

  • Grasp the core of time series analysis and unleash its power using Python
  • Understand PyTorch and how to use it to build deep learning models
  • Discover how to transform a time series for training transformers
  • Understand how to deal with various time series characteristics
  • Tackle forecasting problems, involving univariate or multivariate data
  • Master time series classification with residual and convolutional neural networks
  • Get up to speed with solving time series anomaly detection problems using autoencoders and generative adversarial networks (GANs)

Who this book is for

If you’re a machine learning enthusiast or someone who wants to learn more about building forecasting applications using deep learning, this book is for you. Basic knowledge of Python programming and machine learning is required to get the most out of this book.

Table of contents

  1. Deep Learning for Time Series Cookbook
  2. Contributors
  3. About the authors
  4. About the reviewer
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
    4. Conventions used
    5. Sections
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
      5. See also
    6. Get in touch
    7. Share Your Thoughts
    8. Download a free PDF copy of this book
  6. Chapter 1: Getting Started with Time Series
    1. Technical requirements
    2. Loading a time series using pandas
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Visualizing a time series
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    4. Resampling a time series
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    5. Dealing with missing values
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    6. Decomposing a time series
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
      5. See also
    7. Computing autocorrelation
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    8. Detecting stationarity
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    9. Dealing with heteroskedasticity
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
      5. See also
    10. Loading and visualizing a multivariate time series
      1. Getting ready
      2. How to do it…
      3. How it works…
    11. Resampling a multivariate time series
      1. Getting ready
      2. How to do it…
      3. How it works…
    12. Analyzing correlation among pairs of variables
      1. Getting ready
      2. How to do it…
      3. How it works…
  7. Chapter 2: Getting Started with PyTorch
    1. Technical requirements
    2. Installing PyTorch
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Basic operations in PyTorch
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Advanced operations in PyTorch
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Building a simple neural network with PyTorch
      1. Getting ready
      2. How to do it…
      3. There’s more…
    6. Training a feedforward neural network
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. Training a recurrent neural network
      1. Getting ready
      2. How to do it…
      3. How it works…
    8. Training an LSTM neural network
      1. Getting ready
      2. How to do it…
      3. How it works…
    9. Training a convolutional neural network
      1. Getting ready
      2. How to do it…
      3. How it works…
  8. Chapter 3: Univariate Time Series Forecasting
    1. Technical requirements
    2. Building simple forecasting models
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Univariate forecasting with ARIMA
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    4. Preparing a time series for supervised learning
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    5. Univariate forecasting with a feedforward neural network
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    6. Univariate forecasting with an LSTM
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    7. Univariate forecasting with a GRU
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    8. Univariate forecasting with a Stacked LSTM
      1. Getting ready
      2. How to do it…
      3. How it works…
    9. Combining an LSTM with multiple fully connected layers
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    10. Univariate forecasting with a CNN
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    11. Handling trend – taking first differences
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    12. Handling seasonality – seasonal dummies and Fourier series
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    13. Handling seasonality – seasonal differencing
      1. Getting ready
      2. How to do it…
      3. How it works…
    14. Handling seasonality – seasonal decomposition
      1. Getting ready
      2. How to do it…
      3. How it works…
    15. Handling non-constant variance – log transformation
      1. Getting ready
      2. How to do it…
      3. How it works…
  9. Chapter 4: Forecasting with PyTorch Lightning
    1. Technical requirements
    2. Preparing a multivariate time series for supervised learning
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Training a linear regression model for forecasting with a multivariate time series
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Feedforward neural networks for multivariate time series forecasting
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    5. LSTM neural networks for multivariate time series forecasting
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    6. Monitoring the training process using Tensorboard
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    7. Evaluating deep neural networks for forecasting
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    8. Using callbacks – EarlyStopping
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
  10. Chapter 5: Global Forecasting Models
    1. Technical requirements
    2. Multi-step forecasting with multivariate time series
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Multi-step and multi-output forecasting with multivariate time series
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Preparing multiple time series for a global model
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Training a global LSTM with multiple time series
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Global forecasting models for seasonal time series
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    7. Hyperparameter optimization using Ray Tune
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
  11. Chapter 6: Advanced Deep Learning Architectures for Time Series Forecasting
    1. Technical requirements
    2. Interpretable forecasting with N-BEATS
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Optimizing the learning rate with PyTorch Forecasting
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    4. Getting started with GluonTS
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Training a DeepAR model with GluonTS
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    6. Training a Transformer model with NeuralForecast
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    7. Training a Temporal Fusion Transformer with GluonTS
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    8. Training an Informer model with NeuralForecast
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    9. Comparing different Transformers with NeuralForecast
      1. Getting ready
      2. How to do it…
      3. How it works…
  12. Chapter 7: Probabilistic Time Series Forecasting
    1. Technical requirements
    2. Introduction to exceedance probability forecasting
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Exceedance probability forecasting with an LSTM
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    4. Creating prediction intervals using conformal prediction
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Probabilistic forecasting with an LSTM
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Probabilistic forecasting with DeepAR
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. Introduction to Gaussian Processes
      1. Getting ready
      2. How to do it…
      3. How it works…
    8. Using Prophet for probabilistic forecasting
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
  13. Chapter 8: Deep Learning for Time Series Classification
    1. Technical requirements
    2. Tackling TSC with K-nearest neighbors
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Building a DataModule class for TSC
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Convolutional neural networks for TSC
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. ResNets for TSC
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Tackling TSC problems with sktime
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
  14. Chapter 9: Deep Learning for Time Series Anomaly Detection
    1. Technical requirements
    2. Time series anomaly detection with ARIMA
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Prediction-based anomaly detection using DL
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    4. Anomaly detection using an LSTM AE
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Building an AE using PyOD
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    6. Creating a VAE for time series anomaly detection
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    7. Using GANs for time series anomaly detection
      1. Getting ready…
      2. How to do it…
      3. How it works…
      4. There’s more…
  15. Index
    1. Why subscribe?
  16. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts
    3. Download a free PDF copy of this book

Product information

  • Title: Deep Learning for Time Series Cookbook
  • Author(s): Vitor Cerqueira, Luís Roque
  • Release date: March 2024
  • Publisher(s): Packt Publishing
  • ISBN: 9781805129233