๐”– Scriptorium
โœฆ   LIBER   โœฆ

๐Ÿ“

Modern Time Series Forecasting with Python: Explore industry-ready time series forecasting using modern machine learning and deep learning

โœ Scribed by Manu Joseph


Publisher
Packt Publishing
Year
2022
Tongue
English
Leaves
552
Category
Library

โฌ‡  Acquire This Volume

No coin nor oath required. For personal study only.

โœฆ Synopsis


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.

Table of Contents

  1. Introducing Time Series
  2. Acquiring and Processing Time Series Data
  3. Analyzing and Visualizing Time Series Data
  4. Setting a Strong Baseline Forecast
  5. Time Series Forecasting as Regression
  6. Feature Engineering for Time Series Forecasting
  7. Target Transformations for Time Series Forecasting
  8. Forecasting Time Series with Machine Learning Models
  9. Ensembling and Stacking
  10. Global Forecasting Models
  11. Introduction to Deep Learning
  12. Building Blocks of Deep Learning for Time Series
  13. Common Modeling Patterns for Time Series
  14. Attention and Transformers for Time Series
  15. Strategies for Global Deep Learning Forecasting Models

(N.B. Please use the Look Inside option to see further chapters)

โœฆ Table of Contents


Cover
Title Page
Copyright and Credits
Dedication
Contributors
Table of Contents
Preface
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
About Packt
Other Books You May Enjoy


๐Ÿ“œ SIMILAR VOLUMES


Machine Learning for Time Series Forecas
โœ Francesca Lazzeri ๐Ÿ“‚ Library ๐Ÿ“… 2020 ๐Ÿ› Wiley ๐ŸŒ English

Learn how to apply the principles of machine learning to time series modeling with this indispensable resource Machine Learning for Time Series Forecasting with Python is an incisive and straightforward examination of one of the most crucial elements of decision-making in finance, marketing, edu

Machine Learning for Time Series Forecas
โœ Francesca Lazzeri ๐Ÿ“‚ Library ๐Ÿ“… 2020 ๐Ÿ› Wiley ๐ŸŒ English

Learn how to apply the principles of machine learning to time series modeling with this indispensable resource Machine Learning for Time Series Forecasting with Python is an incisive and straightforward examination of one of the most crucial elements of decision-making in finance, marketing, edu

Deep Time Series Forecasting with Python
โœ N D Lewis ๐Ÿ“‚ Library ๐Ÿ“… 2016 ๐Ÿ› CreateSpace Independent Publishing Platform ๐ŸŒ English

<h2> Master Deep Time Series Forecasting with Python!</h2> <b> Deep Time Series Forecasting with Python</b> takes you on a gentle, fun and unhurried practical journey to creating deep neural network models for time series forecasting with Python. It uses plain language rather than mathematics;

Time Series Algorithms Recipes: Implemen
โœ Akshay R Kulkarni, Adarsha Shivananda, Anoosh Kulkarni, V Adithya Krishnan ๐Ÿ“‚ Library ๐Ÿ“… 2023 ๐Ÿ› Apress ๐ŸŒ English

This book teaches the practical implementation of various concepts for time series analysis and modeling with Python through problem-solution-style recipes, starting with data reading and preprocessing. It begins with the fundamentals of time series forecasting using statistical modeling methods