can you please explain the logic of this code
1 view (last 30 days)
Show older comments
function alphaKrow = mkpca(data,sigma,numev) % ----------------------------------------------------------------------- % global K
[n, d] = size(data); % n : number of data points % d : dimension of data points sigma = 2.5; % kernel matrix: K = zeros(n,n);
% kernel parameter: param = 0.5/(sigma*sigma);
% fprintf('computing kernel matrix K\n'); for i=1:n for j=i:n K(i,j) = kernel(data(i,:),data(j,:),param); K(j,i) = K(i,j); end end
% correct K for non-zero center of data in feature space: Krow = sum(K,1)/n; Ksum = sum(Krow)/n;
for i=1:n for j=1:n K(i,j) = K(i,j) - Krow(i) - Krow(j) + Ksum; end end
opts.disp = 0; [alpha,lambda] = eigs(K);
% normalize alpha: alpha = alpha * inv(sqrt(lambda));
% compute some helper vectors: alphaKrow = Krow * alpha; K = imresize(K,[256,256]); % ----------------------------------------------------------------------- % function k = kernel(x,y,param) % ----------------------------------------------------------------------- % diff = x-y; k = exp(-(diff * diff')*param);
0 Comments
Answers (0)
See Also
Categories
Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!