True Negative can not detect when do clasiffication with libsvm

Hello , I had the probelm with libsvm. I've tried to solve this problem more than 2 weeks but I can not solve it . I hope someone can help my problem.
My problem is.
I run libsvm in matlab with 40 FP and 13 TN. I want to classify become cancer and no cancer. When I try with this data using svm classification, I got 90.57% . with the confusion matrix: 13 5 0 35 and when I tried with libsvm, it gives an strange output. it gives 79.49% but it can not detect True negative. I used 5-cross validation . this is the confusion matrix that i got.
cmTest 1 ==== cmTest2 ====cmTest 3====cmTest4 ====cmTest5 =
0 3 0 3 0 3 0 2 0 2
0 10 0 10 0 10 0 10 0 10
I dont know why the true negatif is 0. when I tried with data testing=data training, it gives 100%. and also when I tried with dataset from libsvm, it's working well. I can not find the problem until now. this is I put my main data train function.
[labels,data]=training('D:\classification\fp\',...
'D:\th\tp\');
opts = '-s 0 -t 2 -c 0.0313 -g 3.0518e-05'; %# libsvm training options
nfold=5;
indices = crossvalind('Kfold', labels, nfold);
acc = zeros(nfold,1);
for i=1:nfold
testIdx = (indices == i); trainIdx = ~testIdx;
trainLabel = labels(trainIdx);
trainData = data(trainIdx,:);
testData=data(testIdx,:);
testLabel=labels(testIdx);
model = svmtrain(trainLabel, trainData, opts);
[predTestLabel, acc, decVals] = svmpredict(testLabel, testData, model);
acc = mean(predTestLabel == testLabel)
cmTest = confusionmat(testLabel,predTestLabel)
akurasi(i) = sum(predTestLabel == testLabel) ./ numel(testLabel)
end
result_accuracy=mean(akurasi)
and this is my train function:
function [C,F ] = training(fpDir,tpDir)
db=dir(fullfile(fpDir,'*.dcm'));
F=[];
%C=zeros(numel(db),1);
C=[]
for ii= 1:numel(db)
name=fullfile(fpDir, db(ii).name);
im1=dicomread(name);
F = [F; func_feature1(im1)];
C = [C;1];
db=dir(fullfile(tpDir,'*.dcm'));
for ii = 1:numel(db)
im1=dicomread(fullfile(tpDir, db(ii).name));
F = [F; func_feature1(im1)];
C = [C;0];
end
end
is there something wrong with my code ? can someone help me to correct this code. Thank you ..

Réponses (0)

Catégories

En savoir plus sur Biotech and Pharmaceutical dans Centre d'aide et File Exchange

Question posée :

bek
le 4 Avr 2013

Community Treasure Hunt

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

Start Hunting!

Translated by