【问题标题】:VSURF and randomForestVSURF 和随机森林
【发布时间】:2016-07-21 22:53:39
【问题描述】:

我正在尝试在 R 中使用 VSURF 和 randomForest,但库中的函数(如 predict.VSURF、predict.randomForest 和 plot.VSURF)不起作用,并且出现以下错误:

错误:找不到函数“predict.VSURF”

这是一个可重现的例子:

library(randomForest)
library(VSURF)
data(cars)
fit <- VSURF(x = cars[1:402,2:ncol(cars)], y = cars[1:402,1])
#At this step I get the error: Error: could not find function "predict.VSURF"
preds <- predict.VSURF(fit, newdata = cars[403:804,2:ncol(cars)]) 

【问题讨论】:

    标签: r random-forest


    【解决方案1】:

    R 将 fit 识别为 VSURF 类对象并为其调用 VSURF.predict。你只需要使用predict()

    此外,在查看您的示例时,VSURF 似乎仅因一个 x 变量引发此错误而失败:

    矩阵中的错误(NA,nrow = nfor.thres,ncol = ncol(x)): 非数字矩阵范围

    使用mtcars 并且仅使用predict(),VSURF 对我来说很好。

    data("mtcars")
    fit <- VSURF(x = mtcars[1:25,2:ncol(mtcars)], y = mtcars[1:25,1])
    preds <- predict(fit, newdata = mtcars[26:32, 2:ncol(mtcars)])
    

    【讨论】:

    • 你知道为什么 preds 有两列吗?我认为“pred”列是预测,但我不确定另一列是什么
    • @IJH VSURF 似乎迭代地预测数据,一次是在“解释”步骤中,最后是在“预测”步骤中。您可以使用step = "pred" 来限制输出。
    猜你喜欢
    • 1970-01-01
    • 2017-01-22
    • 2017-03-15
    • 2015-02-12
    • 2014-08-07
    • 2015-10-15
    • 2015-02-15
    • 2018-07-10
    相关资源
    最近更新 更多