本文介绍了R中的Neuronet-为所有输入值获得相同的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试准备一个神经网络,以基于两个参数否"和预测"来预测产品的理赔数量. '年龄'. 以下数据集是神经网络的输入.

structure(list(no = c(25305.4104099149, 49282.7650363303, 71596.161588407, 
93100.2399492689, 120575.89348652, 138907.168168798, 152853.150129645, 
164658.048266216, 203323.951054253, 217964.514231364, 232098.010631853, 
245528.300551639, 257729.677107825, 273017.858354583, 289943.942081732, 
307253.529762711, 322779.210756104, 338484.424561413, 354509.62945598, 
376508.167449508, 392559.686167136, 406403.704572922, 418237.95321136, 
428306.956736623, 443032.309329306, 462815.029777392, 483057.035564531, 
501119.337852308, 516468.28989971, 529231.965438745, 546230.529378035), 
age = c(63.5793740593707, 102.316649334314, 139.062062015527, 
159.908188195329, 221.139098010716, 243.371632144127, 255.656705912817, 
321.979062244126, 302.183543005839, 354.719062375634, 369.989444935937, 
415.562730056562, 445.18103403067, 487.443822982359, 522.664771025013, 
531.055799381952, 588.227179384567, 627.155320232965, 631.325866647729, 
656.228738193787, 674.252217317525, 717.171080443709, 741.672049752712, 
788.251261134812, 798.113504685438, 831.731613476353, 834.814816968948, 
868.754851062387, 891.362029551517, 902.022293484355, 940.795814337874), 
claims = c(430.964844652385, 732.996578820216, 1702.3121722574,
2251.25233558302, 2197.47809502525, 2567.04757960458, 3031.86042202782, 
3156.90611199034, 3863.87816105778, 4111.89975688297, 3775.93067659216, 
4012.49766196774, 4312.44312947351, 4180.22855748422, 5089.44484309535, 
4257.88997259059, 4880.90586497903, 4463.20376379347, 4240.41527392955, 
4784.76670484109, 5402.00394657619, 4599.18095060565, 4003.91468429224, 
4029.72081951048, 3774.73142127963, 3920.30299815048, 5640.00980484863, 
5609.58082520698, 4689.03553448074, 5021.68591677232, 6583.74468086371), 
expense = c(152020.866139235, 435514.001634924, 752077.230564814, 
1206688.79158373, 1291739.60434588, 1421308.36224772, 2050740.38970347, 
1975198.4497045, 2274222.98020964, 2579595.43870509, 2129258.22735162, 
2135819.30924201, 2670328.44657756, 2908678.20678848, 2647633.44523976, 
2416617.98013342, 2312104.28655066, 2603487.56885879, 2598480.12097434, 
2747610.29007465, 2856983.01477582, 2453661.76656217, 2557917.28443019, 
2952529.81656875, 2177766.2760928, 2077444.9802322, 3542576.76934085, 
4050503.17869956, 3737028.1474149, 3497074.2505681, 3541174.73116362)),
.Names = c("no", "age", "claims", "expense"), row.names = c(NA, -31L), 
class = "data.frame")

我正在尝试的神经网络

claimnet = neuralnet(claims~no+age,data=claimdata,hidden=10,threshold=0.01,err.fct='sse')

我从 claimnet $ net.result获得的所有31条记录的输出/拟合值为3913.491497 .当我尝试使用该神经网络进行计算时,结果也是一样.我认为必须传递一些参数才能获得正确的输出.

请让我知道我要去哪里了.

解决方案

似乎,如果没有跳过层连接,神经网络体系结构将无法正确地近似模型.我在neuralnet中找不到这样的选项,但是您可以使用nnet作为替代.

library(nnet)
res <- nnet(claims ~ .,
    data=claimdata[,1:3],
    size=10, linout=TRUE, skip=TRUE, MaxNWts=10000, trace=FALSE, maxit=100)
predict(res, newdata=claimdata[,1:2])

I am trying to prepare a neural net to forecast number of claims for a product based on two parameters 'no' & 'age'. Following data set is the input to neuralnet.

structure(list(no = c(25305.4104099149, 49282.7650363303, 71596.161588407, 
93100.2399492689, 120575.89348652, 138907.168168798, 152853.150129645, 
164658.048266216, 203323.951054253, 217964.514231364, 232098.010631853, 
245528.300551639, 257729.677107825, 273017.858354583, 289943.942081732, 
307253.529762711, 322779.210756104, 338484.424561413, 354509.62945598, 
376508.167449508, 392559.686167136, 406403.704572922, 418237.95321136, 
428306.956736623, 443032.309329306, 462815.029777392, 483057.035564531, 
501119.337852308, 516468.28989971, 529231.965438745, 546230.529378035), 
age = c(63.5793740593707, 102.316649334314, 139.062062015527, 
159.908188195329, 221.139098010716, 243.371632144127, 255.656705912817, 
321.979062244126, 302.183543005839, 354.719062375634, 369.989444935937, 
415.562730056562, 445.18103403067, 487.443822982359, 522.664771025013, 
531.055799381952, 588.227179384567, 627.155320232965, 631.325866647729, 
656.228738193787, 674.252217317525, 717.171080443709, 741.672049752712, 
788.251261134812, 798.113504685438, 831.731613476353, 834.814816968948, 
868.754851062387, 891.362029551517, 902.022293484355, 940.795814337874), 
claims = c(430.964844652385, 732.996578820216, 1702.3121722574,
2251.25233558302, 2197.47809502525, 2567.04757960458, 3031.86042202782, 
3156.90611199034, 3863.87816105778, 4111.89975688297, 3775.93067659216, 
4012.49766196774, 4312.44312947351, 4180.22855748422, 5089.44484309535, 
4257.88997259059, 4880.90586497903, 4463.20376379347, 4240.41527392955, 
4784.76670484109, 5402.00394657619, 4599.18095060565, 4003.91468429224, 
4029.72081951048, 3774.73142127963, 3920.30299815048, 5640.00980484863, 
5609.58082520698, 4689.03553448074, 5021.68591677232, 6583.74468086371), 
expense = c(152020.866139235, 435514.001634924, 752077.230564814, 
1206688.79158373, 1291739.60434588, 1421308.36224772, 2050740.38970347, 
1975198.4497045, 2274222.98020964, 2579595.43870509, 2129258.22735162, 
2135819.30924201, 2670328.44657756, 2908678.20678848, 2647633.44523976, 
2416617.98013342, 2312104.28655066, 2603487.56885879, 2598480.12097434, 
2747610.29007465, 2856983.01477582, 2453661.76656217, 2557917.28443019, 
2952529.81656875, 2177766.2760928, 2077444.9802322, 3542576.76934085, 
4050503.17869956, 3737028.1474149, 3497074.2505681, 3541174.73116362)),
.Names = c("no", "age", "claims", "expense"), row.names = c(NA, -31L), 
class = "data.frame")

Neural network that I am trying is

claimnet = neuralnet(claims~no+age,data=claimdata,hidden=10,threshold=0.01,err.fct='sse')

Output/fitted that I am getting from claimnet$net.result is 3913.491497 for all 31 records. Same is the result when I try compute with this neuralnet. I think there must be some parameters that must be passed to get proper output.

Please let me know where am I going wrong.

解决方案

It seems that without the skip layer connections, the neural network architecture is unable to correctly approximate the model. I can't find such an option in neuralnet but you can use nnet as an alternative.

library(nnet)
res <- nnet(claims ~ .,
    data=claimdata[,1:3],
    size=10, linout=TRUE, skip=TRUE, MaxNWts=10000, trace=FALSE, maxit=100)
predict(res, newdata=claimdata[,1:2])

这篇关于R中的Neuronet-为所有输入值获得相同的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 21:46