R-Caret:如何访问特定型号的列车控制参数

时间:2015-03-12 17:06:44

标签: r r-caret

我很好奇如何从插入符号训练模型中提取默认模型设置。在我的情况下,我使用ctree来构建回归树。

library(caret)
library(party)
data(trees)
# case 1: use ctree directly
ctree_train_control<-ctree_control()
ct<-ctree(Volume~.,trees,control=ctree_train_control)
# case 2: use ctree train method in caret
modFitCtree<-train(Volume~.,data=trees,method='ctree')

假设我想知道ctree中使用的testtype训练控制参数modFitCtree是否是&#34; Bonferroni&#34;或者是其他东西。在案例1中,我可以手动检查ctree_train_control以查找默认设置。如果我有案例2中的插入符号模型,是否有某个字段可以提取这些模型设置?

1 个答案:

答案 0 :(得分:1)

如果您想知道模型的拟合方式,请使用getModelInfo("ctree", regex = FALSE)[[1]]$fit查看。在这种情况下,相关的行是:

if(any(names(theDots) == "controls")) {
   theDots$controls@gtctrl@mincriterion 

In other words, if you don't specify anything, only mincriterion is changed. Note that it is intercepting the controls argument so you can still pass that in and it will leave everything but mincriterion alone.

After you fit the model, you have access to whatever is saved. In this case:

> slotNames(modFitCtree$finalModel) [1] "data" "responses" "cond_distr_response" [4] "predict_response" "prediction_weights" "get_where" [7] "update" "tree" "where" [10] "weights"