Skip to content

gakhov/pycon-ua-2018

Repository files navigation

Slides and demonstration examples for the talk at PyCon UA, 2018

An Introduction to Time Series Forecasting with Python

Citation

If you need to cite the presentation or the code, please use DOI 10.13140/RG.2.2.18053.86249

Gakhov, A.V. (2018). An Introduction to Time Series Forecasting with Python [PDF slides]. PyCon UA 2018, April 28-29, 2018, Kharkov, Ukraine. Retrieved from https://github.com/gakhov/pycon-ua-2018 DOI 10.13140/RG.2.2.18053.86249

Talk Abstract

Time series is an important instrument to model, analyze and predict data collected over time. In this talk, we learn the basic theoretical concepts without going deep into mathematical aspects, study different models, and try them in practice using StatsModels, Prophet, scikit-learn, and keras.

Talk Description

Nowadays, it is hard to find a company that doesn’t collect various time-dependent data in different forms, for instance, it can be a daily number of visitors and monthly sales for online stores, available resources and stock for factories, number of food poisoning cases for hospitals, and so on. And the reason why all that data is carefully collected, because it can provide meaningful insides not only about the past but can be used to predict and prepare for the future.

In this presentation, we discuss how to analyze and forecast those data, that is called time series. Many people already did that many times while trying to predict the weather on the weekend, guessing the currency exchange rate for tomorrow, or just by expecting great discounts on Christmas sales. Of course, some patterns are truly obvious, like weekly or monthly changes, and overall tendency, others are not. However, all these aspects can be formalized and learned automatically using the power of mathematics and computer science.

The first part is dedicated to the theoretical introduction of time series, where listeners can learn or refresh in memory the essential aspects of time series’ representations, modeling, and forecasting. In the second part, we dive into the most popular time series forecast models - stochastic models (e.g., Autoregressive integrated moving average (ARIMA)), artificial neural networks (e.g., seasonal recurrent neural network) and Support Vector Machines (SVR). Along the way, we show at practice how these models can be applied to a real-world dataset of UK visits by providing examples using such popular Python libraries as StatsModels, Prophet, scikit-learn, and keras.

With these guidelines in mind, you should be better equipped to deal with time series in your everyday work and opt-in for the right tools to analyze them.

To follow the talk it's not required any prior knowledge of time series analysis, but the basic understanding of mathematics and machine learning approaches could be quite helpful.

GitHub repository: https://github.com/gakhov/pycon-ua-2018/

Structure

Generic dataset exploration

To demonstrate the mentioned in the presentation models, I use the following dataset:

OS visits to UK (All visits)

The dataset represents the monthly total number of visits to the UK by overseas residents (in thousands)
from January 1980 to October 2017. Source: Office for National Statistics

Stochastic Models

As a stochastic model for seasonal time series, in the presentation, I describe the Seasonal Autoregressive Integrated Moving Average (SARIMA) model.

Another example is Facebook Prophet model that implements an additive regression model which is essentially a sophisticated curve-fitting model.

Artificial Neural Networks

I consider recurrent artificial neural networks with Long Short-Term Memory (LSTM) architecture and demonstrate how to create and fit Seasonal Artificial Neural Network (SANN).

Support Vector Machines

Support Vector Machines can be used to forecast time series, particularly the Support Vector Machine Regressors (SVMR) that are demonstrated in the presentation.

Dependencies

Install with pip

Installation requires a working build environment that can be build automatically using make utility:

$ make
$ make run

After these commands your default browser should open a Jupyter notebook's index page.

License

MIT License

Source code

Author

Read More

Seasonal ARIMA with Python

TimeSeries Decomposition in Python with statsmodels and Pandas

How to Make Out-of-Sample Forecasts with ARIMA in Python

Introduction to ARIMA: nonseasonal models

[book] Time Series by A.W. van der Vaart

[github] Time series predictions with Keras

Time Series Prediction with LSTM Recurrent Neural Networks in Python with Keras

[book] Time series analysis by Jan Grandell

Seasonal Decomposition of Time Series by Loess

How To Identify Patterns in Time Series Data: Time Series Analysis

[paper] Another look at measures of forecast accuracy

[book] An Introductory Study on Time Series Modeling and Forecasting

[paper] PSO based Neural Networks vs. Traditional Statistical Models for Seasonal Time Series Forecasting

[paper] Seasonal Time Series Forecasting Models based on Artificial Neural Network

[paper] Improving artificial neural networks’ performance in seasonal time series forecasting

Forecasting strong seasonal time series with artificial neural networks

Recurrent Neural Networks. Part 1: Theory

[slides] Time Series Analysis - Moving average and ARMA processes

How to Make Out-of-Sample Forecasts with ARIMA in Python

Cryptocurrency Predictions with ARIMA

Using Facebook Prophet Forecasting Library to Predict the Weather

Forecasting Time-Series data with Prophet

Prophet: forecasting at scale

Playing with Prophet on Bike Sharing Demand in Washington, D.C.

[paper] Using support vector machines for time series prediction