2016-11-08 1 views
0

caretでは、関数best,toleranceなどを使用しています。パフォーマンスペナルティが小さく(tutorial)、あまり複雑ではないモデルを選択できます。キャレットの `finalModel`から別のモデルを選ぶには?

toleranceを使用した後、私は、例えば、すべてのもののうち3番目のモデルをcaretで調整したいと思っています。 caret_result$finalModelを選ぶ方法と同様のモデルを抽出することは可能ですか?あるいは、そのモデルのハイパーパラメータを取り、それらにモデルを再フィットさせる必要がありますか?

答えて

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. 
関連する問題