fdasrsf - Functional Data Analysis using SRVF Framework

raw JSON →
2.6.9 verified Fri May 01 auth: no python

A Python library for functional data analysis (FDA) using the Square Root Slope Framework (SRSF). It provides elastic registration, alignment, principal component analysis, and classification of functional data. Current version 2.6.9, with regular releases.

pip install fdasrsf
error ModuleNotFoundError: No module named 'fdasrsf'
cause The package is not installed or installed in a different Python environment.
fix
Run pip install fdasrsf in the correct environment (Python >=3.10).
error AttributeError: module 'fdasrsf' has no attribute 'align_fPCA'
cause In version 2.x, submodules are not automatically imported. `fdasrsf` no longer has top-level functions.
fix
Use from fdasrsf.time_warping import align_fPCA or import fdasrsf.time_warping then fdasrsf.time_warping.align_fPCA().
breaking In version 2.x, the `fdasrsf` package moved from `fdasrsf` (no subpackage) to a structure with submodules. Old code using `from fdasrsf import align_fPCA` no longer works.
fix Use `from fdasrsf.time_warping import align_fPCA` instead.
deprecated The function `fdasrsf.fdaclassification.classification()` was deprecated in favor of `fdasrsf.classification.classify()`.
fix Replace `fdasrsf.fdaclassification.classification` with `fdasrsf.classification.classify`
gotcha The input data is expected as a 2D array of shape (N, M) where N=number of functions, M=number of time points. Many users pass (M, N) and get bizarre results.
fix Ensure your data matrix is (N, M), not (M, N). Transpose with `.T` if needed.

Basic example of aligning functional data using fdasrsf.

import fdasrsf
import numpy as np

# Generate example functional data: 10 time series of 100 points
N, M = 10, 100
t = np.linspace(0, 1, M)
f = np.random.randn(N, M)

# Align functions using elastic registration
# Note: The main alignment function is `elastic_regression`, but for alignment use `time_warping`.
aligned = fdasrsf.time_warping.align_fPCA(f, t)
print(aligned['fPCA'])