简体   繁体   English

随机森林模型问题

[英]Random Forest Model issues

I ran Random Forest Model in R then now i call it to predict my dataset 我在R中运行了随机森林模型,然后调用它来预测我的数据集

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')" UseMethod(“ predict”)中的错误:没有适用于'predict'的适用方法应用于类“ c('randomForest.formula','randomForest')”的对象

Do anyone know how to fix this error pls? 有人知道如何解决此错误吗?

Regards 问候

It appears that you are using two different R scripts - one for training, and another one for prediction. 看来您正在使用两种不同的R脚本-一种用于训练,另一种用于预测。 This error means that your prediction R script does not know about the randomForest(.formula) class. 此错误意味着您的预测R脚本不了解randomForest(.formula)类。

You can fix it by simply importing the "randomForest" library into your prediction R script: 您可以通过简单地将“ randomForest”库导入到预测R脚本中来解决此问题:

library("randomForest")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM