gpt4 book ai didi

r - 无法从R中的randomForest生成部分图

转载 作者:行者123 更新时间:2023-12-04 11:59:11 24 4
gpt4 key购买 nike

构建模型,可以生成所有可变重要性图。但是,当我在连续变量上使用partialPlot时,例如purchase_value:partialPlot(rf, fraud_data_train, purchase_value, which.class = 1)错误是

Error in is.finite(x): default method not implemented for type 'list'

对于分类变量( browser),错误为 partialPlot(rf, fraud_data_train, browser, which.class = 1)
Error in FUN(X[[i]], ...) : 
only defined on a data frame with all numeric variables

数据可用 here,代码如下:
rf = randomForest(y = fraud_data_train$class_factor, 
x = fraud_data_train[,-predictors_notinclude],
ntree = 30, mtry = 4, keep.forest = TRUE,
importance = TRUE, proximity = TRUE)
partialPlot(rf, fraud_data_train, purchase_value, which.class =1)

更新:

这是我的R Studio控制台的屏幕截图:
enter image description here

更新2

情节以某种方式显示在笔记本的Markdown中..但仍然感到困惑,为什么它无法在控制台中输出
enter image description here

最佳答案

如果您的数据是tibble而不是data.frame,则会遇到此问题。看来tibble(也许也可以是data_frame,但无法测试)与partialPlot函数不兼容。

一个简单的解决方案是执行类似partialPlot(rf, as.data.frame(fraud_data_train), purchase_value, which.class = 1)的操作。

关于r - 无法从R中的randomForest生成部分图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38799216/

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