accuracy Classification LibSVM Matlab

조회 수: 5 (최근 30일)
arnaud ensberg
arnaud ensberg 2016년 3월 8일
답변: med djo 2017년 1월 17일
I have a question about a accuracy of classification, using SVM with libsvm library.
I have two set of data Data set
whan i draw it the tow set are clearly linearly separable
, but i dont know why I Obtain juste 50% of accuracy usign libsvm this is a code
mouv=[mouv1;mouv2];
TailAppr=fix((80*size(mouv,1))/100);
%--Classification--------
shuffledArray = mouv(randperm(size(mouv,1)),:);
dirData='C:\ProjetBCodesMatlab\libsvm-3.20\libsvm-3.20';
M=shuffledArray;
delete('C:\ProjetBCodesMatlab\libsvm-3.20\libsvm-3.20\filAB20.train');
csvwrite('C:\ProjetBCodesMatlab\libsvm-3.20\libsvm-3.20\filAB20.train',M);
SPECTF = csvread('C:\ProjetBCodesMatlab\libsvm-3.20\libsvm-3.20\filAB20.train');
labels = SPECTF(:, 1);
%---------------------------------------------------------------------------------------------------------------------
features = SPECTF(:, 2:end);
features_sparse = sparse(features);
delete('C:\ProjetBCodesMatlab\libsvm-3.20\libsvm-3.20\SPECTF20.train')
libsvmwrite('C:\ProjetBCodesMatlab\libsvm-3.20\libsvm-3.20\SPECTF20.train', labels,features_sparse);
[heart_scale_label, heart_scale_inst] = libsvmread(fullfile(dirData,'SPECTF20.train'));
[N D] = size(heart_scale_inst);
trainIndex = zeros(N,1); trainIndex(1:TailAppr) = 1;
testIndex = zeros(N,1); testIndex(TailAppr+1:N) = 1;
trainData = heart_scale_inst(trainIndex==1,:);
trainLabel = heart_scale_label(trainIndex==1,:);
testData = heart_scale_inst(testIndex==1,:);
testLabel = heart_scale_label(testIndex==1,:);
%model = svmtrain(trainLabel, trainData, '-c 1 -g 0.07 -b 1');
model = svmtrain(trainLabel, trainData, '-c 1 -g 0.001 -b 1');
[predict_label, accuracy, prob_values] = svmpredict(testLabel, testData, model, '-b 1');

답변 (1개)

med djo
med djo 2017년 1월 17일
if you will be able to do this, it will give you the answer Sir .... Assuming that you have three different classes (1,2,3). The first class contains two samples, the second contain one, the third contain one. From each class, you will extract two values (Average and median) of the color (for example). It will give you that: classe 1: (15, 20) classe 1: (16, 21) classe 2: ( 18, 22) classe 3: (22, 24) . On matlab, we make a matrix (Matrix for learning), which contains two columns, four lines and which contain (15, 20; 16, 21;18, 22; 22, 24). And we made a matrix composed of a single column (label matrix), this matrix (1, 1, 2, 3). We execute learning SVM with SVMtrain from libSVM. The parameters I have given you as an example correspond to the RBF kernel. The gamma value, c (varies between 10 and 100,000). Can you execute this scenario in Matlab using LibSVM??

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by