R Caret为测试集计算RMSE

问题描述 投票:0回答:1

我想知道如何为测试集计算RMSE。

我使用下面的代码训练模型:

model_gbm_important<-train(trainSetSmall[,predictors_gbm],trainSetSmall[,outcomeName],method='gbm', trControl=fitControl)

我可以通过使用来获得模型的性能

print(model_gbm_important)

但是,此性能基于交叉验证。如果我有另一个测试集,如何使用测试集评估模型,舔一下RMSE的值?

谢谢!

r r-caret
1个回答
1
投票

要计算测试数据预测的RMSE:

predictions <- predict(model, test_data)
RMSE(predictions, test_data$outcomeName)
© www.soinside.com 2019 - 2024. All rights reserved.