Time Series with PyTorch: Modern Deep Learning Toolkit for Real-World Forecasting Challenges

Time Series with PyTorch: Modern Deep Learning Toolkit for Real-World Forecasting Challenges

Time Series with PyTorch: Modern Deep Learning Toolkit for Real-World Forecasting Challenges
Автор: Davidson Graeme, Ma Lei
Дата выхода: 2026
Издательство: Packt Publishing Limited
Количество страниц: 606
Размер файла: 9,8 МБ
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы

Cover....1

Title Page....2

Copyright and Credits....3

Dedication....4

Acknowledgments ....5

Contributors ....6

Table of Contents ....8

Preface....18

To get the most out of this book....21

Chapter 1: Time Series for Everyone....24

Why time series?....25

The early period....27

The classical era....28

The promise of deep learning....30

From language to time....31

Forecasting and performance....31

Summary....32

Get this books PDF version and more....33

Chapter 2: The Challenge of Time Series....34

What is time-series data?....35

Missing data....36

Types of missing data....36

Simple imputations....39

MICE imputation....42

Theoretical foundations of time series analysis....44

Patterns in time....44

Decomposition....45

Additive decomposition....46

Multiplicative decomposition....49

Alternative decompositions....50

Examples of decomposition....52

Seasonality plotting....53

Beyond decomposition patterns....55

Dependence in time series....55

Autocorrelation function....58

Partial autocorrelation....60

Stationarity....63

Passengers mean and variation split check....64

Tests for stationarity....66

Applying KPSS....66

Time series structures....71

Univariate....71

Multivariate....71

Multivariable....72

Panel data....73

Application of structures to models....73

Summary....74

Recommended reading....74

Join our community on Discord....75

Chapter 3: Evaluating Time-Series Models....76

Why we evaluate....77

Using validation to manage complexity....78

Partitioning data....80

Introducing the dataset....80

ACF and PACF plots....84

Conducting residual analysis....85

Fixed-origin design....85

Train-test split....85

Train-validation-test split....87

Cross-validation....89

Expanding windows....89

Rolling windows....90

Error metrics....91

Intrinsic metrics....92

Absolute error....92

Absolute percentage error (APE)....93

Squared error....97

Variations....99

Extrinsic metrics....100

Grouped error metrics....103

Multivariate forecasting....104

Which to use and when....105

Length of evaluation....105

Data leakage....106

Transformation-based leakage....107

Lookforward bias....108

Panel data leakage....109

Summary....111

Recommended reading....111

Get this books PDF version and more....112

Chapter 4: PyTorch Fundamentals....114

Introduction to PyTorch....115

Working with tensors....115

Stride....117

Basic tensor construction....118

Understanding computational graphs....123

Chain rule revisited....126

Backpropagation calculations....126

A brief look at autograd....127

Practicing PyTorch fundamentals....129

Pure PyTorch neural network....131

Lightning NN....132

Summary....135

Recommended reading....135

Join our community on discord....135

Chapter 5: Simple Neural Architecture....136

Basic structures of neural networks....137

Artificial neurons....143

Neural nets....152

From scalars to matrices....154

Forward propagation....155

Loss calculation....156

Backpropagation....156

Building a neural network....157

Summary....164

Recommended reading....164

Get this books PDF version and more....164

Chapter 6: Optimization....166

Optimization costs....167

Optimization of neural networks....168

Understanding activation functions....169

Taxonomy....170

Layer-wise activation functions....171

Fixed-shape activation functions....171

Sigmoid....171

Tanh....173

ReLU....175

Trainable activation functions....177

Comparing activation functions....179

Hidden layers....185

Gradient descent, loss functions, and regularization techniques....188

Loss functions....188

Optimizing hyperparameters....198

Learning rate scheduling....198

Epochs....200

Batch size....200

Dropout....201

Weight decay....203

Data splitting for neural networks....204

Approaches to splitting....205

Hyperparameter tuning....206

Summary....209

Recommended reading....209

Join our community on discord....210

Chapter 7: Conformal Prediction....212

Uncertainty quantification....213

Understanding conformal prediction....217

Intuition behind conformal prediction....217

Improving conformal intervals....221

Conformal intervals with quartiles....223

Mathematical notation....224

Approaches to splitting....227

Conformalized regression....227

Conformalized forecasting....228

Working with EnbPI....229

Applying EnbPI to our PyTorch model....231

Evaluating conformal interval quality....236

Summary....238

Recommended reading....238

Get this books PDF version and more....239

Chapter 8: Recurrent Neural Networks....240

Time-series data and states....240

Swing angle forecasting....240

Why recurrent models help....242

Introducing RNNs....243

Simple RNN....245

Theoretical background....245

RNNs and differential equations....246

Implementation....246

Introducing LSTM....251

Introducing GRUs....253

Stacking....254

Forecasting using RNNs....255

Summary....264

Recommended reading....264

Chapter 9: Transformers....266

The vanilla transformer....268

Encoder-decoder....268

Attention mechanism....269

Knowledge of temporal information....274

Implementation of transformers....277

The M5 competition....283

Summary....290

Recommended reading....290

Get this books PDF version and more....291

Chapter 10: Other Neural Structures....292

Setting up our M5 dataset....293

Exploring some neural network families....297

Multilayer perceptron....299

N-BEATS....301

N-HITS....305

Convolutional Neural Networks....307

Graph neural networks....309

Kolmogorov–Arnold networks....311

Foundation models....314

Summary....316

Recommended reading....317

Join our community on Discord....317

Chapter 11: Transfer Learning and Global Modelling....318

What is transfer learning?....319

Types of transfer learning....321

Applications of transfer learning....321

Structuring time series data for transfer learning....322

Temporal windowing and sequential organization....323

Scale normalization and feature transformation....323

Temporal feature engineering....324

Global modeling....324

Building GFMs with PyTorch....327

Feature integration mechanisms....329

Data organization and batching....333

Training and balanced sampling....334

Optimizers, learning rate scheduling, and batching....337

Transfer learning with NeuralForecast....339

Data preparation....339

Statistical baselines....340

Decision-tree global models....342

Neural network GFMs....344

Pretraining with external data....346

Summary....348

Recommended reading....349

Get this books PDF version and more....350

Chapter 12: Synthetic Time Series Data....352

The data-generating process....353

Data-driven synthetic time series....356

Generating time series data using variational autoencoders....357

Implementing TimeVAE....358

Implementing the model....364

Training the model....379

Generating synthetic data....380

Beyond VAE....383

Summary....383

Recommended reading....383

Join our community on discord....384

Chapter 13: Diffusion Models....386

Introduction to probabilistic forecasting....386

Diffusion as a real-world phenomenon....387

Simulating the diffusion process....389

Naive diffusion model applied on time series data....395

Denoising diffusion model....406

Summary....408

Recommended reading....409

Get this books PDF version and more....409

Chapter 14: Time Series Classification....410

Types of time-series comparisons....411

Distance-based measures....411

Norms....412

Dynamic time warping....412

Retrieving alignment paths....415

Applied distances....415

Elastic ensemble....417

Proximity forest....418

Comparing distance methods....419

Feature-based algorithms....420

Features built-in....421

Interpreting features....432

Building features....432

Shapelets....435

Dictionary-based classification....438

Convolution-based classification....441

Deep learning approaches....443

Convolutional neural networks....443

ResNet....444

InceptionTime....445

H-InceptionTime....447

LiteTime....448

Summary....449

Recommended reading....450

Join our community on discord....450

Chapter 15: Time Series Clustering....452

What is clustering?....454

Preprocessing for time series clustering....460

Defining time series clustering....461

The TSCL pipeline....462

Clustering approaches....463

Distance-based....463

Distribution-based....464

Subsequence-based....465

Representation learning....466

Deep-learning approaches to TSCL....467

Two-stage pipeline....467

End-to-end neural clustering....468

Applying featurization....469

Data preparation....470

Feature extraction....472

Scaling....475

Selecting the number of clusters....475

Building GFMs with cluster labels....479

Denoising with an autoencoder....481

Autoencoder hyperparameters....486

Evaluating clustering results....488

Summary....490

Recommended reading....491

Get this books PDF version and more....491

Chapter 16: Embeddings for Time Series....492

A dynamical systems perspective....492

Learned embeddings....495

The diversity of time series embeddings....499

Summary....500

Recommended reading....500

Join our community on discord....501

Chapter 17: Supervised and Unsupervised Anomaly Detection....502

What is an outlier or anomaly?....503

Evaluating TSAD systems....509

Rule-based approaches....511

Adaptive thresholds....515

Statistical profiling....519

Building profiles....520

Residuals as the detection signal....523

The One-Class gaussian....524

Isolation forest....524

Isolation forest – unsupervised....525

Standard isolation forest on residuals....527

Extended isolation forest....528

Local outlier factor....530

Matrix profile....532

Application to residuals....533

Multidimensional matrix profile....535

Choosing the window length....538

Matrix profile vs. Point-Based methods....540

Alternative approaches....541

AB-Join: comparing against a reference period....541

Window-Overlap evaluation....542

Where matrix profile fits....543

A comparative summary....544

Supervised anomaly detection....545

The label quality problem....545

Class imbalance....545

Gradient boosting on residual features....546

Threshold adjustment....550

Forecast-First anomaly detection....552

The pipeline....552

The iteration loop....553

Supervised extension....553

Composability in practice....554

Library ecosystem....554

Summary....555

Recommended reading....555

Get this books PDF version and more....556

Chapter 18: Self-Supervised Learning for Time Series....558

Why do we need representations of time series?....559

Self-supervised learning....559

Contrastive predictive coding....562

Data preparation....563

Model implementation....568

Training preparation....575

Training and evaluation....580

Summary....583

Recommended reading....584

Join our community on discord....584

Chapter 19: Unlock Your Exclusive Benefits....586

Unlock this Books Free Benefits in 3 Easy Steps....587

Other Books You May Enjoy....592

Index....596

Time series is far more than fit-predict forecasting. Real mastery comes from intuition and is built through experimentation. Walk the full range with two practitioners: forecasting, conformal prediction, transfer learning, and beyond.

Key Features

  • Grasp core concepts through clear explanations that build genuine understanding rather than surface familiarity
  • Work with realistic datasets and develop the judgement to choose the right approach for your problem
  • Progress from neural network fundamentals to advanced techniques across a full range of time series challenges.

Book Description

Neural networks are powerful tools for time-series forecasting, but applying them effectively requires both practical experience and a clear understanding of architectures, training strategies, and evaluation methods. This book brings these ideas together in a structured and practical way.

Starting with PyTorch fundamentals, you will build neural networks from scratch and progress through recurrent networks, attention mechanisms, and transformers before exploring forecasting architectures such as N-BEATS, N-HiTS, and the Temporal Fusion Transformer. Along the way, you will learn robust hyperparameter tuning, conformal prediction for uncertainty estimation, and reliable evaluation practices.

Unlike most forecasting books, this text also explores topics often overlooked or treated separately, including transfer learning across collections of series, synthetic data generation with diffusion models, and self-supervised representation learning. Beyond forecasting, later chapters cover classification, clustering, anomaly detection, and embeddings for large-scale time-series modeling.

Throughout, the focus is pragmatic: theory is reinforced through experimentation and implementation so you can apply these methods confidently to real-world time-series problems.

What you will learn

  • Build, train, and evaluate neural networks for time series using PyTorch and PyTorch Lightning. Tune models with Bayesian optimisation and validate them with suitable metrics and strategies.
  • Progress from feedforward and recurrent networks to transformers and models such as N-BEATS, N-HiTS, and TFT.
  • Learn how global models use cross- and transfer learning across many series.
  • Generate synthetic series and representations with diffusion and self-supervised methods.
  • Apply modern approaches to classification, clustering, and anomaly detection.

Who this book is for

This book is for data analysts, scientists, and students who want to know how to apply deep learning methods to time-series forecasting problems with PyTorch for real-world business problems.

While the book assumes some understanding of statistics and modeling, you won’t need in-depth knowledge of time series to follow along. Some familiarity with Python is important, but we do not assume any prior knowledge of PyTorch.

The main goal of this book is to be accessible to those with little or no experience with deep learning methods in time series.


Похожее:

Список отзывов:

Нет отзывов к книге.