R/mahadClassifier.R

Defines functions mahadClassifier

Documented in mahadClassifier

#' Implements the mahad classifier evaluation
#' 
#' Takes a dataframe as an argument and evaluates the performance of mahad
#' as a classifier for that dataset.
#' @author Richard D. Yentes \email{rdyentes@ncsu.edu}
#' @param x a dataframe on which to test the classifier
#' @export

mahadClassifier <- function(x, truth, cut=.5) {
  
  md <- careless::mahad(x, plot=FALSE)
  xbar <- base::mean(md)
  SD <- stats::sd(md)
  
  predictions <- ifelse(md > xbar + (SD*cut), 1, 0)
  
  confusionMatrix(predictions,truth)
}
ryentes/rdy-dissertation-tools documentation built on Dec. 5, 2019, 10:23 p.m.