-
Book Overview & Buying
-
Table Of Contents
Time Series with PyTorch
By :
Temporally embedded data is fundamental to our world; it tells us about what has been, why it has been and what it may become. You see it everywhere, from the melodies of your favorite musician/composer and the neural activity in your brain to the energy powering your computer and the critical supply chain supplying your food. Often, people only see them when something bad is happening, e.g., a financial crash, average global temperature increases, COVID-19 cases, and hospital beds. On the opposite side of dualism, we see life expectancy increasing, poverty decreasing, literacy increasing, and an abundance of food supply. More information is available to us than ever before to explain our lives and environments, and with that data, we can understand and improve the world around us.
Modeling this data is a fascinating and challenging area of data science and statistics, and I think it is fair to say that many people find it so. Temporal dependencies, non-stationarity, missing observations, modeling residual data, and a variety of data-generating processes all conspire to make forecasting difficult for novices. This is not helped by the fact that books like Hamilton’s Time Series Analysis (which is excellent) are impenetrable without developing a strong mathematical and statistical knowledge. However, not everyone needs to be at the level of a quantitative analyst for Renaissance Technologies. Many people, such as Rob Hyndman, have worked hard to develop and improve knowledge around time series forecasting.
Neural networks and Deep learning (depending on how you define it) entered the scene around the late 1980s, when Feed-Forward Networks (FFNs) started to be used for sequential modeling, followed by LSTMs in 1997. And there they sat, useful but not making much headway in forecasting until 2017, when Transformers were created by a team at Google, followed by Oreshkin et al.’s N-BEATS, N-HiTS and a huge range of new architectures and techniques for training that allow us to apply cross-learning and transfer-learning on untrained and trained models.
Currently, many of these networks/algorithms can be, or are, written in PyTorch, which gives us a flexible and expressive framework for building, training, and evaluating forecasting models, from simple FFNs to foundation models trained across thousands of series. Of course, the kind people at NeuralForecast and Darts have done a lot of the work for us, so you only need to start from scratch occasionally.
It has never been easier to experiment with neural networks, but how do these architectures work, how do we decide between them, and when are they useful? In time series forecasting there is no free lunch; this book aims to help you understand that, and to guide your intuition by explaining how these architectures build functions for temporal data, so that you can be confident in your choices.
This book is a practical guide. We wrote it for data scientists, machine learning engineers, and researchers who already have some experience with Python and statistics but want to build a working understanding of modern deep learning approaches to time series. Our goal is not to catalog every published architecture, but to give you the conceptual foundations, hands-on code, and evaluation discipline you need to design, build, and critically assess forecasting systems in practice.
The book is organized in three broad sections. The first third (Chapters 1 to 7) establishes foundations: what makes time series data challenging, how to evaluate models honestly, the mechanics of PyTorch, and how to build, optimize, and calibrate neural networks with conformal prediction intervals. The middle section (Chapters 8 to 13) covers major architectural families — recurrent networks, transformers, Convolutional Neural Networks (CNNs), graph neural networks, and generative models, including Variational Autoencoders (VAEs) and diffusion — alongside transfer learning and global modeling strategies. The final third (Chapters 14 to 18) moves beyond point forecasting into classification, clustering, embeddings, anomaly detection, and self-supervised learning, reflecting the breadth of tasks practitioners often encounter.
Throughout, we emphasize understanding over black-box application. We want you to know why an architecture works the way it does, not just how to call its API. Where possible, we build models from first principles in PyTorch before showing how libraries like Nixtla’s NeuralForecast and statsforecast can accelerate your experimentation. We hope you find it useful.