Closed zzstefan closed 5 years ago
Hi,
When given two matrixes (say, A and B), corrcoef
regards A and B as two random variables and returns correlation between A and B. So, corrcoef(A, B)
is equivalent to corrcoef(A(:), B(:))
, and returns 2-by-2 matrix in which (1, 2) and (2, 1) are correlation coefficient between A and B.
On the other hand, factcorr
returns column-wise correlation; each column in A
and B
is regarded as a single random variables. That is, factcorr(A, B)
resutrns M-by-N matrix (where M = size(A, 2)
, N = size(B, 2)
), and (i, j) element in the returned matrix is correlation coefficient between A(:, i) and B(:, j).
So, nanmean(diag(fastcorr(predPercept, testFeat)))
takes correlation between predicted and true features for each unit and averages the correlation across all units, not just taking the correlation between predPercept(:) and testFeat(:).
Hi, recently I have been doing similar analysis on my own dataset. I wonder the difference between these two lines of code:
predAcc.image.perception = nanmean(diag(fastcorr(predPercept, testFeat))) predAcc.image.perception = corrcoef(predPercept, testFeat)
By using corrcoef, the prediction accuracy on my data can achieve much better results than using fastcorr.