Last active
August 29, 2015 14:26
-
-
Save timvw/2745b143542cc28cc623 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 [accuracy, precision, recall, f1] = classify(X) | |
| % X is a matrix with the following data: | |
| % X(1,1) we predict that it is true, it is true - true positive | |
| % X(1,2) we predict that it is true, it is false - false positive | |
| % X(2,1) we predict that it is false, it is true - false negative | |
| % X(2,2) we predict that it is false, it is false - true negative | |
| accuracy = ( X(1,1) + X(2,2) ) / sum(sum(X)) | |
| precision = X(1,1) / ( X(1,1) + X(1,2) ) | |
| recall = X(1,1) / ( X(1,1) + X(2,1) ) | |
| f1 = (2 * precision * recall) / (precision + recall) | |
| % ============================================================ | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Calculate accuracy, precision, recall and f1 with Octave