mercredi 10 février 2016

testing performance classifier matlab

Hello I have trained a classifier in matlab and I would like to test its accuracy. I have found a lot of functions to do that and I am puzzling on what to use...

at the moment:

% train my classifier
svmStruct = fitcsvm(Xtrain,Ytrain,'KernelFunction','linear','Standardize',true);

% predict the output of an unknown input <- this part takes a lot of time
IDX_svm = zeros(size(Xtest,1),1);
for j = 1 : size(Xtest,1)    
    IDX_svm(j) = predict(svmStruct,Xtest(j,:));    
end

%compute performaces
TABLE = confusionmat(Ytest,IDX_svm);
sum_diag = 0;
for j = 1 : size(TABLE,2)
    sum_diag = sum_diag + TABLE(j,j);
end
error_rate = 1-(sum_diag/sum(sum(TABLE,2)));

Aucun commentaire:

Enregistrer un commentaire