iris data:
three species : setosa, virginica and versicolor (3分类)
Four features : the length and the width of the sepals and petals(4特性)
####
library(randomForest)
data(iris)
iris
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
.....
.....
148 6.5 3.0 5.2 2.0 virginica
149 6.2 3.4 5.4 2.3 virginica
150 5.9 3.0 5.1 1.8 virginica
set.seed(71)
randomForest(Species ~ ., data=iris, importance=TRUE)
等同
set.seed(71)
randomForest(Species ~Sepal.Length + Sepal.Width + Petal.Length + Petal.Width , data=iris, importance=TRUE)
Call:
randomForest(formula = Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width, data = iris, importance = TRUE)
Type of random forest: classification
Number of trees: 500
No. of variables tried at each split: 2
OOB estimate of error rate: 4%
Confusion matrix:
setosa versicolor virginica class.error
setosa 50 0 0 0.00
versicolor 0 47 3 0.06
virginica 0 3 47 0.06
再有问题,把数据传上来


雷达卡


京公网安备 11010802022788号







