【发布时间】:2019-10-16 15:02:34
【问题描述】:
当不在插入符号“rf”模型中指定 ntree 计数时,我很难找到模型中使用了多少棵树。
这是我用来训练模型的代码:
fitControl <- trainControl(
method = "cv",
number = 3,
savePredictions = "final",
classProbs = T,
summaryFunction = twoClassSummary,
sampling = "down")
set.seed(3219)
rf_model_down <- train(Class ~ .,
data = train_data,
method ='rf',
tuneLength = 2,
trControl = fitControl,
metric = "ROC")
使用print(rf_model_down) 函数,我可以看到mtry 是什么,但它没有告诉我们使用的ntree 计数。
print(rf_model_down)
# Random Forest
#
# 10000 samples
# 94 predictor
# 2 classes: 'Fraud', 'notFraud'
#
# No pre-processing
# Resampling: Cross-Validated (3 fold)
# Summary of sample sizes: 6667, 6666, 6667
# Addtional sampling using down-sampling
#
# Resampling results across tuning parameters:
#
# mtry ROC Sens Spec
# 2 0.7401603 0.7691257 0.5717070
# 94 0.7449104 0.6814208 0.6641911
#
# ROC was used to select the optimal model using the largest value.
# The final value used for the model was mtry = 94.
在此先感谢您提供的最有可能是一个我很难找到的简单答案...
【问题讨论】:
标签: r random-forest r-caret