未找到Forecast.random林
我使用的是R(RStudio)和randomForest包。我使用了以下代码:未找到Forecast.random林,r,package,random-forest,R,Package,Random Forest,我使用的是R(RStudio)和randomForest包。我使用了以下代码: rf = randomForest(y ~ x1 + x2 +...) 效果很好。然后我尝试使用predict.randomForest函数,结果遇到了一个问题。R给了我以下信息: Error: could not find function "predict.randomForest" 当我转到randomForest帮助页面(??randomForest)时,它显示有一个函数,如predict.randomF
rf = randomForest(y ~ x1 + x2 +...)
效果很好。然后我尝试使用predict.randomForest
函数,结果遇到了一个问题。R给了我以下信息:
Error: could not find function "predict.randomForest"
当我转到randomForest帮助页面(??randomForest
)时,它显示有一个函数,如predict.randomForest
,但我无法调用它。这是怎么回事?我检查了randomForest包是否有可用的更新,但没有
此外,也找不到plot.randomForest()函数。您只需使用generic
plot()
和predict()
,就像本例中的?randomForest
:
require(randomForest)
set.seed(17)
x <- matrix(runif(5e2), 100)
y <- gl(2, 50)
myrf <- randomForest(x, y)
predict(myrf, x)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
Levels: 1 2
啊,好的。感谢replypredict.randomForest是一个S3方法,泛型函数predict()将用于类“randomForest”或继承“randomForest”的子类的所有对象。如果您想出于某种诊断目的直接访问该功能,请尝试;mypredrf函数
set.seed(17)
iris.urf <- randomForest(iris[, -5])
MDSplot(iris.urf, iris$Species)