How to plot my 4 classes samples to visualize each classes's representing dot?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Réponses (1)
Image Analyst
le 30 Juin 2017
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 commentaire
Image Analyst
le 30 Juin 2017
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.
Voir également
Catégories
En savoir plus sur Discriminant Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!