![]() |
#1
|
|||
|
|||
![]()
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, ![]() ![]() ![]() %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. |
![]() |
Thread Tools | |
Display Modes | |
|
|