I created a model in R for my df as
fit <- randomForest(y ~ x1 +
x2 + x3 +
x4+ x5+x6+ x7+x8,
data = data_train,ntree=35,
keep.forest=FALSE, importance=TRUE)
gives result as
Call:
randomForest(formula = y ~ x1 + x2
+ x3 + x4 + x5 +
x6 + x7 + x8, data =
data_train, ntree = 35, keep.forest = FALSE, importance = TRUE)
Type of random forest: regression
Number of trees: 35
No. of variables tried at each split: 2
Mean of squared residuals: 2901510
% Var explained: 53.45
but while I am predicting using
p <- predict(data_test, fit, type='prob')
Shows error
Error in ets(object, lambda = lambda, biasadj = biasadj,
allow.multiplicative.trend = allow.multiplicative.trend, :
y should be a univariate time series
When I am using
predict(fit, newdata= data_test)
Showing error
Error in predict.randomForest(fit, newdata = data_test) :
No forest component in the object
how can I solve this.. I am new in using RandomForest in R
As @bzki suggested By putting keep.forest = TRUE It works fine
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.