clc;
clear;
close all;
traindata = [1,0; 3,10; 2,2; 2,3; -1,-1; -6,-4; -4,-1; -1.5, -3];
group = [1 1 1 1 -1 -1 -1 -1]‘;
testdata = [ 1,2; 1,1; -1,-4;-2, -3];
svm_struct = svmtrain(traindata,group,‘Showplot‘,true); % training
Group = svmclassify(svm_struct,testdata,‘Showplot‘,true);
hold on;
plot(testdata(:,1),testdata(:,2),‘ro‘,‘MarkerSize‘,12); % testing
hold off
时间: 2024-11-03 01:23:21