scikit-fda
raw JSON → 0.10.1 verified Fri May 01 auth: no python
scikit-fda is a Python package for functional data analysis (FDA). Version 0.10.1 requires Python >=3.10. It provides tools for representation, preprocessing, and statistical analysis of functional data, following scikit-learn like API. Releases are irregular, roughly 1-2 per year.
pip install scikit-fda Common errors
error ModuleNotFoundError: No module named 'skfda.representation' ↓
cause Incorrect import path; in older docs, some examples use deep nested paths that no longer exist.
fix
Use the new top-level imports:
from skfda import FDataGrid instead of from skfda.representation.grid import FDataGrid. error ValueError: Data must be 2D array with shape (n_samples, n_points) or (n_samples, n_points, n_dimensions) ↓
cause Data passed to FDataGrid has wrong shape (e.g., transposed).
fix
Reshape data to (n_samples, n_points). For multivariate functional data, shape should be (n_samples, n_points, n_dimensions).
error AttributeError: 'FData' object has no attribute 'regularize' ↓
cause The `regularize` method was removed in newer versions (>=0.9).
fix
Use
least_squares_warping from skfda.preprocessing.registration instead. Warnings
breaking In version 0.9, the top-level imports were reorganized. Importing from `skfda.representation.grid` or `skfda.representation.basis` directly is deprecated. Use `from skfda import FDataGrid` and `from skfda.representation.basis import FDataBasis`. ↓
fix Update imports to the new paths as shown in the docs.
deprecated The `regularize` function from `skfda.preprocessing.registration` was deprecated in 0.9. Use `least_squares_warping` instead. ↓
fix Replace `regularize` calls with `least_squares_warping` from the same module.
gotcha FDataGrid expects data_matrix of shape (n_samples, n_points) by default, not (n_points, n_samples). Common mistake: transposed data leads to weird errors. ↓
fix Ensure data_matrix has shape (n_samples, n_points) or specify `sample_points` argument accordingly.
gotcha When using basis expansion (e.g., `FDataBasis`), the coefficients array shape must match the basis. Dimensions mismatch leads to obscure NumPy errors. ↓
fix Check that the shape of coefficients is (n_samples, n_basis) for unidimensional basis.
Install
pip install scikit-fda[plot] Imports
- FDataGrid wrong
from skfda.representation import FDataGridcorrectfrom skfda import FDataGrid - FPCA
from skfda.preprocessing.dim_reduction import FPCA - regularize wrong
from skfda.registration import regularizecorrectfrom skfda.preprocessing.registration import least_squares_warping
Quickstart
import numpy as np
from skfda import FDataGrid
from skfda.preprocessing.dim_reduction import FPCA
# Generate functional data: 10 curves, each with 50 points
t = np.linspace(0, 1, 50)
data_matrix = np.random.randn(10, 50) # 10 samples, 50 time points
fd = FDataGrid(data_matrix, grid_points=t)
# Perform FPCA
fpca = FPCA(n_components=3)
fpca.fit(fd)
scores = fpca.transform(fd)
print(scores.shape)