📄 pcaerr.m
字号:
function [err, minerr, evals] = pcaerr(A, W)
% PCAERR Compute the average reconstruction error for a PCA matrix.
%
% [err, minerr] = pcaerr(A, W)
% A is the data matrix where each column is a data point
% W is the eigenvector matrix, each column is an eigenvector
% err is the average reconstruction error
% minerr is the minimum reconstruction error (from SVD)
%
% David Gleich
% CS 152 - Neural Networks
% 12 December 2003
%
err = mean(sum((A - W*(W'*A)).^2));
if (nargout > 1)
C = cov(A');
[V D] = eig(C);
k = size(W,2);
evals = -sort(-diag(D));
minerr = sum(evals(k+1:end));
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -