Reputation: 39
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
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