R/trim.R

Defines functions trim.train trim

trim <- function(object, ...) UseMethod("trim")

#' @export
trim.train <- function(object, ...) {
  removals <- c("results", "pred", "bestTune", "call", "dots",
                "metric", "trainingData", "resample", "resampledCM",
                "perfNames", "maxmimize", "times")
  for(i in removals)
    if(i %in% names(object)) object[i] <- NULL
  c_removals <- c('method', 'number', 'repeats', 'p', 'initialWindow', 
                  'horizon', 'fixedWindow', 'verboseIter', 'returnData', 
                  'returnResamp', 'savePredictions', 'summaryFunction', 
                  'selectionFunction', 'index', 'indexOut', 'indexFinal',
                  'timingSamps', 'trim', 'yLimits')
  for(i in c_removals)
    if(i %in% names(object$control)) object$control[i] <- NULL  
  if(!is.null(object$modelInfo$trim))
    object$finalModel <- object$modelInfo$trim(object$finalModel)
  object
}

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.