1
votes

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

1
The problem can only be solved with access to a sample of your data.NelsonGon
dear NelsonGon, thank you very much for your comment, i know it is hard for you to solve problems without data set however out dataset contains 88 satellite images which is over 200 GB so I could not upload the one here, very sorry for thattnbang

1 Answers

2
votes

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")