ebook img

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

552 Pages·2022·25.52 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

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

Modern Time Series Forecasting with Python Explore industry-ready time series forecasting using modern machine learning and deep learning Manu Joseph BIRMINGHAM—MUMBAI Modern Time Series Forecasting with Python Copyright © 2022 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Publishing Product Manager: Dhruv Kataria Senior Editors: Roshan Ravikumar, Tazeen Shaikh Content Development Editor: Shreya Moharir Technical Editor: Devanshi Ayare Copy Editor: Safis Editing Project Coordinator: Farheen Fathima Proofreader: Safis Editing Indexer: Subalakshmi Govindhan Production Designer: Alishon Mendonca Marketing Coordinator: Shifa Ansari First published: November 2022 Production reference: 1181122 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-80324-680-2 www.packt.com For my son, Zane, For his boundless curiosity, For his endless questions, And for his innocent love of learning. (All great qualities for adults who read this book as well.) Contributors About the author Manu Joseph is a self-made data scientist with more than a decade of experience working with many Fortune 500 companies, enabling digital and AI transformations, specifically in machine learning- based demand forecasting. He is considered an expert, thought leader, and strong voice in the world of time series forecasting. Currently, Manu leads applied research at Thoucentric, where he advances research by bringing cutting-edge AI technologies to the industry. He is also an active open source contributor and has developed an open source library—PyTorch Tabular—which makes deep learning for tabular data easy and accessible. Originally from Thiruvananthapuram, India, Manu currently resides in Bengaluru, India, with his wife and son. About the reviewers Dr. Julien Siebert is currently working as a researcher at the Fraunhofer Institute for Experimental Software Engineering (IESE), in Kaiserslautern, Germany. He studied engineering sciences and AI and obtained a PhD in computer science on the topic of modeling and simulation of complex systems. After several years of research both in computer science and theoretical physics, Dr. Julien Siebert worked as a data scientist for an e-commerce fashion company. Since 2018, he has been working at the intersection between software engineering and data science. Gerzson David Boros is the owner and CEO of Data Science Europe and a senior data scientist who has been involved in data science for more than 10 years. He has an MSc and is a candidate for an MBA. In the last 5 years, he and his team have made business proposals for 100 different executives and worked on more than 30 different projects on the topic of data science and artificial intelligence. His motto is “Social responsibility is also achievable with the help of data.” Table of Contents Preface xvii Part 1 – Getting Familiar with Time Series 1 1 Introducing Time Series 3 Technical requirements 3 Stationary and non-stationary time series 13 What is a time series? 4 What can we forecast? 16 Types of time series 4 Forecasting terminology 17 Main areas of application for time series analysis 4 Summary 18 Data-generating process (DGP) 5 Further reading 18 Generating synthetic time series 7 2 Acquiring and Processing Time Series Data 19 Technical requirements 19 Slicing and indexing 26 Understanding the time series dataset 20 Creating date sequences and managing date offsets 27 Preparing a data model 22 Handling missing data 28 pandas datetime operations, Converting the half-hourly block-level data indexing, and slicing (hhblock) into time series data 33 – a refresher 23 Compact, expanded, and wide forms of data 33 Converting the date columns into Enforcing regular intervals in time series 34 pd.Timestamp/DatetimeIndex 24 Converting the London Smart Meters dataset Using the .dt accessor and datetime properties 25 into a time series format 35 viii Table of Contents Mapping additional information 36 Hourly average profile 43 Saving and loading files to disk 38 The hourly average for each weekday 45 Seasonal interpolation 46 Handling longer periods of missing data 38 Summary 48 Imputing with the previous day 42 3 Analyzing and Visualizing Time Series Data 49 Technical requirements 49 Detrending 60 Components of a time series 50 Deseasonalizing 61 Implementations 63 The trend component 50 The seasonal component 51 Detecting and treating outliers 72 The cyclical component 51 Standard deviation 72 The irregular component 51 Interquartile range (IQR) 73 Visualizing time series data 52 Isolation Forest 73 Extreme studentized deviate (ESD) and Line charts 52 seasonal ESD (S-ESD) 73 Seasonal plots 55 Treating outliers 74 Seasonal box plots 56 Calendar heatmaps 58 Summary 75 Autocorrelation plot 58 References 75 Decomposing a time series 60 Further reading 75 4 Setting a Strong Baseline Forecast 77 Technical requirements 78 Seasonal naive forecast 83 Setting up a test harness 78 Exponential smoothing (ETS) 84 ARIMA 87 Creating holdout (test) and validation datasets 78 Theta Forecast 89 Choosing an evaluation metric 79 Fast Fourier Transform forecast 91 Generating strong baseline forecasts 80 Evaluating the baseline forecasts 94 Naïve forecast 82 Assessing the forecastability of a time Moving average forecast 83 series 96 Table of Contents ix Coefficient of Variation (CoV) 96 Summary 103 Residual variability (RV) 97 References 103 Entropy-based measures 98 Further reading 104 Kaboudan metric 101 Part 2 – Machine Learning for Time Series 105 5 Time Series Forecasting as Regression 107 Understanding the basics of machine Temporal embedding 116 learning 107 Global forecasting models – a Supervised machine learning tasks 110 paradigm shift 116 Overfitting and underfitting 110 Summary 118 Hyperparameters and validation sets 113 References 119 Time series forecasting as regression 114 Further reading 119 Time delay embedding 114 6 Feature Engineering for Time Series Forecasting 121 Technical requirements 121 Exponentially weighted moving averages (EWMA) 131 Feature engineering 122 Avoiding data leakage 123 Temporal embedding 134 Setting a forecast horizon 124 Calendar features 134 Time elapsed 135 Time delay embedding 125 Fourier terms 136 Lags or backshift 125 Rolling window aggregations 127 Summary 138 Seasonal rolling window aggregations 129

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.