Error in computing pca with nan values

9 visualizzazioni (ultimi 30 giorni)
eli karimi
eli karimi il 19 Ott 2019
Commentato: Christine Tobler il 28 Ott 2019
Hello,
I used pca. After computing the covariance matrix, I saw the NaN values in it. When I want to calculate the eigenvalues and eigenvectores, it gives an error.
Error using eig
Input matrix contains NaN or Inf.
Error in TrainData (line 113)
[V,LAMBDA]=eig(C);
Please guide me
thank you
  1 Commento
Christine Tobler
Christine Tobler il 28 Ott 2019
PCA is based on SVD or EIG, and these functions do not support NaN inputs. This is because there is no simple, unique way to ignore NaN values when computing these function.
Some ideas:
  • If each row or column of your input matrix represents an independent measurement, remove all rows (or columns) that contain any NaN values.
  • Set all NaN values to zero, or to the mean (or median) of all values in the matrix. Possibly, it would be better to set them to the mean of the row or column that they are in, if these each represent one type of measurement.
  • Take a look at the fillmissing function, perhaps one of the options there would be suitable for replacing the NaN values in your input data.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Dimensionality Reduction and Feature Extraction in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by