#' @title BMI585 final project: including accuracy
#' @description This functions accept two binary numerical arrays
#' @param pred: the prediction array
#' @param true: the true array
#' @return sen: accuracy
#' @examples
#' pred <- c(1,1,1)
#' true <- c(1,1,0)
#' accuracy(pred,true)
accuracy <- function(pred,true){
pred<-as.logical(pred)
true<-as.logical(true)
TP <- pred==true & true==1
TN <- pred==true & true==0
FP <- pred!=true & true==1
FN <- pred!=true & true==0
sen <- (sum(TN)+sum(TP))/(sum(true==0)+sum(true==1))
return(sen)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.