R/calcAUC.R

Defines functions calcAUC

Documented in calcAUC

#' @title Aire Under the Curve
#' @author Melody Premaillon
#'
#' @description Compute AUC for train (and) validation set
#' @param df_postprobfreq Post prob frequency data frame (from build_df_postprobfreq function)
#'
#' @return A data frame with two AUC (on train and validation set)
#' @importFrom  DescTools AUC
#' @export
#'

calcAUC <- function(df_postprobfreq){
  trainAUC <- round(AUC(df_postprobfreq$count_cum_prct, df_postprobfreq$trng_cum_prct)/10000, 3)

  valAUC <- if("val_cum_prct" %in% colnames(df_postprobfreq)){
    round(AUC(df_postprobfreq$count_cum_prct, df_postprobfreq$val_cum_prct)/10000, 3)
  }else{
    NA
  }

  myAUCs <- data.frame(trainAUC, valAUC)
  colnames(myAUCs) <- c("training", "validation")
  return(myAUCs)
}
MelodyPremaillon/valwoe documentation built on April 16, 2022, 12:46 a.m.