Skip to content

Instantly share code, notes, and snippets.

@limzunyuan
Created January 2, 2016 17:53
Show Gist options
  • Save limzunyuan/a12edbccc1f8a14269dd to your computer and use it in GitHub Desktop.
Save limzunyuan/a12edbccc1f8a14269dd to your computer and use it in GitHub Desktop.
function [ matrix ] = confusion_matrix(size, predicted, actual)
%CONFUSION_MATRIX Generates general confusion matrix
% User inputs size of expected matrix, get length of vector input
% For length of vector input, increment value of matrix with coordinates
% corresponding to value in vector row.
len = length(actual);
matrix = zeros(size);
predicted;
for n = 1:len
x = actual(n, :) + 1 ;
y = (predicted(:, n) >= 0.99) + 1;
matrix(x, y) = matrix(x, y) + 1;
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment