首页 > 解决方案 > 在 R 中获取神经网络的恒定输出(net.result)

问题描述

我正在尝试运行一个神经网络模型来预测以下数据集中 y 的值(下面提供的 dput):

structure(list(feature1 = c(1, 1, 1, 1, 1), feature3 = c(2, 1, 
2, 2, 1), feature4 = c(5.20909584705607, 4.45094060803504, 5.39655180066883, 
4.97016301474876, 5.26686796952951), feature5 = c(9789.26151130325, 
10552.5218988245, 10233.4331187079, 10829.0567458179, 10678.7036869759
), feature7 = c(0.00101042237609137, 0.000999767963117104, 0.00101456547642991, 
0.000992996484855727, 0.00100941888927906), feature9 = c(13L, 
11L, 13L, 8L, 11L), y = c(0L, 0L, 0L, 1L, 0L)), row.names = c(NA, 
5L), class = "data.frame")

我用于构建神经网络的代码如下所示:

library(neuralnet)
ann <- neuralnet(y~., train_model, hidden = c(2,2), act.fct = "tanh")
plot(ann)
ann$net.result

该模型运行良好,误差为 106。但是,当我尝试查看 net.results 时,我得到所有观测值的恒定概率为 0.31。

标签: rneural-networkshared-libraries

解决方案


推荐阅读