{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

svm_out - %first of all obtain the size of training data...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
%% now we will produce a function that computes the output of the svm %% directly. that is w'*fi(x) + d. function [val] = svm_out(xtest,xtrain,bet,alph,d,sg,r) %xtrain: xtrain must be in this form. each column is a seperate training %data. it is assumed to be in this form. %xtest : xtest is also in the form of xtrain. that is columns are seperate %training datas. %alph : is assumed to be in column. %first we have to compute the kernel matrix. K is N by 1 in this case.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %first of all obtain the size of training data thus the kernel matrix [m,n] = size(xtrain); if(m>n) sizeK = m; else sizeK = n; end K=zeros(sizeK,1); for i = 1:sizeK K(i,1) = exp(- ((norm( xtrain(:,i) - xtest ))^2)/(2*sg^2) ); % Be carefull with the value of sg or sg^2 end val = bet*sum(K(:,1)) + alph'*K(r:end,1) + d; v...
View Full Document

{[ snackBarMessage ]}