[R] Surprising randomForest Results

Liaw, Andy andy_liaw at merck.com
Wed Oct 1 17:47:22 CEST 2008


If you read the help page for randomForest(), you would expect this
behavior...

In the "Value" section of that help page, it says:

predicted 	the predicted values of the input data based on
out-of-bag samples. 

Andy 

From: Rodney Barnett
> 
> Is it expected that predict.randomForest() produces the 
> response vector when
> given the same data frame as provided to randomForest()?  See below.
> 
> Thanks.
> 
> Rodney
> 
> > rf <- randomForest (Species ~ ., iris)
> > pc <- predict (rf, iris)
> > confusion (pc, iris$Species)
>             true
> object       setosa versicolor virginica
>   setosa         50          0         0
>   versicolor      0         50         0
>   virginica       0          0        50
> attr(,"error")
> [1] 0
> > confusion (rf$predicted, iris$Species)
>             true
> object       setosa versicolor virginica
>   setosa         50          0         0
>   versicolor      0         47         3
>   virginica       0          3        47
> attr(,"error")
> [1] 0.04
> > rf$confusion
>            setosa versicolor virginica class.error
> setosa         50          0         0        0.00
> versicolor      0         47         3        0.06
> virginica       0          3        47        0.06
> >
> 
> ______________________________________________
> 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.
> 
Notice:  This e-mail message, together with any attachme...{{dropped:12}}



More information about the R-help mailing list