Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
jpm-behavior/CalculateAcc.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
14 lines (14 sloc)
606 Bytes
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 [TP, TN, FN, FP] = CalculateAcc(ytest, yhat, theta, upper, lower) | |
% This function calculates the accuracy of the test set based on | |
% the thresholds provided | |
% Parameters: | |
% ytest: the test set vector | |
% yhat: the raw test set predictions | |
% theta: the threshold for classification | |
% upper: the positive value of the test set | |
% lower: the negative value of the test set | |
TP = sum(and(ytest==upper, yhat >= theta)); | |
FP = sum(and(ytest==lower, yhat >= theta)); | |
TN = sum(and(ytest==lower, yhat < theta)); | |
FN = sum(and(ytest==upper, yhat < theta)); | |
end |