Talk:Statistics package

From Octave
Revision as of 04:04, 14 November 2014 by 88.192.249.152 (talk) (confusionmat)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Hi, here you have my implementation of the confusionmat function. I hope it helps someone

function [ret] = confusionmat(v1, v2)

  values = union(unique(v1), unique(v2));
  ret = zeros(size(values), size(values));
  for i = 1:size(v1)
     i1 = find(values == v1(i));
     i2 = find(values == v2(i));
     ret(i1, i2) = ret(i1, i2) + 1;
  end

endfunction