在caret
中,使用函数best
,tolerance
等。我可以选择性能较低(tutorial)的不太复杂的模型。
使用tolerance
之后,我现在知道,我希望在caret
调整的所有模型中使用第3个模型。是否可以提取类似于我如何选择caret_result$finalModel
的模型?或者我是否必须采用该模型的超参数并用它们重新拟合模型?
答案 0 :(得分:2)
请参阅update.train
:
> mod1 <- train(Species ~ ., data = iris, method = "rpart")
> mod1
CART
150 samples
4 predictor
3 classes: 'setosa', 'versicolor', 'virginica'
No pre-processing
Resampling: Bootstrapped (25 reps)
Summary of sample sizes: 150, 150, 150, 150, 150, 150, ...
Resampling results across tuning parameters:
cp Accuracy Kappa
0.00 0.9434796 0.9145259
0.44 0.7609620 0.6544837
0.50 0.4731651 0.2350673
Accuracy was used to select the optimal model using the largest value.
The final value used for the model was cp = 0.
> update(mod1, param = list(cp = .44))
CART
150 samples
4 predictor
3 classes: 'setosa', 'versicolor', 'virginica'
No pre-processing
Resampling: Bootstrapped (25 reps)
Summary of sample sizes: 150, 150, 150, 150, 150, 150, ...
Resampling results across tuning parameters:
cp Accuracy Kappa
0.00 0.9434796 0.9145259
0.44 0.7609620 0.6544837
0.50 0.4731651 0.2350673
The tuning parameter was set manually.
The final value used for the model was cp = 0.44.