function [ K H ] = KernelKreator( training, labels, scale, toggle)
[xm xn] = size(training);
[ym yn] = size(labels);
if xm ~= ym || toggle < 0
display('Sorry, this is an idiot proof function. Try feeding in valid parameters next time, doof!');
return;
end
K = zeros(xm, xm);
H = zeros(xm, xm);
iter = 0;
%build kernel based on toggle used
if toggle == 0 %use regular dot product
for i = 1:xm
for j = i:xm
K(i,j) = (defaultKernel(training(i, :), training(j, :), eye(xn))) / scale;
K(j, i) = K(i,j);
H(i,j) = (K(i,j) * labels(i) * labels(j));
H(j,i) = H(i,j);
iter = iter + 1;
end
end
%put other toggles here for other kernels
elseif toggle == 1
for i = 1:xm
for j = i:xm
K(i,j) = (defaultKernel(training(i, :), training(j, :), eye(xn))) / scale;
K(i,j) = (K(i,j) + 1)^2;
K(j, i) = K(i,j);
H(i,j) = (K(i,j) * labels(i) * labels(j));
H(j,i) = H(i,j);
end
end
elseif toggle == 2
for i = 1:xm
for j = i:xm
K(i,j) = (defaultKernel(training(i, :), training(j, :), eye(xn))) / scale;
K(i,j) = (K(i,j) + 1)^3;
K(j, i) = K(i,j);
H(i,j) = (K(i,j) * labels(i) * labels(j));
H(j,i) = H(i,j);
end
end
elseif toggle == 3
for i = 1:xm
for j = i:xm
K(i,j) = GaussKernel(training(i, :), training(j, :), scale);
K(j,i) = K(i,j);
H(i,j) = (K(i,j) * labels(i) * labels(j));
H(j,i) = H(i,j);
end
end
end
Friday Night Open Thread: Motivation
5 hours ago
No comments:
Post a Comment