Skip to main content

Easy Singular Spectrum Analysis (SSA) implementation for Python

Project description

ESSA - Easy Singular Spectrum Analysis

A Python package for Singular Spectrum Analysis (SSA) of time series data.

Installation

pip install essa

Features

  • Support for both full SVD and randomized SVD for large datasets
  • Support for Toeplitz SSA method for stationary series
  • Simple API for decomposition and reconstruction
  • Compatible with NumPy arrays

Usage Example

from essa import Decompose, reconstruct
import numpy as np
import matplotlib.pyplot as plt

# Generate synthetic data
t = np.linspace(0, 2*np.pi, 100)
series = np.sin(t) + 0.5*np.sin(3*t)

# Create decomposer with window size of 20
decomposer = Decompose(time_series=series, window_size=20)
decomposer.fit()  # Perform decomposition

# Reconstruct components
trend = reconstruct(decomposer, [[0]])[0]  # First component as trend
seasonal = reconstruct(decomposer, [[1, 2]])[0]  # 2nd and 3rd components as seasonality
noise = reconstruct(decomposer, [[3]])[0]  # 4th component as noise

# Plot results
plt.figure(figsize=(10, 6))
plt.plot(t, series, label='Original Series')
plt.plot(t, trend, label='Trend')
plt.plot(t, seasonal, label='Seasonality')
plt.plot(t, noise, label='Noise')
plt.legend()
plt.title('SSA Decomposition')
plt.xlabel('Time')
plt.ylabel('Value')
plt.show()

Toeplitz SSA Example

# For stationary time series, Toeplitz SSA may provide better results
decomposer = Decompose(time_series=series, window_size=20, method="toeplitz")
decomposer.fit()

# Reconstruct components
trend = reconstruct(decomposer, [[0]])[0]
seasonal = reconstruct(decomposer, [[1, 2, 3]])[0]
# ... rest of analysis

API Reference

Decompose Class

Decompose(time_series, window_size, method="basic", svd_method=None)

Parameters:

  • time_series (np.ndarray): The time series data to analyze
  • window_size (int): The embedding window length (L)
  • method (str): SSA method to use - 'basic' (default) or 'toeplitz'
  • svd_method (str): Only for basic method - 'full' for exact SVD or 'randomized' for approximate (default: 'full')

Methods:

  • fit(): Perform decomposition and store components

reconstruct Function

reconstruct(decomposer, groups)

Parameters:

  • decomposer: A fitted Decompose object
  • groups (List[List[int]]): List of component groups to reconstruct

Returns:

  • Array of reconstructed components for each group

License

MIT License

Citation

If you use this package in your research, please cite:

@software{essa2025,
  author = {Eugene Turov},
  title = {ESSA: Easy Singular Spectrum Analysis},
  year = {2025},
  url = {https://github.com/ProtonEvgeny/essa}
}

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

essa-0.3.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

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

essa-0.3-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file essa-0.3.tar.gz.

File metadata

  • Download URL: essa-0.3.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for essa-0.3.tar.gz
Algorithm Hash digest
SHA256 3c3e23433136ed62175fc16d0445cda9cb35ef93299eb5772bf881853fddefc0
MD5 14e1b72e43d5fad3fc047153f9f28aa3
BLAKE2b-256 9c23b9fd46dca7ea29810e68ed9afbaf2aaa092e2d6a8f505eae1e2986f4052d

See more details on using hashes here.

File details

Details for the file essa-0.3-py3-none-any.whl.

File metadata

  • Download URL: essa-0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for essa-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c3b76a3f3fbcc960e2610283f961d99360180292a6580ef2a25faa7ed580daaf
MD5 f625d5021245810c98bfc386978b7205
BLAKE2b-256 ee413462c28358ac92ece879169dc364dc772493e474c25dc3e5477be8d452a6

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