gpt4 book ai didi

r - 与游侠的重要性不同

转载 作者:行者123 更新时间:2023-11-30 08:22:35 25 4
gpt4 key购买 nike

我使用 caret + ranger 训练了一个随机森林。

fit <- train(
y ~ x1 + x2
,data = total_set
,method = "ranger"
,trControl = trainControl(method="cv", number = 5, allowParallel = TRUE, verbose = TRUE)
,tuneGrid = expand.grid(mtry = c(4,5,6))
,importance = 'impurity'
)

现在我想看看变量的重要性。然而,这些都不起作用:

> importance(fit)
Error in UseMethod("importance") : no applicable method for 'importance' applied to an object of class "c('train', 'train.formula')"
> fit$variable.importance
NULL
> fit$importance
NULL

> fit
Random Forest

217380 samples
32 predictors

No pre-processing
Resampling: Cross-Validated (5 fold)
Summary of sample sizes: 173904, 173904, 173904, 173904, 173904
Resampling results across tuning parameters:

mtry RMSE Rsquared
4 0.03640464 0.5378731
5 0.03645528 0.5366478
6 0.03651451 0.5352838

RMSE was used to select the optimal model using the smallest value.
The final value used for the model was mtry = 4.

知道我是否能够得到它以及如何得到它吗?

谢谢。

最佳答案

varImp(fit) 将为您获取它。

为了弄清楚这一点,我查看了 names(fit),这导致我找到 names(fit$modelInfo) - 然后你会看到 varImp 作为选项之一。

关于r - 与游侠的重要性不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37279964/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com