FilippoMB / Time-series-classification-and-clustering-with-Reservoir-Computing

Library for implementing reservoir computing models (echo state networks) for multivariate time series classification and clustering.
https://reservoir-computing.readthedocs.io/en/latest/
MIT License
347 stars 83 forks source link

TensorPCA yields complex data type array which causes error in Ridge module #8

Open jagandecapri opened 3 years ago

jagandecapri commented 3 years ago

Hi @FilippoMB,

I noticed that for the dataset that I'm using, the result of tensorPCA yields a complex data type Numpy array. This in turn causes an error in the ridge module which says that it does not support complex data type. Specifically, error ValueError: Complex data not supported is generated at https://github.com/FilippoMB/Time-series-classification-and-clustering-with-Reservoir-Computing/blob/master/code/modules.py#L205

I don't face this issue when I use PCA with the same dataset.

I tried to print out the eigenvalue and eigenvector data type at https://github.com/FilippoMB/Time-series-classification-and-clustering-with-Reservoir-Computing/blob/master/code/tensorPCA.py#L33-L38 and both these vectors are of the data type, complex128, for the dataset I am using.

I tried Googling a bit and found some resources such as https://stackoverflow.com/questions/10420648/complex-eigen-values-in-pca-calculation and https://stackoverflow.com/questions/48695430/how-to-make-the-eigenvalues-and-eigenvectors-stay-real-instead-of-complex. From what I understood, due to some numerical error, the eigenvalues and eigenvectors can have a small imaginary value when linalg.eig is used. I'm not sure whether my understanding is correct.

Any thoughts on this?