predict.randomForest 未找到
predict.randomForest not found
我正在使用 R (RStudio) 和 运行domForest 包。我使用了以下代码:
rf = randomForest(y ~ x1 + x2 +...)
效果很好。然后我试着用predict.randomForest
函数和运行变成了一个问题。 R 给了我以下信息:
Error: could not find function "predict.randomForest"
当我进入运行domForest帮助页面(??randomForest
)时,它告诉我有predict.randomForest
这样的函数,但我无法调用它.这里发生了什么?我检查了 运行domForest 包是否有可用的更新,并且有 none.
此外,plot.randomForest() 函数也未找到。
您可以只使用通用的 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
您还可以查看 MDSplot()
以及同一来源的示例:
set.seed(17)
iris.urf <- randomForest(iris[, -5])
MDSplot(iris.urf, iris$Species)
我正在使用 R (RStudio) 和 运行domForest 包。我使用了以下代码:
rf = randomForest(y ~ x1 + x2 +...)
效果很好。然后我试着用predict.randomForest
函数和运行变成了一个问题。 R 给了我以下信息:
Error: could not find function "predict.randomForest"
当我进入运行domForest帮助页面(??randomForest
)时,它告诉我有predict.randomForest
这样的函数,但我无法调用它.这里发生了什么?我检查了 运行domForest 包是否有可用的更新,并且有 none.
此外,plot.randomForest() 函数也未找到。
您可以只使用通用的 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
您还可以查看 MDSplot()
以及同一来源的示例:
set.seed(17)
iris.urf <- randomForest(iris[, -5])
MDSplot(iris.urf, iris$Species)