MFPCA#
- class FDApy.preprocessing.MFPCA(n_components=2, univariate_expansions=None, method='covariance', weights=None, normalize=False)[source]#
Multivariate functional principal components analysis.
Linear dimensionality reduction of a multivariate functional dataset. The projection of the data in a lower dimensional space is performed using a diagonalization of the covariance operator of each univariate component or of the inner-product matrix of the data. It is assumed that the data have \(P\) components.
- Parameters:
n_components (int | float) – Number of components to keep. If n_components is an integer, n_components are kept. If 0 < n_components < 1, we select the number of components such that the amount of variance that needs to be explained is greater than the percentage specified by n_components.
univariate_expansions (List[Dict[str, object]] | None) – List of dictionaries characterizing the univariate expansion computed for each component.
method (str) – Method used to estimate the eigencomponents. If method == ‘covariance’, the estimation is based on an eigendecomposition of the covariance operator of each univariate components. If method == ‘inner-product’, the estimation is based on an eigendecomposition of the inner-product matrix.
weights (ndarray[Any, dtype[float64]] | None) – A vector of weights of length \(P\). If None, we set the weights to be equal to 1 for each component.
normalize (bool) – Perform a normalization of the data.
- Attributes:
mean (MultivariateFunctionalData) – An estimation of the mean of the training data.
covariance (MultivariateFunctionalData) – An estimation of the covariance of the training data based on their eigendecomposition using the Mercer’s theorem.
eigenvalues (npt.NDArray[np.float64], shape=(n_components,)) – The singular values corresponding to each of selected components.
eigenfunctions (MultivariateFunctionalData) – Principal axes in feature space, representing the directions of maximum variances in the data as a MultivariateFunctionalData.
References
Methods
fit(data[, points, method_smoothing])Estimate the eigencomponents of the data.
inverse_transform(scores)Transform the data back to its original space.
transform([data, method, method_smoothing])Apply dimensionality reduction to the data.
- fit(data, points=None, method_smoothing=None, **kwargs)[source]#
Estimate the eigencomponents of the data.
Before estimating the eigencomponents, the data is centered. Using the covariance operator, the estimation is based on [2]. Using the Gram matrix, the estimation is based on [1].
- Parameters:
data (MultivariateFunctionalData) – Training data used to estimate the eigencomponents.
points (List[DenseArgvals] | None) – The sampling points at which the covariance and the eigenfunctions will be estimated.
method_smoothing (str | None) – Should the mean and covariance be smoothed?
kwargs – Other keyword arguments are passed to the functions:
FunctionalData.mean(),FunctionalData.center()andpreprocessing.dim_reduction.mfpca._fit_inner_product_multivariate().
- Return type:
None
- inverse_transform(scores)[source]#
Transform the data back to its original space.
Given a set of scores \(c_{ik}\), we reconstruct the observations using a truncation of the Karhunen-Loève expansion,
\[X_{i}(t) = \mu(t) + \sum_{k = 1}^K c_{ik}\phi_k(t).\]Data can be multidimensional. Recall that, here, \(X_{i}\), \(\mu\) and \(\phi_k\) are \(P\)-dimensional functions.
- transform(data=None, method='NumInt', method_smoothing='LP', **kwargs)[source]#
Apply dimensionality reduction to the data.
The functional principal components scores are defined as the projection of the observation \(X_i\) on the eigenfunction \(\phi_k\). These scores are given by:
\[c_{ik} = \sum_{p = 1}^P \int_{\mathcal{T}_p} \{X_i^{(p)}(t) - \mu^{(p)}(t)\}\phi_k^{(p)}(t)dt.\]This integral can be estimated using numerical integration. If the eigenfunctions have been estimated using the inner-product matrix, the scores can also be estimated using the formula
\[c_{ik} = \sqrt{l_k}v_{ik},\]where \(l_k\) and \(v_{k}\) are the eigenvalues and eigenvectors of the inner-product matrix.
- Parameters:
data (MultivariateFunctionalData | None) – Data
method (str) – Method used to estimate the scores. If
method == 'NumInt', numerical integration method is performed. Ifmethod == 'InnPro', the estimation is performed using the inner product matrix of the data (can only be used if the eigencomponents have been estimated using the inner-product matrix.)method_smoothing (str) – Method to smooth the data before estimating the scores.
kwargs – Other keyword arguments are passed to the function:
FunctionalData.center().
- Returns:
An array representing the projection of the data onto the basis of functions defined by the eigenfunctions.
- Return type:
npt.NDArray[np.float64], shape=(n_obs, n_components)
Notes
Concerning the estimation of the scores using numerical integration, we directly estimate the scores using the projection of the data onto the multivariate eigenfunctions and not use the univariate components and the decomposition of the covariance of the univariate scores as Happ and Greven [2] could do.