Modern Time Series Forecasting with Python: Explore industry-ready time series forecasting using modern machine learning and deep learning
- Length: 552 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2022-11-24
- ISBN-10: 1803246804
- ISBN-13: 9781803246802
- Sales Rank: #0 (See Top 100 Books)
Build real-world time series forecasting systems which scale to millions of time series by applying modern machine learning and deep learning concepts
Key Features
- Explore industry-tested machine learning techniques used to forecast millions of time series
- Get started with the revolutionary paradigm of global forecasting models
- Get to grips with new concepts by applying them to real-world datasets of energy forecasting
Book Description
We live in a serendipitous era where the explosion in the quantum of data collected and a renewed interest in data-driven techniques such as machine learning (ML), has changed the landscape of analytics, and with it, time series forecasting. This book, filled with industry-tested tips and tricks, takes you beyond commonly used classical statistical methods such as ARIMA and introduces to you the latest techniques from the world of ML.
This is a comprehensive guide to analyzing, visualizing, and creating state-of-the-art forecasting systems, complete with common topics such as ML and deep learning (DL) as well as rarely touched-upon topics such as global forecasting models, cross-validation strategies, and forecast metrics. You’ll begin by exploring the basics of data handling, data visualization, and classical statistical methods before moving on to ML and DL models for time series forecasting. This book takes you on a hands-on journey in which you’ll develop state-of-the-art ML (linear regression to gradient-boosted trees) and DL (feed-forward neural networks, LSTMs, and transformers) models on a real-world dataset along with exploring practical topics such as interpretability.
By the end of this book, you’ll be able to build world-class time series forecasting systems and tackle problems in the real world.
What you will learn
- Find out how to manipulate and visualize time series data like a pro
- Set strong baselines with popular models such as ARIMA
- Discover how time series forecasting can be cast as regression
- Engineer features for machine learning models for forecasting
- Explore the exciting world of ensembling and stacking models
- Get to grips with the global forecasting paradigm
- Understand and apply state-of-the-art DL models such as N-BEATS and Autoformer
- Explore multi-step forecasting and cross-validation strategies
Who this book is for
The book is for data scientists, data analysts, machine learning engineers, and Python developers who want to build industry-ready time series models. Since the book explains most concepts from the ground up, basic proficiency in Python is all you need. Prior understanding of machine learning or forecasting will help speed up your learning. For experienced machine learning and forecasting practitioners, this book has a lot to offer in terms of advanced techniques and traversing the latest research frontiers in time series forecasting.
Modern Time Series Forecasting with Python Contributors About the author About the reviewers Preface Who this book is for What this book covers To get the most out of this book Setting up an environment Download the data Download the example code files Download the color images Conventions used Get in touch Share Your Thoughts Download a free PDF copy of this book Part 1 – Getting Familiar with Time Series Chapter 1: Introducing Time Series Technical requirements What is a time series? Types of time series Main areas of application for time series analysis Data-generating process (DGP) Generating synthetic time series Stationary and non-stationary time series What can we forecast? Forecasting terminology Summary Further reading Chapter 2: Acquiring and Processing Time Series Data Technical requirements Understanding the time series dataset Preparing a data model pandas datetime operations, indexing, and slicing – a refresher Converting the date columns into pd.Timestamp/DatetimeIndex Using the .dt accessor and datetime properties Slicing and indexing Creating date sequences and managing date offsets Handling missing data Converting the half-hourly block-level data (hhblock) into time series data Compact, expanded, and wide forms of data Enforcing regular intervals in time series Converting the London Smart Meters dataset into a time series format Mapping additional information Saving and loading files to disk Handling longer periods of missing data Imputing with the previous day Hourly average profile The hourly average for each weekday Seasonal interpolation Summary Chapter 3: Analyzing and Visualizing Time Series Data Technical requirements Components of a time series The trend component The seasonal component The cyclical component The irregular component Visualizing time series data Line charts Seasonal plots Seasonal box plots Calendar heatmaps Autocorrelation plot Decomposing a time series Detrending Deseasonalizing Implementations Detecting and treating outliers Standard deviation Interquartile range (IQR) Isolation Forest Extreme studentized deviate (ESD) and seasonal ESD (S-ESD) Treating outliers Summary References Further reading Chapter 4: Setting a Strong Baseline Forecast Technical requirements Setting up a test harness Creating holdout (test) and validation datasets Choosing an evaluation metric Generating strong baseline forecasts Naïve forecast Moving average forecast Seasonal naive forecast Exponential smoothing (ETS) ARIMA Theta Forecast Fast Fourier Transform forecast Evaluating the baseline forecasts Assessing the forecastability of a time series Coefficient of Variation (CoV) Residual variability (RV) Entropy-based measures Kaboudan metric Summary References Further reading Part 2 – Machine Learning for Time Series Chapter 5: Time Series Forecasting as Regression Understanding the basics of machine learning Supervised machine learning tasks Overfitting and underfitting Hyperparameters and validation sets Time series forecasting as regression Time delay embedding Temporal embedding Global forecasting models – a paradigm shift Summary References Further reading Chapter 6: Feature Engineering for Time Series Forecasting Technical requirements Feature engineering Avoiding data leakage Setting a forecast horizon Time delay embedding Lags or backshift Rolling window aggregations Seasonal rolling window aggregations Exponentially weighted moving averages (EWMA) Temporal embedding Calendar features Time elapsed Fourier terms Summary Chapter 7: Target Transformations for Time Series Forecasting Technical requirements Handling non-stationarity in time series Detecting and correcting for unit roots Unit roots The Augmented Dickey-Fuller (ADF) test Differencing transform Detecting and correcting for trends Deterministic and stochastic trends Kendall’s Tau Mann-Kendall test (M-K test) Detrending transform Detecting and correcting for seasonality Detecting seasonality Deseasonalizing transform Detecting and correcting for heteroscedasticity Detecting heteroscedasticity Log transform Box-Cox transform AutoML approach to target transformation Summary References Further reading Chapter 8: Forecasting Time Series with Machine Learning Models Technical requirements Training and predicting with machine learning models Generating single-step forecast baselines Standardized code to train and evaluate machine learning models FeatureConfig MissingValueConfig ModelConfig MLForecast Helper functions for evaluating models Linear regression Regularized linear regression Decision trees Random forest Gradient boosting decision trees Training and predicting for multiple households Using AutoStationaryTransformer Summary References Further reading Chapter 9: Ensembling and Stacking Technical requirements Combining forecasts Best fit Measures of central tendency Simple hill climbing Stochastic hill climbing Simulated annealing Optimal weighted ensemble Stacking or blending Summary References Further reading Chapter 10: Global Forecasting Models Technical requirements Why Global Forecasting Models (GFMs)? Sample size Cross-learning Multi-task learning Engineering complexity Creating GFMs Strategies to improve GFMs Increasing memory Using time series meta-features Tuning hyperparameters Partitioning Bonus – interpretability Summary References Further reading Part 3 – Deep Learning for Time Series Chapter 11: Introduction to Deep Learning Technical requirements What is deep learning and why now? Why now? What is deep learning? Perceptron – the first neural network Components of a deep learning system Representation learning Linear transformation Activation functions Output activation functions Loss function Forward and backward propagation Summary References Further reading Chapter 12: Building Blocks of Deep Learning for Time Series Technical requirements Understanding the encoder-decoder paradigm Feed-forward networks Recurrent neural networks The RNN layer in PyTorch Long short-term memory (LSTM) networks The LSTM layer in PyTorch Gated recurrent unit (GRU) The GRU layer in PyTorch Convolution networks Convolution Padding, stride, and dilations The convolution layer in PyTorch Summary References Further reading Chapter 13: Common Modeling Patterns for Time Series Technical requirements Tabular regression Single-step-ahead recurrent neural networks Sequence-to-sequence (Seq2Seq) models RNN-to-fully connected network RNN-to-RNN Summary Reference Further reading Chapter 14: Attention and Transformers for Time Series Technical requirements What is attention? The generalized attention model Alignment functions The distribution function Forecasting with sequence-to-sequence models and attention Transformers – Attention is all you need Attention is all you need Transformers in time series Forecasting with Transformers Summary References Further reading Chapter 15: Strategies for Global Deep Learning Forecasting Models Technical requirements Creating global deep learning forecasting models Preprocessing the data Understanding TimeSeriesDataset from PyTorch Forecasting Building the first global deep learning forecasting model Using time-varying information Using static/meta information One-hot encoding and why it is not ideal Embedding vectors and dense representations Defining a model with categorical features Using the scale of the time series Balancing the sampling procedure Visualizing the data distribution Tweaking the sampling procedure Using and visualizing the dataloader with WeightedRandomSampler Summary Further reading Chapter 16: Specialized Deep Learning Architectures for Forecasting Technical requirements The need for specialized architectures Neural Basis Expansion Analysis for Interpretable Time Series Forecasting (N-BEATS) The architecture of N-BEATS Forecasting with N-BEATS Interpreting N-BEATS forecasting Neural Basis Expansion Analysis for Interpretable Time Series Forecasting with Exogenous Variables (N-BEATSx) Handling exogenous variables Exogenous blocks Neural Hierarchical Interpolation for Time Series Forecasting (N-HiTS) The Architecture of N-HiTS Forecasting with N-HiTS Informer The architecture of the Informer model Forecasting with the Informer model Autoformer The architecture of the Autoformer model Forecasting with Autoformer Temporal Fusion Transformer (TFT) The Architecture of TFT Forecasting with TFT Interpreting TFT Interpretability Probabilistic forecasting Probability Density Function (PDF) Quantile functions Other approaches Summary References Further reading Part 4 – Mechanics of Forecasting Chapter 17: Multi-Step Forecasting Why multi-step forecasting? Recursive strategy Training regime Forecasting regime Direct strategy Training regime Forecasting regime Joint strategy Training regime Forecasting regime Hybrid strategies DirRec Strategy Iterative block-wise direct strategy Rectify strategy RecJoint How to choose a multi-step forecasting strategy? Summary References Chapter 18: Evaluating Forecasts – Forecast Metrics Technical requirements Taxonomy of forecast error measures Intrinsic metrics Extrinsic metrics Investigating the error measures Loss curves and complementarity Bias towards over- or under-forecasting Experimental study of the error measures Using Spearman’s rank correlation Guidelines for choosing a metric Summary References Further reading Chapter 19: Evaluating Forecasts – Validation Strategies Technical requirements Model validation Holdout strategies Window strategy Calibration strategy Sampling strategy Cross-validation strategies Choosing a validation strategy Validation strategies for datasets with multiple time series Summary References Further reading Index Why subscribe? Other Books You May Enjoy Packt is searching for authors like you Share Your Thoughts Download a free PDF copy of this book
Donate to keep this site alive
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Modern Time Series Forecasting with Python: Explore industry-ready time series forecasting using modern machine learning and deep learning
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.