Error in computing pca with nan values

조회 수: 12 (최근 30일)
eli karimi
eli karimi 2019년 10월 19일
댓글: Christine Tobler 2019년 10월 28일
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
Christine Tobler
Christine Tobler 2019년 10월 28일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by