R/true_negative.R

Defines functions true_negative

Documented in true_negative

#################
# True Negative #
#################

# nikita.gusarov@univ-grenoble-alpes.fr - April 2022

#' @title True Negative
#' @description Count True Negatives using confusion matrix.
#'
#' @param confusion_matrix Confusion matrix to be used.
#'
#' @return vector of True Negatives count
#'
#' @export
#'
#'

true_negative <- function(confusion_matrix) {
  # Compute True Negative
  TN <- sapply(
    seq(nrow(confusion_matrix)),
    function(i) {
      sum(confusion_matrix[-i, -i])
    }
  )

  # Conserve naming convention
  names(TN) <- colnames(confusion_matrix)

  # Output
  return(TN)
}
nikitagusarov/performancer documentation built on Jan. 12, 2023, 12:19 a.m.