Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [cf_mat, total_error] = get_confusion_error(predictions, num_classes)
- actuals = [];
- if num_classes == 2
- actuals = [repmat(1,1,200) repmat(2,1,200)];
- else
- actuals = [repmat(1,1,100) repmat(2,1,200) repmat(3,1,150)];
- end
- cf_mat = repmat(0,num_classes,num_classes);
- for i = 1:length(actuals)
- cf_mat(actuals(i), predictions(i)) = cf_mat(actuals(i), predictions(i)) + 1;
- end
- total_error = sum(cf_mat, 'all');
- errors = [];
- for i = 1:length(cf_mat)
- errors = [errors, (sum(cf_mat(i, :))-cf_mat(i, i))/sum(cf_mat(i, :))];
- total_error = total_error - cf_mat(i,i);
- end
- total_error = total_error/sum(cf_mat, 'all');
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement