Learn how to evaluate time series in Python model predictions, build an ARIMA model, and evaluate predictions using mean absolute error.
If you’ve read any of my previous posts, you’ll know I don’t call myself a data scientist. I would call myself a data enthusiast. Being in marketing, I make every business decision based on what the data is telling me.
Having said that, I ran into a great 3-part tutorial series about time series in Python. It’s meant for intermediate to advanced learners, but I found it was incredibly easy to follow along (even if I had to look up some of the concepts/techniques). Each video is between 10-15 minutes and should only take you about 45 minutes to complete.
Here are the packages used in the tutorials:
This tutorial is taught in Python. If you are more comfortable with R, the presenter has shared the R code (and Python) script Repository
Part 1: Read and Transform Your Data
In Part 1, you will learn how to read and index your data for time series, check that the data meets the requirements or assumptions for time series modeling, and transform your data to ensure it meets those requirements. You’ll primarily be using the
The next two parts both start right where Part 1 left off. Both don’t have much of an introduction other than a really short review of what was covered in the previous section(s). If you aren’t completing each tutorial right after the other, make sure to go back and review.
Part 2: ARIMA modeling and forecasting in Python
Part 2 has you building an Arima model using the
StatsModel package, predicting N timestamps into the future. In addition, you will also look at the Autocorrelation Function plot and Partial Autocorrelation Function plot to determine the terms in your time series model.
Part 3: Evaluating time series forecasts
In the final part of the (time) series, you’ll evaluate predictions using mean absolute error and Python’s
matplotlib packages. You’ll plot the last five predicted and actual values, look at the differences and calculate the mean absolute error to help evaluate your ARIMA model. At the end of the video, the presenter challenges you to improve on the model she walks you through.
I don’t have the data science know-how to make improvements, but maybe you do! I encourage you to add the ways you have improved the model to the Discussion. Who knows, maybe I’ll contact you to collaborate on a follow-up blog post.