Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multivariate FPCA not working #598

Open
aa89113 opened this issue Feb 16, 2024 · 1 comment
Open

Multivariate FPCA not working #598

aa89113 opened this issue Feb 16, 2024 · 1 comment
Labels

Comments

@aa89113
Copy link

aa89113 commented Feb 16, 2024

Bug description summary

FPCA does not seem to work when working with multivariate functional data.

Code to reproduce the bug

import numpy as np
import skfda
from skfda.preprocessing.dim_reduction import FPCA

data_matrix = np.random.rand(20, 50, 4)
grid_points = np.sort(np.random.rand(50))
fdata = skfda.FDataGrid(grid_points=grid_points, data_matrix=data_matrix)

fpca = FPCA(n_components=2)
fdata_fpca = fpca.fit_transform(fdata)

Expected result

No error raised

Actual result

ValueError: cannot reshape array of size 4000 into shape (20,50)

Traceback (if an exception is raised)

328 raise AttributeError(
329 "The number of components should be "
330 "smaller than the number of discretization "
331 "points of the functional data object.",
332 )
334 # data matrix initialization
--> 335 fd_data = X.data_matrix.reshape(X.data_matrix.shape[:-1])
337 # get the number of samples and the number of points of descretization
338 n_samples, n_points_discretization = fd_data.shape

ValueError: cannot reshape array of size 4000 into shape (20,50)

Software versions

skfda.version = '0.9'

Additional context

@aa89113 aa89113 added the bug label Feb 16, 2024
@vnmabus
Copy link
Member

vnmabus commented Feb 16, 2024

I think this is a duplicate of #537. Vector-valued functions are not supported yet for the FDataGrid case. You may try to convert them to FDataBasis using VectorValuedBasis and perform FPCA in basis representation instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants