Created
January 2, 2016 17:53
-
-
Save limzunyuan/a12edbccc1f8a14269dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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