📄 kisomap_test.m
字号:
function [TestY, TestD] = kisomap_test(TestX, TrainX, U, BK0, D, K, BMLam);
% [TestY, TestD] = kisomap_test(TestX, TrainX, U, BK0, D, K);
%
% INPUT
% TestX: Test Data
% TrainX: Train Data which was used for Training...
% U: EigenVector of Kernel Matrix
% BK0: Gram matrix of Training Data in Feature space.
% D: Euclidean Distance
% K: the number of neighborhood
%
% OUTPUT
% TestY: Projected Data
% TestD: Euclidean Distance between Training Data and Test Data
%
% This code uses some functions of Tenenbaum's Isomap code
%
% For the details, See
% H. Choi, S. Choi, "Kernel Isomap," Electronics Letters, vol. 40, no. 25, pp. 1612-1613, 2004
%
% 2004.06.04
% by hychoi@postech.ac.kr, http://home.postech.ac.kr/~hychoi/
% Heeyoul Choi
% Dept. of Computer Science
% POSTECH, Korea
TrainN = size(TrainX, 2);
TestN = size(TestX, 2);
% Neighborhood...
TestD = zeros(TestN, TrainN);
for idx = 1:TestN
ND = L2_distance(TestX(:,idx), TrainX, 1);
[tmp, ind] = sort(ND);
ND(1,ind(1, (2+K):end)) = 0;
ND = [D ND'; ND 0];
ND = sparse(ND);
ND = max(ND,ND');
TD = dijkstra(ND, TrainN+1); % Shortest Path....
TestD(idx,:) = TD(1, 1:TrainN);
end
TestD = TestD + BMLam;
% Kernel Trick...
diagB = diag(BK0)';
K0 = -.5*(TestD.^2 - repmat(diagB, TestN, 1) - repmat(sum(TestD.^2, 2)/TrainN, 1, TrainN) ...
+ sum(diagB)/TrainN);
%% Centering is meaningless
% K0 = K0 - ones(TestN, TrainN)/TrainN * BK0 - K0 * ones(TrainN, TrainN)/TrainN ...
% + ones(TestN, TrainN)/TrainN * BK0 * ones(TrainN, TrainN)/TrainN;
TestY = (K0*U)';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -