tnbang
tnbang

Reputation: 39

Random Forest Model issues

I ran Random Forest Model in R then now i call it to predict my dataset

predict.rf<-predict(layers.stack,random.forest, na.rm=T, type='response')

However it comes with one error as follow:

Error in UseMethod("predict") : no applicable method for 'predict' applied to an object of class "c('randomForest.formula', 'randomForest')"

Do anyone know how to fix this error pls?

Regards

Upvotes: 1

Views: 274

Answers (1)

user1808924
user1808924

Reputation: 4926

It appears that you are using two different R scripts - one for training, and another one for prediction. This error means that your prediction R script does not know about the randomForest(.formula) class.

You can fix it by simply importing the "randomForest" library into your prediction R script:

library("randomForest")

Upvotes: 2

Related Questions