Tutorial: Machine Learning with Time Series
Round of applause to Andrii Gakhov and his video tutorials!
Instructor: Vaibhav Srivastav
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.
Attendees will need to bring a laptop with scikit-learn and pandas (and their dependencies) already installed. Installing the Anaconda distribution of Python is an easy way to accomplish this. Both Python 2 and 3 are welcome.
I will be leading the tutorial using the IPython/Jupyter notebook, and have added a pre-written notebook to this repository. I have also created a Python script that is identical to the notebook, which you can use in the Python environment of your choice.
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.
GitHub repository: https://github.com/vaibhavs10/ml-for-timeseries/
Attendees to this tutorial should be comfortable working in Python, should understand the basic principles of machine learning, and should have at least basic experience with both pandas and scikit-learn. However, no knowledge of advanced mathematics is required.
To demonstrate the mentioned in the presentation models, I will 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
- Jupyter Notebook: https://github.com/vaibhavs10/ml-for-timeseries/blob/master/look-into-the-data.ipynb
As a stochastic model for seasonal time series, in the presentation, I describe the Seasonal Autoregressive Integrated Moving Average (SARIMA) model.
- Jupyter Notebook: https://github.com/vaibhavs10/ml-for-timeseries/blob/master/stochastic-models.ipynb
- Python package: Statsmodels
Another example is Facebook Prophet model that implements an additive regression model which is essentially a sophisticated curve-fitting model.
- Jupyter Notebook: https://github.com/vaibhavs10/ml-for-timeseries/blob/master/prophet.ipynb
- Python package: Facebook Prophet
- Vaibhav Srivastav email@example.com
[github] Time series predictions with Keras