R/classLevels.R

levels.train <- function(x, ...) {
  if(x$modelType == "Classification") {
    if(!isS4(x$finalModel) && !is.null(x$finalModel$obsLevels)) 
      return(x$finalModel$obsLevels)
    if(is.null(x$modelInfo)) {
      code <- getModelInfo(x$method, regex = FALSE)[[1]]
    } else code <- x$modelInfo
    if(!is.null(code$levels)){
      checkInstall(code$library)
      for(i in seq(along = code$library)) 
        do.call("require", list(package = code$library[i]))
      out <- code$levels(x$finalModel, ...)
    } else out <- NULL
  } else out <- NULL
  out
}

Try the caret package in your browser

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

caret documentation built on May 2, 2019, 5:47 p.m.