Skip to content

Instantly share code, notes, and snippets.

@cseidman
Created January 24, 2018 14:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cseidman/6e498a51ee62195e4b42d7f72714b134 to your computer and use it in GitHub Desktop.
calculateperfmeasures.R
# Common classification performance measures
# Set the variables
tN <- cMx[1,1] # True negative
tP <- cMx[2,2] # True positive
fP <- cMx[2,1] # False positive
fN <- cMx[1,2] # False negative
pM.Accuracy <- round((tP + tN)/(tP + fP + tN + fN),2)
pM.Precision <- round(tP/(tP + fP),2)
pM.Recall <- round(tP/(tP + fN),2)
pM.Specificity <- round(tN/(tN + fP),2)
f1 <- round((2 * pM.Precision * pM.Recall)/(pM.Precision + pM.Recall),2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment