我想获得神经网络的预测结果的准确性或 RMSE
. 我开始使用混淆矩阵,但如前面的答案所示,混淆矩阵为非连续变量提供有效结果 .
有什么方法可以获得神经网络预测的准确度或错误率吗?
作为一个例子,这是我到目前为止的代码:
library(nnet)
library(caret)
library(e1071)
data(rock)
newformula <- perm ~ area + peri + shape
y <- rock[, "perm"]
x <- rock[!colnames(rock)%in% "perm"]
original <- datacol(rock,"perm")
nnclas_model <- nnet(newformula, data = rock, size = 4, decay = 0.0001, maxit = 500)
nnclas_prediction <- predict(nnclas_model, x)
nnclas_tab <- table(nnclas_prediction, y)
rmse <- sqrt(mean((original - nnclas_prediction)^2))
有谁知道我怎么能做这个工作?或者我如何获得准确度或神经网络预测?任何帮助将深表感谢 .
2 回答
正如评论中所提到的,混淆矩阵用于分类问题 . 如果您打算根据其级别对
perm
进行分类,那么以下代码应该适合您 .如果你的意思是将
perm
视为连续的,那么混淆矩阵没有任何意义 . 您应该考虑均方误差 .我不知道"nnet",但我使用了"neuralnet"库并且能够获得RMSE . 这是我的完整代码: Just change the data for training_Data and testing_Data as per your requirements and in place of "Channel" give what is your classification attribute