-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprintConfusionAndMetrics.m
25 lines (23 loc) · 1.03 KB
/
printConfusionAndMetrics.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function [accuracy, precision, recall, f1score] = ...
printConfusionAndMetrics(predictLabels, trueLabels)
%PRINTCONFUSIONANDMETRICS return the mainly metrics from predict data
% of binary class. Also prints the consfusion Matrix and this metrics on
% the console.
%
% [accuracy, precision, recall, f1score] = printConfusionAndMetrics(predictLabels, trueLabels)
%
% PARAMETERS
% predictLabels - Labels array from the predict techinique
% trueLabels - Label arrays from the dataset with the right labels.
%
% RETURN
% accuracy - (truePositive + trueNegative) / N
% precision - truePositive / (truePositive + falsePositive)
% recall - truePositive / (truePositive + falseNegative)
% f1score - 2 * precision * recall / (precision + recall)
printConfusion(predictLabels, trueLabels);
[accuracy, precision, recall, f1score] = ...
getMetrics(predictLabels, trueLabels);
fprintf("Accuracy: %.4f\t Precision: %.4f\nRecall: %.4f\t\t F1Score: %.4f\n", ...
accuracy, precision, recall, f1score);
end