forked from alok-ai-lab/DeepInsightTab2Image
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel.m
More file actions
28 lines (22 loc) · 740 Bytes
/
Copy pathkernel.m
File metadata and controls
28 lines (22 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
% X: data matrix, each row is one observation, each column is one feature
% type: type of kernel, can be 'simple', 'poly', or 'gaussian'
% para: parameter for computing the 'poly' kernel, for 'simple'
% and 'gaussian' it will be ignored
% K: kernel matrix
% Copyright by Quan Wang, 2011/05/10
% Please cite: Quan Wang. Kernel Principal Component Analysis and its
% Applications in Face Recognition and Active Shape Models.
% arXiv:1207.3538 [cs.CV], 2012.
function K=kernel(X,type,para)
N=size(X,1);
if strcmp(type,'simple')
K=X*X';
end
if strcmp(type,'poly')
K=X*X'+1;
K=K.^para;
end
if strcmp(type,'gaussian')
K=distanceMatrix(X).^2;
K=exp(-K./(2*para.^2));
end