Skip to main content

Singular Spectrum Analysis Library (SSALib)

Project description

Singular Spectrum Analysis Library (SSALib)

Tests Python Version Coverage License Development Status

Overview

The Singular Spectrum Analysis Library (SSALib) is a Python package for univariate (i.e., single) time series decomposition, designed for multidisciplinary applications like natural sciences, economics, epidemiology, and more. SSALib can be used to explore and extract trends, periodic patterns, and noise from time series.

decomposed_signal.png Figure: Example of Decomposition and Pattern Extraction (standardized) using the Sea Surface Temperature Time Series

Key Features

  • Univariate SSA implementation with both Broemhead & King and Vautard and Ghil approaches
  • Multiple SVD solver options (NumPy, SciPy, scikit-learn)
  • Monte Carlo SSA for significance testing
  • Built-in visualization tools for analysis
  • Include example datasets
  • Comprehensive test coverage
  • Type-annotated codebase

Quick Start

Requirements

  • Python ≥ 3.9
  • NumPy
  • SciPy < 1.16.0
  • Pandas
  • Matplotlib
  • Scikit-learn
  • Statsmodels

Installation

Use

pip install git+https://github.com/ADSCIAN/ssalib.git

or

pip install ssalib

Basic Usage

from ssalib import SingularSpectrumAnalysis
from ssalib.datasets import load_sst

# Load example data: Mean Sea Surface Temperature
ts = load_sst()

# Create SSA instance and decompose
ssa = SingularSpectrumAnalysis(ts)
ssa.decompose()

# Visualize results, in this case, singular values
fig, ax = ssa.plot(kind='values')

# Reconstruct groups
ssa.reconstruct(groups={'trend': [0, 1], 'seasonality': [2, 3]})

# Export
df_ssa = ssa.to_frame()

Available Datasets

Dataset Loading Function Description Time Range Source License
Mortality load_mortality() Daily counts of deaths in Belgium. 1992-01-01 to 2023-12-31 STATBEL Open Data
SST load_sst() Monthly mean sea surface temperature globally between 60° North and South. 1982-01-01 to 2023-12-31 Climate Reanalyzer CC-BY

Available SVD Methods

SSALib supports multiple SVD solvers:

Solver Name Underlying Method Status
numpy_standard numpy.linalg.svd Default
scipy_standard scipy.linalg.svd Available
scipy_sparse scipy.sparse.linalg.svds Available
sklearn_randomized sklearn.utils.extmath.randomized_svd Available

Select the solver with the svd_solver argument.

from ssalib import SingularSpectrumAnalysis
from ssalib.datasets import load_sst

# Load example data
ts = load_sst()

# Create SSA instance with solver 'sklearn_randomized'
ssa = SingularSpectrumAnalysis(ts, svd_solver='sklearn_randomized')

Available Visualizations

kind Description Decomposition Required Reconstruction Required
matrix Plot the matrix or its group reconstruction Optional Optional
paired Plot pairs (x,y) of successive left-eigenvectors Yes No
periodogram Plot periodogram associated with eigenvectors Yes No
timeseries Plot original, preprocessed, or reconstructed time series Optional Optional
values Plot the singular values ranked by value norm or dominant component frequency Yes No
vectors Plot the left eigen vectors Yes No
wcorr Plot the weighted correlation matrix Yes No

Pass the kind argument to the SingularSpectrumAnalysis.plot method.

Documentation

For more in-depth examples and tutorials, check the Jupyter notebooks in the notebooks folder:

In more advanced tutorials, we cover:

References

The main references used to develop SSALib were:

  1. Golyandina, N., & Zhigljavsky, A. (2020). Singular Spectrum Analysis for Time Series. Berlin, Heidelberg: Springer. https://doi.org/10.1007/978-3-662-62436-4
  2. Hassani, H. (2007). Singular Spectrum Analysis: Methodology and Comparison. Journal of Data Science, 5(2), 239–257. https://doi.org/10.6339/JDS.2007.05(2).396
  3. Broomhead, D. S., & King, G. P. (1986). Extracting qualitative dynamics from experimental data. Physica D: Nonlinear Phenomena, 20(2), 217–236. https://doi.org/10.1016/0167-2789(86)90031-X
  4. Vautard, R., & Ghil, M. (1989). Singular spectrum analysis in nonlinear dynamics, with applications to paleoclimatic time series. Physica D: Nonlinear Phenomena, 35(3). https://doi.org/10.1016/0167-2789(89)90077-8
  5. Allen, M. R., & Smith, L. A. (1996). Monte Carlo SSA: Detecting irregular oscillations in the Presence of Colored Noise. Journal of Climate, 9(12), 3373–3404. https://doi.org/10.1175/1520-0442(1996)009<3373:MCSDIO>2.0.CO;2

How to Cite

Awaiting the release of the first non-beta version, you can refer to SSALib using:

@software{ssalib2025,
  author    = {Delforge, Damien AND Alonso, Alice AND de Viron, Olivier AND Vanclooster, Marnik AND Speybroeck, Niko},
  title     = {{SSALib}: A {Python} Library for {Singular Spectrum Analysis}},
  year      = {2025},
  version   = {0.1.2b1},
  url       = {https://github.com/ADSCIAN/ssalib}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ssalib-0.1.2b1.tar.gz (96.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ssalib-0.1.2b1-py3-none-any.whl (83.6 kB view details)

Uploaded Python 3

File details

Details for the file ssalib-0.1.2b1.tar.gz.

File metadata

  • Download URL: ssalib-0.1.2b1.tar.gz
  • Upload date:
  • Size: 96.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for ssalib-0.1.2b1.tar.gz
Algorithm Hash digest
SHA256 78fc03ba43164aa5b028e6c68def0cf1a7b178a94ed907399ac49733d4533808
MD5 e13def7038d738f392771e22219a1836
BLAKE2b-256 e57a7d892e6797d9d43e2a02e0255a99dcaee6415204a338f2a68451d911c982

See more details on using hashes here.

File details

Details for the file ssalib-0.1.2b1-py3-none-any.whl.

File metadata

  • Download URL: ssalib-0.1.2b1-py3-none-any.whl
  • Upload date:
  • Size: 83.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for ssalib-0.1.2b1-py3-none-any.whl
Algorithm Hash digest
SHA256 79b6e9cde016af9d1944cc2d5f7b4dd06e854e461c7aa736750178f493290ad8
MD5 50fc090061d2da4ac5e7d6017cbdef5c
BLAKE2b-256 26c426726804970e65740083fdbf381ea2ed3fc708d940f1dc0802cc8a1370a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page