File: trim.R

package info (click to toggle)
r-cran-caret 6.0-81-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,268 kB
  • sloc: ansic: 208; sh: 10; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 896 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
}