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

R-Caret: How to access model-specific train control parameters

我很好奇如何从插入符号训练的模型中提取默认模型设置。在我的例子中,我使用 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 中的插入符号模型,是否有某个字段可以提取这些模型设置?

想知道模型拟合度如何,用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"