The MSSA Python Package for Time-series Prediction — A Hidden Gem?

Michael Rowe
3 min readMay 1, 2023

--

I love finding little packages that don’t get a lot of press, are easy to use, and are not wedded to pandas.

MSSA (Multivariate Singular Spectrum Analysis) is a Python package for multivariate time-series analysis that provides a range of tools for decomposing and forecasting complex time-series data. The package is built on the principles of Singular Spectrum Analysis (SSA), a data-driven technique for time-series decomposition that has been widely used in various fields.

MSSA can be used to analyze and forecast multivariate time-series data that exhibit complex patterns and dependencies. It works by decomposing the data into a set of orthogonal components, which can be used to identify the underlying patterns and trends in the data. These components can then be used to generate forecasts for future time points.

MSSA includes a variety of functions for data preprocessing, decomposition, and forecasting. The MSSA class provides a high-level interface for performing SSA-based decomposition on multivariate time-series data. The Forecasting class provides functions for generating forecasts using the decomposed components. The Visualization class provides functions for visualizing the decomposed components and the forecasts.

One advantage of MSSA is its ability to handle multivariate time-series data, which can be challenging to analyze and forecast using traditional methods. It can also handle missing data and can automatically detect and remove outliers, making it robust to noisy or incomplete data.

Installation & data

We’ll need data too, so:

We grab a time-series:

This Python code imports the MicroReader class from the microprediction package, which is a Python client for accessing time-series data from the Microprediction platform. The code then creates a MicroReader object called mr using the default constructor. This object is used to access time-series data from the platform. The get_lagged_values method of the MicroReader class is then called on the mr object with the argument name='emojitracker-twitter-face_with_tears_of_joy.json'.

Here’s the actual data shown live btw. You can choose any other stream by changing the name of the stream. See the listing of streams and find something you like!

Using MSSA

Really easy!

Though in the notebook this is wrapped to imitate a mock-incremental style before plotting, as this was intended for inclusion in the list of skaters in the timemachines package.

It works pretty well. What a nice change to not have to go through a lot of ceremony just to predict a time-series!

That’s all folks. By all means discuss in the microprediction slack.

--

--

Michael Rowe

Data scientist on health leave. I value constructive interactions. I enjoy probability, statistics and contributing to open source.