Is it s defect that the fitcsvm() function picked some "far away" points as the support vectors?

조회 수: 1 (최근 30일)
Hi,
I used fitcsvm() to run SVM on some data with Gaussian kernel.
The yellow circled points are the support vector.
However, some points at the bottom shouldn't be support vectors, as they are far away from the decision boundary.
Therefore picking them as support vectors is not reasonable.
I wonder if they are mistakenly picked by the algorithm? Is that a defect?
The data.mat file is as attached.
Thanks.
Code
clear;
close all;
load('data','feature','label');
X = feature;
Y = label;
%% Computation
SVMModel = fitcsvm(X,Y,'ClassNames',[false true],'Standardize',true,...
'KernelFunction','rbf','BoxConstraint',1);
margin = 1;
x_start=min(X(:,1)) - margin;
x_end=max(X(:,1)) + margin;
y_start=min(X(:,2)) - margin;
y_end=max(X(:,2)) + margin;
d = 0.02;
[x1Grid,x2Grid] = meshgrid(x_start:d:x_end,...
y_start:d:y_end);
xGrid = [x1Grid(:),x2Grid(:)];
N = size(xGrid,1);
Scores = zeros(N,2);
[~,score] = predict(SVMModel,xGrid);
[~,maxScore] = max(score,[],2);
%% Plot Graph
figure
gscatter(xGrid(:,1),xGrid(:,2),maxScore, [0.5 0.1 0.5; 0.1 0.5 0.5]);
hold on
gscatter(X(:,1),X(:,2),Y);
title('{\bf SVM}');
xlabel('x_1');
ylabel('x_2');
axis tight
svInd = SVMModel.IsSupportVector;
plot(X(svInd,1),X(svInd,2),'yo','MarkerSize',10)
hold off

답변 (1개)

Rajani Mishra
Rajani Mishra 2020년 4월 16일
To understand how well or bad svm classification is performing calculate loss error, you can use loss function for the same. Refer to this link for learning about it.
Also you can try to optimize result of svm classifier. Refer to this link for more information : https://www.mathworks.com/help/stats/optimize-an-svm-classifier-fit-using-bayesian-optimization.html
Hope this helps!

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by