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??
accuracy Classification LibSVM Matlab
5 次查看(过去 30 天)
显示 更早的评论
I have a question about a accuracy of classification, using SVM with libsvm library.
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');
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File 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!