tsdr: Time-Series Dimension Reduction
tsdr is a Python package of time-series dimension reduction (TSDR) methods: algorithms that reduce multivariate data to a few components by exploiting temporal structure. In contrast to general dimension reduction (GDR) methods, whose outputs are invariant to temporal permutation, TSDR methods are sensitive to temporal structure. The package implements 30 methods from the seven categories of TSDR methods defined in Owens & Fulcher (2025), written in a simple, readable style to help time-series analysts understand the algorithms discussed in that review.
Installation
pip install tsdr
The package is on PyPI and requires Python 3.8 or later.
It depends on numpy, scipy, scikit-learn, pywavelets and kneed.
The example below also uses matplotlib.
Quick start
Every method is a class with a scikit-learn-style fit and fit_transform, and all but four also have transform (see the exceptions below).
Here we extract a slow sinusoid from a linear mixture of noise channels using slow feature analysis (SFA):
from tsdr.slowness import SFA
import numpy as np
import scipy
import matplotlib.pyplot as plt
# create a dataset for analysis
# a sinusoid
z = np.sin(np.linspace(0, 4*np.pi, 1000))
# multichannel noise
D = 5
rng = np.random.default_rng(0)
noise = rng.normal(scale=1.0, size=((len(z), D-1)))
# linear mixing
A = scipy.stats.ortho_group.rvs(D, random_state=1)
X = np.concatenate([z.reshape(-1,1), noise], axis=1) @ A
# extract a slow component using SFA
slow_component = SFA(n_components=1).fit_transform(X)
# visualize the component
fig, axs = plt.subplots(6, 1, figsize=(8, 8))
axs[0].plot(slow_component, lw=1.0)
axs[0].set_ylabel('SFA1')
for i in range(D):
axs[i].spines[['right', 'top', 'bottom']].set_visible(False)
axs[i].set_xticks([])
axs[i+1].plot(X[:, i], c='black', linewidth=0.5)
axs[i+1].set_ylabel(f'X{i+1}')
axs[D].spines[['right', 'top']].set_visible(False)
axs[D].set_xlabel('Time')
plt.tight_layout()
Input requirements
Xis a 2-D array of shape(n_samples, n_features), with time along the rows: a NumPy array or a pandas DataFrame (which is converted to an array). A 1-D time series must be reshaped to one column, e.g.,x.reshape(-1, 1).Xmust not contain NaN or infinite values, which raise aValueError.- The methods that whiten the data need more time points than features (
n_samples > n_features) and a nonsingular covariance matrix, i.e., no constant or linearly dependent channels. n_componentsmust be between 1 andn_featuresfor most methods (some methods, such as the diffusion methods andDyCA, allow more).- The
transformof the linear methods applies the learned linear map toXwithout first subtracting the mean of the training data, so each component carries a constant offset. Subtract the column means of the output if you need zero-mean components.
Available methods
The methods are grouped by the aspect of temporal structure that they exploit.
Each is imported from the module named in the first column, e.g., from tsdr.slowness import SFA.
| Category | Module | Methods |
|---|---|---|
| (a) Slowness | tsdr.slowness |
SFA (slow feature analysis)BioSFA (biologically plausible SFA)ISFA (independent slow feature analysis)SICA (slow independent component analysis) |
| (b) Autocorrelation | tsdr.autocorrelation |
TICA (time-lagged independent component analysis)TMCA (time-lagged maximum covariance analysis)CSA (colored subspace analysis)TCCA (time-lagged canonical correlation analysis, in closed form)TCCA_Stiefel (trace-ratio optimization of the time-lagged covariance on the Stiefel manifold, which for whitened data gives the TICA subspace)sPCA_dwt (spectral PCA using the discrete wavelet transform) |
| (c) Predictability | tsdr.predictability |
TLPC (temporally local predictive coding)PrCA (predictable component analysis)DiCCA (dynamic inner canonical correlation analysis)ForeCA (forecastable component analysis)PFA (predictable feature analysis)PTS (principal time series)DCA (dynamical components analysis) |
| (d) Determinism | tsdr.determinism |
DyCA (dynamical component analysis)DMD (dynamic mode decomposition) |
| (e) Non-stationarity | tsdr.nonstationarity |
ASSA (analytic stationary subspace analysis)SSAsir (stationary subspace analysis via sliced inverse regression)SSAsave (stationary subspace analysis via sliced average variance estimation)SSAcor (stationary subspace analysis via time-lagged autocorrelation)WaSSAf (Wasserstein stationary subspace analysis using the Fréchet mean)WaSSAr (Wasserstein stationary subspace analysis using the root-Fréchet mean)BSSnonstat (blind source separation via non-stationarity of variances) |
| (f) Diffusion | tsdr.diffusion |
DMcov (diffusion maps using covariance distance)DIG (dynamical information geometry)NLSA (nonlinear Laplacian spectral analysis) |
| (g) Latent variable | tsdr.latentvariable |
LDS (latent linear dynamical system)DFA (dynamic factor analysis) |
The figure at the top summarizes these categories.
A few methods differ from the common pattern:
-
Methods with a random initialization or random order of updates (
BioSFA,ISFA,SICA,TCCA_Stiefel,ForeCA,DCA,BSSnonstat, andLDSandDFAwithinit='random') accept arandom_stateargument, which defaults to 0 so that results are reproducible (passrandom_state=Noneto use the global NumPy random state; the oldseedargument ofTCCA_Stiefelstill works but is deprecated).LDSandDFAare initialised deterministically by default (init='autocorrelation').BSSnonstatandDCArun their optimisation from several random initialisations (n_init, default 5) and keep the best solution, asForeCAdoes (n_starts). -
sPCA_dwtand the three diffusion methods return component time series of the fitted data rather than a linear map of the features, so they havefit_transformbut no out-of-sampletransform(sPCA_dwt.transformraisesNotImplementedError, and the diffusion methods have notransformmethod).DMcovandDIGembed sliding windows of the time series (of lengthwindow, everystepsamples), so they return one row per window;NLSAembeds the time series withqlags, so it returnsn_samples - qrows (for time pointsqonwards). -
The sign of a component is arbitrary for most methods (e.g., that of an eigenvector), so it is fixed by a convention: the entry of largest magnitude of each column of
linear_transform_(or, forsPCA_dwtand the diffusion methods, the value of largest magnitude of each component) is positive.DMDfixes the phase and sign of its (complex) components in its own way (see its docstring), and the signs of theLDSandDFAcomponents are not fixed.
Citation
If you use this software, please read and cite the open-access article:
Owens, K. S. & Fulcher, B. D. (2025). Time-series dimension reduction: a comprehensive review and conceptual unification of algorithms. TechRxiv. doi:10.36227/techrxiv.176409662.29359239/v1
@article{owens2025tsdr,
title = {Time-series dimension reduction: a comprehensive review and conceptual unification of algorithms},
author = {Owens, Kieran S. and Fulcher, Ben D.},
journal = {TechRxiv},
year = {2025},
doi = {10.36227/techrxiv.176409662.29359239/v1}
}
License
tsdr is released under the MIT License.
Metadata
Release files for tsdr 0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tsdr-0.11.tar.gz | 81.5 kB | Without provenance | Details for tsdr-0.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tsdr-0.11-py3-none-any.whl | Python 3 | none | any | Details for tsdr-0.11-py3-none-any.whl |
Total release size: 141.0 kB
Release files / tsdr-0.11.tar.gz
| Download URL | tsdr-0.11.tar.gz |
|---|---|
| Size | 81.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9ac9b011973a3e7427d3b8fd46aa7cea1f778103bf9ec7d37ed0d114dfd1890c
|
|
BLAKE2b-256 checksum How to use checksums |
e263d2675cfde6a78b4ce10abdd7224a44871e59abd5b64898ff8b69e1897f2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.7
|
Release files / tsdr-0.11-py3-none-any.whl
| Download URL | tsdr-0.11-py3-none-any.whl |
|---|---|
| Size | 59.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9d9694bfc5979bd300267607277e30b87b93f917ab7b7495837f26fb74045c50
|
|
BLAKE2b-256 checksum How to use checksums |
89078fffe12ed174fbeea550fac800a6366ae1155f96174386be6a8902cc1e58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.7
|
Security for tsdr 0.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.