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

From: Jim_S <virtualreal_at_gmail.com>
Date: Mon, 16 Jun 2008 00:01:31 -0700 (PDT)

Now I read it in the manual "If xtest is given, defaults to FALSE." Thanks for your help!

Jim

Moshe Olshansky-2 wrote:

> 
> You must use randomForest with keep.forest=TRUE - otherwise the Forest
> object is not saved and so no prediction can be made.
> 
> 
> --- On Mon, 16/6/08, Jim_S <virtualreal_at_gmail.com> wrote:
> 

>> From: Jim_S <virtualreal@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.
> 
> 

-- 
View this message in context: http://www.nabble.com/randomForest%2C-%27No-forest-component...%27-error-while-calling-Predict%28%29-tp17855119p17858931.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.
Received on Mon 16 Jun 2008 - 07:19:36 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 - 09:30:40 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