R/fourStats.R

#' nnet with cutoff as additional tuning parameter
#' @author Max Kuhn 
#' @description is used as internal function in caret's rfe and train
#' @references http://caret.r-forge.r-project.org/custom_models.html
#' @export fourStats

fourStats <- function (data, lev = levels(data$obs), model = NULL) {
  ## This code will get use the area under the ROC curve and the
  ## sensitivity and specificity values using the current candidate
  ## value of the probability threshold.
  out <- c(twoClassSummary(data, lev = levels(data$obs), model = NULL))
  
  ## The best possible model has sensitivity of 1 and specificity of 1. 
  ## How far are we from that value?
  coords <- matrix(c(1, 1, out["Spec"], out["Sens"]),
                   ncol = 2,
                   byrow = TRUE)
  colnames(coords) <- c("Spec", "Sens")
  rownames(coords) <- c("Best", "Current")
  c(out, Dist = dist(coords)[1])
}
environmentalinformatics-marburg/Rainfall documentation built on May 16, 2019, 7:49 a.m.