我想libsvmtrain_ova
在这个链接中绘制结果:
10 fold cross-validation in one-against-all SVM (using LibSVM)
,我在里面使用了这段代码,libsvmtrain_ova
但我认为它不能正常工作。
hold off
figure();
for j=1:numLabels
w = models{j}.SVs' * models {j}.sv_coef;
b = -models{j}.rho;
c1 = find(double(labels==1) == 1);
c2= find(double(labels==2) == 1);
c3=find(double(labels==3) == 1);
plot(X(c1,1), X(c1,2), 'ko', 'MarkerFaceColor', 'b'); hold on;
plot(X(c2,1), X(c2,2), 'ko', 'MarkerFaceColor', 'g');hold on;
plot(X(c3,1), X(c3,2), 'ko', 'MarkerFaceColor', 'r')
% Plot the decision boundary
plot_x = linspace(min(X(:,1)), max(X(:,1)), 30);
plot_y = (-1/w(2))*(w(1)*plot_x + b);
plot(plot_x, plot_y, 'k-', 'LineWidth', 2)
end
title(sprintf('SVM Linear Classifier with C = %g', 1), 'FontSize', 12)