[R] Random Forest confusion matrix
Gabor Grothendieck
ggrothendieck at gmail.com
Thu Feb 26 18:06:19 CET 2009
randomForest output is based on predict(iris.rf) whereas the
code shown below uses predict(iris.rf, iris). See ?predict.randomForest
for an explanation.
On Thu, Feb 26, 2009 at 11:10 AM, Li GUO <guoli84 at yahoo.com> wrote:
> Dear R users,
>
> I have a question on the confusion matrix generated by function randomForest.
> I used the entire data
> set to generate the forest, for example:
>> print(iris.rf)
>
> Call:
> randomForest(formula = Species ~ ., data = iris, importance = TRUE,
> keep.forest = TRUE)
>
> confusion
> setosa versicolor virginica class.error
> setosa 50 0 0 0.00
> versicolor 0 47 3 0.06
> virginica 0 3 47 0.06
>
> then I classified the same data set with this forest:
>
>> iris.pred <- predict(iris.rf, iris)
>> table(observed = iris[,"Species"], predicted = iris.pred)
> predicted
> observed setosa versicolor virginica
> setosa 50 0 0
> versicolor 0 50 0
> virginica 0 0 50
> Why the two matrices are different?
> Thinks,
>
> Li
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list