View Single Post
  #1  
Old 09-14-2012, 11:23 AM
MLearning MLearning is offline
Senior Member
 
Join Date: Jul 2012
Posts: 56
Default Question 13 - RBF with hard mrgin unable to accurately classifiy

I am having difficulty getting SVM with RBF to accurately classify a linearly separable data. I included herein a piece of my code.

N = 100; gamma = 1.5;

X = 2*rand(2,N)-1; %Training data
fx=sign(X(2,-X(1, + 0.25*sin(pi*X(1,));

%Generate Kx(xn,xm)
for n=1:N
for m=1:N
Kx(n,m)=exp(-gamma*(norm(X(:,n)-X(:,m))).^2);
end
end

Q=(fx*fx').*Kx; %Q Matrix
... %other input parameters are similarly defined

alpha0=zeros(N,1)% This initialization has no effect

alphan = quadprog(Q,q,[],[],Aeq,beq,lb,ub,alpha0,optimset('maxiter',10000,'la rgescale','off'));

wsvm=((alphan.*fx')'*Kx')';

The problem is that all values of alphan are very small (e.g., max(alphan) = 0.0072 in one of the runs). Due to this, gx is either always equal to 1 -1.

Can anyone point out where the error lies in the above piece of code? I really appreciate it.
Reply With Quote