首页 文章

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

提问于
浏览
0

我很好奇如何从插入符号训练模型中提取默认模型设置 . 在我的情况下,我使用 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')

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

1 回答

  • 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"
    

相关问题