How to plot my 4 classes samples to visualize each classes's representing dot?

조회 수: 2 (최근 30일)
Alex Brown
Alex Brown 2017년 6월 30일
댓글: Rena Berman 2017년 7월 18일
I created a features vector of more than 100 elements,then used my multiclass SVM code to classify my 106samples(91 trained,105 tested) and ended up with a classification for each of those 15 samples.Now i want to plot them in a similar way to the attached image.
%%SVM Multiclass Example
% SVM is inherently one vs one classification.
% This is an example of how to implement multiclassification using the
% one vs all approach.
TrainingSet=\[ 1 10;2 20;3 30;4 40;5 50;6 66;3 30;4.1 42;56 4;34 1\];
TestSet=\[3 34; 1 14; 2.2 25; 6.2 63\];
GroupTrain=\[1 1 2 2 2 2 3 3 4 4\];
results = multisvm(TrainingSet, GroupTrain, TestSet);
disp('multi class problem');
disp(results);
multisvm code:
numClasses=length(u);
result = zeros(length(TestSet(:,1)),1);
%build models
for k=1:numClasses
%Vectorized statement that binarizes Group
%where 1 is the current class and 0 is all other classes
G1vAll=(GroupTrain==u(k));
models(k) = svmtrain(TrainingSet,G1vAll);
end
%classify test cases
for j=1:size(TestSet,1)
for k=1:numClasses
if(svmclassify(models(k),TestSet(j,:)))
break;
end
end
result(j) = k;
end

답변 (1개)

Image Analyst
Image Analyst 2017년 6월 30일
If you know what class each point was assigned to, then you can use gscatter() to plot each point/spot in a different color.
  댓글 수: 1
Image Analyst
Image Analyst 2017년 6월 30일
It would be best to try with your data, but I don't have the multisvm function. Can you upload it along with your data. The number of points in your code doesn't match your picture.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Discriminant Analysis에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by