Re: [R] randomForest, 'No forest component...' error while calling Predict()

From: Moshe Olshansky <m_olshansky_at_yahoo.com>
Date: Sun, 15 Jun 2008 18:44:48 -0700 (PDT)


You must use randomForest with keep.forest=TRUE - otherwise the Forest object is not saved and so no prediction can be made.

> From: Jim_S <virtualreal_at_gmail.com>
> Subject: [R] randomForest, 'No forest component...' error while calling Predict()
> To: r-help_at_r-project.org
> Received: Monday, 16 June, 2008, 8:13 AM
> Dear R-users,
>
> While making a prediction using the randomForest function
> (package
> randomForest) I'm getting the following error message:
>
> "Error in predict.randomForest(model, newdata = CV) :
> No forest component
> in the object"
> Here's my complete code. For reproducing this task,
> please find my 2 data
> sets attached (
>
http://www.nabble.com/file/p17855119/data.rar data.rar ).
>
> Thanks in advance for any help!
>
> - Jim
>
> CT <-
> read.table("CT.txt",header=TRUE,sep="\t")
> CV <-
> read.table("CV.txt",header=TRUE,sep="\t")
> # Both CT & CV have the syntaxis X1, X2,...,X97,Y where
> all variables are
> numeric
> x <- CT[,-98]
> y <- CT[,98]
> xtest <- CV[,-98]
> ytest <- CV[,98]
> library(randomForest)
> model <- randomForest(x ,y , xtest,
> ytest,ntree=500,mtry=32,nodesize=5,nPerm=2)
> model
>
> #Call:
> # randomForest(x = x, y = y, xtest = xtest, ytest = ytest,
> ntree = 500,
> mtry = 32, nodesize = 5,
> # nPerm = 2)
> # Type of random forest: regression
> # Number of trees: 500
> #No. of variables tried at each split: 32
> #
> # Mean of squared residuals: 0.0022117
> # % Var explained: -1.01
> # Test set MSE: 0
> # % Var explained: 2.61
>
>
> prediction <- predict(model, newdata= CT)
> #Error in predict.randomForest(model, newdata = CV) :
> # No forest component in the object
> #
> --
> View this message in context:
> http://www.nabble.com/randomForest%2C-%27No-forest-component...%27-error-while-calling-Predict%28%29-tp17855119p17855119.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.



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. Received on Mon 16 Jun 2008 - 01:48:08 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 16 Jun 2008 - 08:30:44 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive