• Stars
    star
    315
  • Rank 128,068 (Top 3 %)
  • Language
    Jupyter Notebook
  • License
    MIT License
  • Created almost 3 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Modern Time Series Forecasting with Python, published by Packt

Modern Time Series Forecasting with Python

Modern Time Series Forecasting with Python

This is the code repository for Modern Time Series Forecasting with Python, published by Packt.

Explore industry-ready time series forecasting using modern machine learning and deep learning

What is this book about?

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 book covers the following exciting features:

  • 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

If you feel this book is for you, get your copy today!

https://www.packtpub.com/

Instructions and Navigations

All of the code is organized into folders.

The code will look like the following:

#Does not support missing values, so using imputed ts instead
res = seasonal_decompose(ts, period=7*48, model="additive",
extrapolate_trend="freq")

Following is what you need for this book: 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.

Setup the environment

The easiest way to setup the environment is by using Anaconda, a distribution of Python for scientific computing. You can use Miniconda, a minimal installer for conda as well if you do not want the pre-installed packages that come with Anaconda.

  1. Install Anaconda/Miniconda: Anaconda can be installed from https://www.anaconda.com/products/distribution. Depending on your operating system choose the corresponding file and follow instructions. Or you can install Miniconda from here: https://docs.conda.io/en/latest/miniconda.html#latest-miniconda-installer-links.
  2. Open conda prompt: To open Anaconda Prompt (or terminal on Linux or macOS):
    1. Windows: Open the Anaconda Prompt (Start >> Anaconda Prompt)
    2. macOS: Open Launchpad and then open Terminal. Type conda activate
    3. Linux: Open Terminal. Type conda activate
  3. Navigate to the downloaded code: Use operating system specific commands to navigate to the folder where you have downloaded the code. For instance, in Windows, use cd.
  4. Install the environment: Using the anaconda_env.yml file that is included install the environment. conda env create -f anaconda_env.yml This creates a new environment under the name, modern_ts, and will install all the required libraries in the environment. This can take a while.
  5. Checking the installation: We can check if all the libraries required for the book is installed properly by executing a script in the downloaded code folder python test_installation.py
  6. Activating the environment and Running Notebooks: Every time you want to run the notebooks, first activate the environment using the command conda activate modern_ts and then use Jupyter Notebook (jupyter notebook) or Jupyter Lab (jupyter lab) according to your preference.

If anaconda installation stalls

Sometimes the anaconda installation can stall at Solving Environment. This is because anaconda can sometimes be really slow at resolving package dependencies. We can get around this by using Mamba.

Mamba is a fast, robust, and cross-platform package manager.

It runs on Windows, OS X and Linux (ARM64 and PPC64LE included) and is fully compatible with conda packages and supports most of conda’s commands.

All we need to do is:

  1. Install mamba - conda install mamba -n base -c conda-forge
  2. Instead of using conda, use mamba to install the environment - mamba env create -f anaconda_env.yml

Special Instructions for MacOS

If the installation doesn't work for MacOS, please try the following:

  1. In anaconda_env.yml, change the line python-kaleido==0.1.0 to python-kaleido>=0.1.0
  2. In anaconda_env.yml, change the line statsforecast==0.6.0 to statsforecast>=0.6.0

Now, try installing the environment again. If this doesn't work, please raise an issue on the GitHub repo.

Download the Data

You are going to be using a single dataset throughout the book. The book uses London Smart Meters Dataset from Kaggle for this purpose. Therefore, if you don’t have an account with Kaggle, please go ahead and make one. https://www.kaggle.com/account/login?phase=startRegisterTab There are two ways you can download the data- automated and manual. For the automated way, we need to download a key from Kaggle. Let’s do that first (if you are going to choose the manual way, you can skip this).

  1. Click on your profile picture on the top right corner of Kaggle
  2. Select "Account”, and find the section for β€œAPI”
  3. Click the β€œCreate New API Token” button. A file by the name kaggle.json will be downloaded.
  4. Copy the file and place it in the api_keys folder in the downloaded code folder. Now that we have the kaggle.json downloaded and placed in the right folder, let’s look at the three methods to download data:

Method 1: Automated Download

  1. Activate the environment using conda activate modern_ts
  2. Run the provided script from the root directory of downloaded code python scripts/download_data.py That’s it. Now just wait for the script to finish downloading, unzipping and organize the files in the expected format.

Method 2: Manual Download

  1. Go to https://www.kaggle.com/jeanmidev/smart-meters-in-london and download the dataset
  2. Unzip the contents to data/london_smart_meters
  3. Unzip hhblock_dataset to get the raw files we want to work with.
  4. Make sure the unzipped files are in the expected folder structure (next section) Now that you have downloaded the data, we need to make sure it is arranged in the below folder structure. Automated Download does it automatically, but for Manual Download this structure needs to be created. To avoid ambiguity, the expected folder structure can be found below:
data
β”œβ”€β”€ london_smart_meters
β”‚   β”œβ”€β”€ hhblock_dataset
β”‚   β”‚   β”œβ”€β”€ hhblock_dataset
β”‚   β”‚       β”œβ”€β”€ block_0.csv
β”‚   β”‚       β”œβ”€β”€ block_1.csv
β”‚   β”‚       β”œβ”€β”€ ...
β”‚   β”‚       β”œβ”€β”€ block_109.csv
β”‚   │── acorn_details.csv
β”‚   β”œβ”€β”€ informations_households.csv
β”‚   β”œβ”€β”€ uk_bank_holidays.csv
β”‚   β”œβ”€β”€ weather_daily_darksky.csv
β”‚   β”œβ”€β”€ weather_hourly_darksky.csv

There can be additional files as part of the extraction process. You can remove them without impacting anything. There is a helpful script which checks this structure. python test_data_download.py

Blocks vs RAM

Number of blocks to select from the dataset is dependent on how much RAM you have in your machine. Although, these are not rules, but rough guidelines on how much blocks to choose based on your RAM is given below. If you still face problems, please experiment with lowering the number of blocks to make it work better for you.

  • 1 or <1 Block for 4GB RAM
  • 1 or 2 Blocks for 8GB RAM
  • 3 Blocks for 16GB RAM
  • 5 Blocks for 32GB RAM

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.

Related products

Get to Know 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 learningbased 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.

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781803246802

More Repositories

1

Deep-Reinforcement-Learning-Hands-On

Hands-on Deep Reinforcement Learning, published by Packt
Python
2,750
star
2

The-Kaggle-Book

Code Repository for The Kaggle Book, Published by Packt Publishing
Jupyter Notebook
2,056
star
3

Advanced-Deep-Learning-with-Keras

Advanced Deep Learning with Keras, published by Packt
Python
1,700
star
4

Hands-On-Machine-Learning-for-Algorithmic-Trading

Hands-On Machine Learning for Algorithmic Trading, published by Packt
Jupyter Notebook
1,280
star
5

Node.js-Design-Patterns-Third-Edition

Node.js Design Patterns Third Edition, published by Packt
JavaScript
1,162
star
6

Machine-Learning-for-Algorithmic-Trading-Second-Edition_Original

Machine Learning for Algorithmic Trading, Second Edition - published by Packt
Jupyter Notebook
1,083
star
7

Deep-Learning-with-Keras

Code repository for Deep Learning with Keras published by Packt
Jupyter Notebook
1,047
star
8

Deep-Reinforcement-Learning-Hands-On-Second-Edition

Deep-Reinforcement-Learning-Hands-On-Second-Edition, published by Packt
Jupyter Notebook
1,028
star
9

Learning-JavaScript-Data-Structures-and-Algorithms-Third-Edition

Learning JavaScript Data Structures and Algorithms (Third Edition), published by Packt
JavaScript
1,007
star
10

40-Algorithms-Every-Programmer-Should-Know

40 Algorithms Every Programmer Should Know, published by Packt
Python
910
star
11

Learn-CUDA-Programming

Learn CUDA Programming, published by Packt
Cuda
849
star
12

3D-Graphics-Rendering-Cookbook

3D Graphics Rendering Cookbook, published by Packt.
C++
847
star
13

Vulkan-Cookbook

Code repository for Vulkan Cookbook by Packt
C++
784
star
14

Linux-Kernel-Programming

Linux Kernel Programming, published by Packt
Makefile
759
star
15

Learn-Algorithmic-Trading

Learn Algorithmic Trading, Published by Packt
Python
730
star
16

Django-4-by-example

Django 4 by example (4th Edition) published by Packt
Python
718
star
17

Django-3-by-Example

Django 3 by Example (3rd Edition) published by Packt
Python
710
star
18

Node.js_Design_Patterns_Second_Edition_Code

Code repository for Node.js Design Patterns Second Edition, published by Packt
JavaScript
706
star
19

Python-for-Finance-Cookbook

Python for Finance Cookbook, published by Packt
Jupyter Notebook
665
star
20

Pandas-Cookbook

Pandas Cookbook, published by Packt
Jupyter Notebook
623
star
21

Hands-on-Exploratory-Data-Analysis-with-Python

Hands-on Exploratory Data Analysis with Python, published by Packt
Jupyter Notebook
619
star
22

Java-Coding-Problems

Java Coding Problems, published by Packt
Java
615
star
23

Hands-On-Domain-Driven-Design-with-.NET-Core

Hands-On Domain-Driven Design with .NET Core, published by Packt
C#
602
star
24

Modern-Computer-Vision-with-PyTorch

Modern Computer Vision with PyTorch, published by Packt
Jupyter Notebook
585
star
25

Hands-On-GPU-Accelerated-Computer-Vision-with-OpenCV-and-CUDA

Hands-On GPU Accelerated Computer Vision with OpenCV and CUDA, published by Packt
C++
584
star
26

Django-2-by-Example

Django 2 by Example (2nd Edition) published by Packt
Python
567
star
27

Learning-OpenCV-4-Computer-Vision-with-Python-Third-Edition

Learning OpenCV 4 Computer Vision with Python 3 – Third Edition, published by Packt
Python
562
star
28

Learn-Data-Structures-and-Algorithms-with-Golang

Learn Data Structures and Algorithms with Golang, published by Packt
Go
557
star
29

Causal-Inference-and-Discovery-in-Python

Causal Inference and Discovery in Python by Packt Publishing
Jupyter Notebook
555
star
30

TensorFlow-Machine-Learning-Cookbook

Code repository for TensorFlow Machine Learning Cookbook by Packt
Python
552
star
31

Transformers-for-Natural-Language-Processing

Transformers for Natural Language Processing, published by Packt
Jupyter Notebook
539
star
32

Data-Engineering-with-Python

Data Engineering with Python, published by Packt
Python
537
star
33

Mastering-OpenCV-4-Third-Edition

Mastering OpenCV 4, Third Edition, published by Packt publishing
Assembly
520
star
34

Cpp17-STL-Cookbook

Code files by Packt
C++
514
star
35

Clean-Code-in-Python

Clean Code in Python, published by Packt
Python
513
star
36

Hands-On-Graph-Neural-Networks-Using-Python

Hands-On Graph Neural Networks Using Python, published by Packt
Jupyter Notebook
500
star
37

Getting-Started-with-TensorFlow

Getting Started with TensorFlow, published by Packt
Python
491
star
38

Hands-On-Data-Structures-and-Algorithms-with-Rust

Hands-On Data Structures and Algorithms with Rust, published by Packt
Rust
486
star
39

Linux-Device-Drivers-Development

Linux Device Drivers Development, published by Packt
C
482
star
40

Python-Machine-Learning-Second-Edition

Python Machine Learning - Second Edition, published by Packt
Jupyter Notebook
477
star
41

Mastering-Graphics-Programming-with-Vulkan

C++
469
star
42

Learn-LLVM-12

Learn LLVM 12, published by Packt
C++
465
star
43

Mastering-Embedded-Linux-Programming-Third-Edition

Mastering Embedded Linux Programming Third Edition, published by Packt
C
460
star
44

Python-3-Object-Oriented-Programming-Third-Edition

Python 3 Object-Oriented Programming – Third Edition, published by Packt
Python
453
star
45

Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud

Hands-On Microservices with Spring Boot and Spring Cloud, published by Packt
Java
452
star
46

Software-Architecture-with-Cpp

Software Architecture with C++, published by Packt
C++
447
star
47

Full-Stack-React-Projects-Second-Edition

Full-Stack React Projects - Second Edition, published by Packt
JavaScript
445
star
48

Python-Feature-Engineering-Cookbook

Python Feature Engineering Cookbook, published by Packt
Jupyter Notebook
442
star
49

Deep-Learning-with-PyTorch

Deep Learning with PyTorch, published by Packt
Jupyter Notebook
437
star
50

Interpretable-Machine-Learning-with-Python

Interpretable Machine Learning with Python, published by Packt
Jupyter Notebook
423
star
51

Python-Machine-Learning-Cookbook

Code files for Python-Machine-Learning-Cookbook
Python
416
star
52

Modern-CMake-for-Cpp

Modern CMake for C++, published by Packt
Dockerfile
411
star
53

Artificial-Intelligence-with-Python

Code repository for Artificial Intelligence with Python, published by Packt
Python
408
star
54

Hands-On-Software-Engineering-with-Golang

Hands-On Software Engineering with Golang, published by Packt
Go
406
star
55

Mastering-Python-for-Finance-Second-Edition

Mastering Python for Finance – Second Edition, published by Packt
Jupyter Notebook
394
star
56

Go-Design-Patterns

This is the code repository for the book, Go Design Patterns, published by Packt
Go
394
star
57

Mastering-Python-Design-Patterns-Second-Edition

Mastering-Python-Design-Patterns-Second-Edition, published by Packt
Python
389
star
58

Mastering-Go-Second-Edition

Mastering Go Second Edition, published by Packt
Go
384
star
59

Hands-On-Machine-Learning-with-CPP

Hands-On Machine Learning with C++, published by Packt
C++
377
star
60

Learn-OpenCV-4-By-Building-Projects-Second-Edition

Learn OpenCV 4 By Building Projects, Second Edition, published by Packt
C++
367
star
61

Hands-On-Computer-Vision-with-TensorFlow-2

Hands-On Computer Vision with TensorFlow 2, published by Packt
Jupyter Notebook
366
star
62

Mastering-OpenCV-4-with-Python

Mastering OpenCV 4 with Python, published by Packt
Python
362
star
63

Hands-On-Microservices-with-Rust

Hands-On Microservices with Rust 2018, published by Packt
Rust
354
star
64

Hands-On-Design-Patterns-with-CPP

Hands-On Design Patterns with C++, published by Packt
C
353
star
65

Python-Machine-Learning-Blueprints

Code repository for Python Machine Learning Blueprints, published by Packt
Jupyter Notebook
349
star
66

Practical-Time-Series-Analysis

Practical Time-Series Analysis, published by Packt
Jupyter Notebook
345
star
67

Machine-Learning-for-Algorithmic-Trading-Bots-with-Python

Jupyter Notebook
337
star
68

Machine-Learning-for-Finance

Machine Learning for Finance, published by Packt
Jupyter Notebook
336
star
69

Effective-Python-Penetration-Testing

Effective Python Penetration Testing by Packt Publishing
Python
334
star
70

Python-Algorithmic-Trading-Cookbook

Python Algorithmic Trading Cookbook, published by Packt
Jupyter Notebook
325
star
71

Hands-On-Intelligent-Agents-with-OpenAI-Gym

Code for Hands On Intelligent Agents with OpenAI Gym book to get started and learn to build deep reinforcement learning agents using PyTorch
Python
322
star
72

Python-Artificial-Intelligence-Projects-for-Beginners

Python Artificial Intelligence Projects for Beginners, published by Packt
Jupyter Notebook
321
star
73

Hands-On-Reactive-Programming-in-Spring-5

Hands-On Reactive Programming in Spring 5, published by Packt
Java
320
star
74

Micro-State-Management-with-React-Hooks

Micro State Management with React Hooks, published by Packt
TypeScript
317
star
75

The-Azure-Cloud-Native-Architecture-Mapbook

The Azure Cloud Native Architecture Mapbook, published by Packt
C#
315
star
76

Godot-Game-Engine-Projects

Godot Game Engine Projects, published by Packt
GDScript
315
star
77

Python-GUI-Programming-Cookbook-Second-Edition

Python GUI Programming Cookbook, Second Edition, published by Packt
Python
312
star
78

Computer-Vision-with-OpenCV-3-and-Qt5

Computer Vision with OpenCV 3 and Qt5, published by Packt
C++
305
star
79

Learning-PySpark

Code repository for Learning PySpark by Packt
Jupyter Notebook
303
star
80

Deep-Learning-with-TensorFlow-2-and-Keras

Deep Learning with TensorFlow 2 and Keras, published by Packt
Jupyter Notebook
302
star
81

PyTorch-Computer-Vision-Cookbook

PyTorch Computer Vision Cookbook, Published by Packt
Jupyter Notebook
302
star
82

Mastering-Machine-Learning-for-Penetration-Testing

Mastering Machine Learning for Penetration Testing, published by Packt
Python
298
star
83

Learning-Vuejs-2

This is the code repository for Learning Vue.js 2, published by Packt.
JavaScript
296
star
84

Building-Data-Science-Applications-with-FastAPI

Building Data Science Applications with FastAPI, Published by Packt
Python
295
star
85

OpenGL-4-Shading-Language-Cookbook-Third-Edition

OpenGL 4 Shading Language Cookbook - Third Edition, published by Packt
C
295
star
86

Mastering-Transformers

Mastering Transformers, published by Packt
Jupyter Notebook
289
star
87

Neural-Network-Projects-with-Python

Neural Network Projects with Python, Published by Packt
Python
289
star
88

Bioinformatics-with-Python-Cookbook-Second-Edition

Bioinformatics with Python Cookbook Second Edition, published by Packt
OpenEdge ABL
287
star
89

Hands-on-Python-for-Finance

Hands-on Python for Finance published by Packt.
Jupyter Notebook
284
star
90

Full-Stack-React-TypeScript-and-Node

Full-Stack React, TypeScript, and Node, published by Packt
TypeScript
282
star
91

CPP-Data-Structures-and-Algorithms

C++ Data Structures and Algorithms, published by Packt
C++
279
star
92

The-Modern-Cpp-Challenge

The Modern C++ Challenge, published by Packt
C
276
star
93

The-Complete-Coding-Interview-Guide-in-Java

The Complete Coding Interview Guide in Java, published by Packt
Java
272
star
94

Pandas-Cookbook-Second-Edition

Pandas Cookbook Second Edition, published by Packt
Jupyter Notebook
271
star
95

Full-Stack-React-Projects

Full-Stack React Projects, published by Packt
JavaScript
271
star
96

Machine-Learning-for-Cybersecurity-Cookbook

Machine Learning for Cybersecurity Cookbook, published by Packt
Jupyter Notebook
270
star
97

Natural-Language-Processing-with-TensorFlow

Natural Language Processing with TensorFlow, published by Packt
Jupyter Notebook
269
star
98

50-Projects-In-50-Days---HTML-CSS-JavaScript

50 Projects In 50 Days - HTML, CSS & JavaScript, by Packt Publishing
CSS
269
star
99

Hands-On-Image-Processing-with-Python

Jupyter Notebook
264
star
100

Mastering-Distributed-Tracing

"Mastering Distributed Tracing" by Yuri Shkuro, published by Packt
Java
264
star