Paperback
-
PICK UP IN STORECheck Availability at Nearby Stores
Available within 2 business hours
Related collections and offers
Overview
In Time Series Forecasting in Python you will learn how to:
Recognize a time series forecasting problem and build a performant predictive model
Create univariate forecasting models that account for seasonal effects and external variables
Build multivariate forecasting models to predict many time series at once
Leverage large datasets by using deep learning for forecasting time series
Automate the forecasting process
Time Series Forecasting in Python teaches you to build powerful predictive models from time-based data. Every model you create is relevant, useful, and easy to implement with Python. You’ll explore interesting real-world datasets like Google’s daily stock price and economic data for the USA, quickly progressing from the basics to developing large-scale models that use deep learning tools like TensorFlow.
Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.
About the technology
You can predict the future—with a little help from Python, deep learning, and time series data! Time series forecasting is a technique for modeling time-centric data to identify upcoming events. New Python libraries and powerful deep learning tools make accurate time series forecasts easier than ever before.
About the book
Time Series Forecasting in Python teaches you how to get immediate, meaningful predictions from time-based data such as logs, customer analytics, and other event streams. In this accessible book, you’ll learn statistical and deep learning methods for time series forecasting, fully demonstrated with annotated Python code. Develop your skills with projects like predicting the future volume of drug prescriptions, and you’ll soon be ready to build your own accurate, insightful forecasts.
What's inside
Create models for seasonal effects and external variables
Multivariate forecasting models to predict multiple time series
Deep learning for large datasets
Automate the forecasting process
About the reader
For data scientists familiar with Python and TensorFlow.
About the author
Marco Peixeiro is a seasoned data science instructor who has worked as a data scientist for one of Canada’s largest banks.
Table of Contents
PART 1 TIME WAITS FOR NO ONE
1 Understanding time series forecasting
2 A naive prediction of the future
3 Going on a random walk
PART 2 FORECASTING WITH STATISTICAL MODELS
4 Modeling a moving average process
5 Modeling an autoregressive process
6 Modeling complex time series
7 Forecasting non-stationary time series
8 Accounting for seasonality
9 Adding external variables to our model
10 Forecasting multiple time series
11 Capstone: Forecasting the number of antidiabetic drug prescriptions in Australia
PART 3 LARGE-SCALE FORECASTING WITH DEEP LEARNING
12 Introducing deep learning for time series forecasting
13 Data windowing and creating baselines for deep learning
14 Baby steps with deep learning
15 Remembering the past with LSTM
16 Filtering a time series with CNN
17 Using predictions to make more predictions
18 Capstone: Forecasting the electric power consumption of a household
PART 4 AUTOMATING FORECASTING AT SCALE
19 Automating time series forecasting with Prophet
20 Capstone: Forecasting the monthly average retail price of steak in Canada
21 Going above and beyond
Product Details
ISBN-13: | 9781617299889 |
---|---|
Publisher: | Manning |
Publication date: | 10/04/2022 |
Pages: | 456 |
Sales rank: | 1,129,507 |
Product dimensions: | 7.38(w) x 9.25(h) x 1.10(d) |
About the Author
Table of Contents
Preface xvii
Acknowledgments xix
About this book xx
About the author xxiv
About the cover illustration xxv
Part 1 Time waits for no one 1
1 Understanding time series forecasting 3
1.1 Introducing time series 4
Components of a time series 5
1.2 Bird's-eye view of time series forecasting 8
Setting a goal 9
Determining what must be forecast to achieve your goal 9
Setting the horizon of the forecast 10
Gathering the data 10
Developing a forecasting model 10
Deploying to production 11
Monitoring 11
Collecting new data 11
1.3 How time series forecasting is different from other regression tasks 12
Time series have an order 12
Time series sometimes do not have features 13
1.4 Next steps 13
2 A naive prediction of the future 14
2.1 Defining a baseline model 16
2.2 Forecasting the historical mean 17
Setup for baseline implementations 17
Implementing the historical mean baseline 19
2.3 Forecasting last year's mean 23
2.4 Predicting using the last known value 25
2.5 Implementing the naive seasonal forecast 26
2.6 Next steps 28
3 Going on a random walk 30
3.1 The random walk process 31
Simulating a random walk process 32
3.2 Identifying a random walk 35
Stationarity 36
Testing for stationarity 38
The autocorrelation function 41
Putting it all together 42
Is GOOGL a random walk? 45
3.3 Forecasting a random walk 47
Forecasting on a long horizon 48
Forecasting the next timestep 52
3.4 Next steps 55
3.5 Exercises 56
Simulate and forecast a random walk 56
Forecast the daily closing price of GOOGL 57
Forecast the daily closing price of a stock of your choice 57
Part 2 Forecasting with statistical models 59
4 Modeling a moving average process 61
4.1 Defining a moving average process 63
Identifying the order of a moving average process 64
4.2 Forecasting a moving average process 69
4.3 Next steps 78
4.4 Exercises 79
Simulate an MA(2) process and make forecasts 79
Simulate an MA(q) process and make forecasts 80
5 Modeling an autoregressive process 81
5.1 Predicting the average weekly foot traffic in a retail store 82
5.2 Defining the autoregressive process 84
5.3 Finding the order of a stationary autoregressive process 85
The partial autocorrelation function (PACF) 89
5.4 Forecasting an autoregressive process 92
5.5 Next steps 98
5.6 Exercises 99
Simulate an AR(2) process and make forecasts 99
Simulate an AR(p) process and make forecasts 100
6 Modeling complex time series 101
6.1 Forecasting bandwidth usage for data centers 102
6.2 Examining the autoregressive moving average process 105
6.3 Identifying a stationary ARMA process 106
6.4 Devising a general modeling procedure 111
Understanding the Akaike information criterion (AIC) 113
Selecting a model using the AIC 114
Understanding residual analysis 116
Performing residual analysis 121
6.5 Applying the general modeling procedure 125
6.6 Forecasting bandwidth usage 132
6.7 Next steps 136
6.8 Exercises 137
Make predictions on the simulated ARMA(1,1) process 137
Simulate an ARMA(2,2) process and make forecasts 137
7 Forecasting non-stationary time series 140
7.1 Defining the autoregressive integrated moving average model 142
7.2 Modifying the general modeling procedure to account for non-stationary series 143
7.3 Forecasting a non-stationary times series 145
7.4 Next steps 154
7.5 Exercises 154
Apply the ARIMA(p,d,q) model on the datasets from chapters 4, 5, and 6 154
8 Accounting for seasonality 156
8.1 Examining the SARIMA(p,d,q) (P,D,Q)m model 157
8.2 Identifying seasonal patterns in a time series 160
8.3 Forecasting the number of monthly air passengers 163
Forecasting with an ARIMA(p,d,q) model 165
Forecasting with a SARIMA(p,d,q)(P,D,Q)m model 171
Comparing the performance of each forecasting method 176
8.4 Next steps 178
8.5 Exercises 178
Apply the SARIMA(p,d,q)(P,D,Q)m model on the Johnson & Johnson dataset 178
9 Adding external variables to our model 180
9.1 Examining the SARIMAX model 182
Exploring the exogenous variables of the US macroeconomics dataset 183
Caveat for using SARIMAX 185
9.2 Forecasting the real GDP using the SARIMAX model 186
9.3 Next steps 195
9.4 Exercises 195
Use all exogenous variables in a SARIMAX model to predict the real GDP 195
10 Forecasting multiple time series 197
10.1 Examining the VAR model 199
10.2 Designing a modeling procedure for the VAR(p) model 201
Exploring the Granger causality test 201
10.3 Forecasting real disposable income and real consumption 203
10.4 Next steps 214
10.5 Exercises 214
Use a VARMA model to predict realdpi and realcons 214
Use a VARMAX model to predict realdpi and realcons 215
11 Capstone: Forecasting the number of antidiabetic drug prescriptions in Australia 216
11.1 Importing the required libraries and loading the data 218
11.2 Visualizing the series and its components 219
11.3 Modeling the data 220
Performing model selection 222
Conducting residual analysis 224
11.4 Forecasting and evaluating the model's performance 225
11.5 Next steps 229
Part 3 Large-scale forecasting with deep learning 231
12 Introducing deep learning for time series forecasting 233
12.1 When to use deep learning for time series forecasting 234
12.2 Exploring the different types of deep learning models 234
12.3 Getting ready to apply deep learning for forecasting 237
Performing data exploration 237
Feature engineering and data splitting 241
12.4 Next steps 246
12.5 Exercise 246
13 Data windowing and creating baselines for deep learning 248
13.1 Creating windows of data 249
Exploring how deep learning models are trained for time series forecasting 249
Implementing the Data Window class 253
13.2 Applying baseline models 260
Single-step baseline model 260
Multi-step baseline models 263
Multi-output baseline model 266
13.3 Next steps 268
13.4 Exercises 269
14 Baby steps with deep learning 270
14.1 Implementing a linear model 271
Implementing a single-step linear model 272
Implementing a multi-step linear model 274
Implementing a multi-output linear model 275
14.2 Implementing a deep neural network 276
Implementing a deep neural network as a single-step model 278
Implementing a deep neural network as a multi-step model 281
Implementing a deep neural network as a multi-output model 282
14.3 Next steps 284
14.4 Exercises 285
15 Remembering the past with LSTM 287
15.1 Exploring the recurrent neural network (RNN) 288
15.2 Examining the LSTM architecture 290
The forget gate 291
The input gate 292
The output gate 294
15.3 Implementing the LSTM architecture 295
Implementing an LSTM as a single-step model 295
Implementing an LSTM as a multi-step model 297
Implementing an LSTM as a multi-output model 299
15.4 Next steps 302
15.5 Exercises 303
16 Filtering a time series with CNN 305
16.1 Examining the convolutional neural network (CNN) 306
16.2 Implementing a CNN 309
Implementing a CNN as a single-step model 310
Implementing a CNN as a multi-step model 314
Implementing a CNN as a multi-output model 315
16.3 Next steps 317
16.4 Exercises 318
17 Using predictions to make more predictions 320
17.1 Examining the ARLSTM architecture 321
17.2 Building an autoregressive LSTM model 322
17.3 Next steps 327
17.4 Exercises 328
18 Capstone: Forecasting the electric power consumption of a household 329
18.1 Understanding the capstone project 330
Objective of this capstone project 331
18.2 Data wrangling and preprocessing 333
Dealing with missing data 334
Data conversion 335
Data resampling 335
18.3 Feature engineering 338
Removing unnecessary columns 338
Identifying the seasonal period 339
Splitting and scaling the data 341
18.4 Preparing for modeling with deep learning 342
Initial setup 342
Defining the DataWindow class 343
Utility junction to train our models 346
18.5 Modeling with deep learning 346
Baseline models 346
Linear model 349
Deep neural network 350
Long short-term memory (LSTM) model 351
Convolutional neural network (CNN) 351
Combining a CNN with an LSTM 354
The autoregressive LSTM model 355
Selecting the best model 356
18.6 Next steps 358
Part 4 Automating forecasting at scale 359
19 Automating time series forecasting with Prophet 361
19.1 Overview of the automated forecasting libraries 362
19.2 Exploring Prophet 363
19.3 Basic forecasting with Prophet 365
19.4 Exploring Prophet's advanced functionality 370
Visualization capabilities 370
Cross-validation and performance metrics 374
Hyperparameter tuning 379
19.5 Implementing a robust forecasting process with Prophet 381
Forecasting project: Predicting the popularity of "chocolate" searches on Google 381
Experiment: Can SARIMA do better? 389
19.6 Next steps 393
19.7 Exercises 394
Forecast the number of air passengers 394
Forecast the volume of antidiabetic drug prescriptions 394
Forecast the popularity of a keyword on Google Trends 394
20 Capstone: Forecasting the monthly average retail price of steak in Canada 396
20.1 Understanding the capstone project 397
Objective of the capstone project 397
20.2 Data preprocessing and visualization 398
20.3 Modeling with Prophet 400
20.4 Optional: Develop a SARIMA model 404
20.5 Next steps 409
21 Going above and beyond 410
21.1 Summarizing what you've learned 411
Statistical methods for forecasting 411
Deep learning methods for forecasting 412
Automating the forecasting process 413
21.2 What if forecasting does not work? 413
21.3 Other applications of time series data 415
21.4 Keep practicing 416
Appendix Installation instructions 418
Index 421