problem in plottin kernel svm inplementation
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
Hi,
I am implementing the Kernel SVM for a non-linear separable data set. I have implemented the algorithm for 4 points to see the results and then generalize for a larger data set. When I plot the results, I can see the surfaces separating the data sets but for a larger data set it does not give proper results, so I am not sure if I am plotting in the right way. Could someone please let me know how to plot the results.
Thanks in advance, Sharmi
I have added the Kernel SVM code below
% kernel function g = @(x,y) (x*y'+1).^2; X_data = cat(1,data_set(1:N1,1:2),-data_set(N1+1:N1+N2,1:2)); y = cat(1,data_set(1:N1,3),data_set(N1+1:N1+N2,3)); H = (y*y').*g(X_data,X_data); f=-ones(N1+N2,1); Aeq=y'; beq=0; lb=zeros(N1+N2,1); ub=C*ones(N1+N2,1); lambda=quadprog(H,f,[],[],Aeq,beq,lb,ub);
lambda(floor(10000*abs(lambda))==0)=0; s =g(X_data,X_data);
% weight vector w = g(data_set,data_set)*(y.*lambda); q=find(lambda>0 & lambda<C-.000001);
x_min=-1+floor(min(abs(g(data_set,data_set)))); x_max=1+ceil(max(abs(g(data_set,data_set)))); y_min=-1+floor(min(abs(data_set(:,2)))); y_max=1+ceil(max(abs(data_set(:,2))));
xi=x_min:x_max; for i=1:N1+N2 yi=(y.*lambda)*g(data_set(i,:),data_set); end
xi= xi(1:size(yi));
axis equal figure plot(xi,yi,'k') figure mesh(yi);
data_set is the 2D non-linearly separable random data set which is augmented for each class and normalized for the second class.
2 Kommentare
Shashank Prasanna
am 11 Mär. 2013
Could you shed more light on "does not give proper results"? Do you get an error message? What seems to be the issue?
rini
am 12 Mär. 2013
Antworten (0)
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!