バックプロパゲーション

「データからの知識発見」第12章バックプロパゲーション

訓練用データ

1
2
3
input<-c(0.015,0.11,0.205,0.3,0.395,0.49,0.585,0.68,0.775,0.87,0.965)
output<-c(0.500912724,0.297571962,0.218176008,0.19291396,0.329506764,0.456520966,0.672476834,0.766769393,0.852478107,0.704861326,0.570437662)
train<-data.frame(input,output)

検証用データ

1
2
3
4
input<-c(0.025,0.05,0.075,0.1,0.125,0.15,0.175,0.2,0.225,0.25,0.275,0.3,0.325,0.35,0.375,0.4,0.425,0.45,0.475,0.5,0.525,0.55,0.575,0.6,0.625,0.65,0.675,0.7,0.725,0.75,0.775,0.8,0.825,0.85,0.875,0.9,0.925,0.95,0.975)
output<-c(0.45306966,0.407294902,0.36380285,0.323664424,0.287867966,0.257294902,0.232698043,0.214683045,0.203693498,0.2,0.203693498,0.214683045,0.232698043,0.257294902,0.287867966,0.323664424,0.36380285,0.407294902,0.45306966,0.5,0.54693034,0.592705098,0.63619715,0.676335576,0.712132034,0.742705098,0.767301957,0.785316955,0.796306502,0.8,0.796306502,0.785316955,0.767301957,0.742705098,0.712132034,0.676335576,0.63619715,0.592705098,0.54693034)
valid<-data.frame(input,output)
library(nnet)

中間層1個の場合

1
2
3
4
5
sin1<-nnet(output~input,data=train,size=1,maxit=1000)
yosoku1<-predict(sin1,valid,type="raw")
plot(valid,type="b",ylim=c(0,1))
points(valid$input,yosoku1,pch=16)
lines(valid$input,yosoku1)

中間層4個の場合

1
2
3
4
5
sin1<-nnet(output~input,data=train,size=4,maxit=1000)
yosoku1<-predict(sin1,valid,type="raw")
plot(valid,type="b",ylim=c(0,1))
points(valid$input,yosoku1,pch=16)
lines(valid$input,yosoku1)

中間層16個の場合

1
2
3
4
5
sin1<-nnet(output~input,data=train,size=16,maxit=1000)
yosoku1<-predict(sin1,valid,type="raw")
plot(valid,type="b",ylim=c(0,1))
points(valid$input,yosoku1,pch=16)
lines(valid$input,yosoku1)