update.train: Update or Re-fit a Model

Description Usage Arguments Details Value Author(s) See Also Examples

Description

update allows a user to over-ride the tuning parameter selection process by specifying a set of tuning parameters or to update the model object to the latest version of this package.

Usage

1
2
## S3 method for class 'train'
update(object, param = NULL, ...)

Arguments

object

an object of class train

param

a data frame or named list of all tuning parameters

...

not currently used

Details

If the model object was created with version 5.17-7 or earlier, the underlying package structure was different. To make old train objects consistent with the new structure, use param = NULL to get the same object back with updates.

To update the model parameters, the training data must be stored in the model object (see the option returnData in trainControl. Also, all tuning parameters must be specified in the param slot. All other options are held constant, including the original pre-processing (if any), options passed in using code... and so on. When printing, the verbiage "The tuning parameter was set manually." is used to describe how the tuning parameters were created.

Value

a new train object

Author(s)

Max Kuhn

See Also

train, trainControl

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
data(iris)
TrainData <- iris[,1:4]
TrainClasses <- iris[,5]

knnFit1 <- train(TrainData, TrainClasses,
                 method = "knn",
                 preProcess = c("center", "scale"),
                 tuneLength = 10,
                 trControl = trainControl(method = "cv"))

update(knnFit1, list(.k = 3))

## End(Not run)

Example output

Loading required package: lattice
Loading required package: ggplot2
Warning in pre_process_options(method, column_types) :
  The following pre-processing methods were eliminated: 'ignore'
k-Nearest Neighbors 

150 samples
  4 predictor
  3 classes: 'setosa', 'versicolor', 'virginica' 

Pre-processing: centered (4), scaled (4) 
Resampling: Cross-Validated (10 fold) 
Summary of sample sizes: 135, 135, 135, 135, 135, 135, ... 
Resampling results across tuning parameters:

  k   Accuracy   Kappa
   5  0.9333333  0.90 
   7  0.9533333  0.93 
   9  0.9533333  0.93 
  11  0.9533333  0.93 
  13  0.9600000  0.94 
  15  0.9600000  0.94 
  17  0.9600000  0.94 
  19  0.9466667  0.92 
  21  0.9466667  0.92 
  23  0.9466667  0.92 

The tuning parameter was set manually.
The final value used for the model was k = 3.

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

Related to update.train in caret...