% accuracy.m
%
% calculating the accuracy of prediction
% conf_matrix is a matrix with element conf_matrix(i,j) showing
% how many examples from class 'i' were predicted to be of class 'j'

function [acc, conf_matrix] = accuracy(prediction,true)

u = unique(true);
for i=1:length(u)
   for j=1:length(u)
      conf_matrix(i,j) = length(find(prediction == u(j) & true == u(i)));
   end
end
acc=sum(diag(conf_matrix))/length(true);

return