R/probFunction.R

Defines functions probFunction

Documented in probFunction

#' @rdname caret-internal
#' @export
probFunction <- function(method, modelFit, newdata = NULL, preProc = NULL, param = NULL)
{
  if(!is.null(newdata) && !is.null(preProc)) newdata <- predict(preProc, newdata)

  obsLevels <- levels(modelFit)

  classProb <- method$prob(modelFit = modelFit,
                           newdata = newdata,
                           submodels = param)
  if(!is.data.frame(classProb) & is.null(param))
  {
    classProb <- as.data.frame(classProb, stringsAsFactors = TRUE)
    if(!is.null(obsLevels)) classprob <- classProb[, obsLevels]
  }
  classProb
}

Try the caret package in your browser

Any scripts or data that you put into this service are public.

caret documentation built on March 31, 2023, 9:49 p.m.