资源预览内容
第1页 / 共8页
第2页 / 共8页
第3页 / 共8页
第4页 / 共8页
第5页 / 共8页
第6页 / 共8页
第7页 / 共8页
第8页 / 共8页
亲,该文档总共8页全部预览完了,如果喜欢就下载吧!
资源描述
用用 BP 神经网络进行预测神经网络进行预测用用 BP 神经网络进行预测神经网络进行预测班级:信计班级:信计 071 姓名:郭怡志姓名:郭怡志 学号学号 0710820104用用 BP 神经网络进行股票预测神经网络进行股票预测1、目的:掌握、目的:掌握 BP 神经网络算法及其神经网络算法及其 Matlab 环境下编程实现环境下编程实现2、题目:用、题目:用 BP 神经网络对附表神经网络对附表 3.1 的训练数据,预测附表的训练数据,预测附表 3.2 中数据的收盘价中数据的收盘价3、设计过程:用、设计过程:用“571”BP 神经网络进行训练和预测神经网络进行训练和预测4、Matlab 源程序如下:源程序如下:P= 12.4912.4912.2112.2213607255167520944; 12.2212.7212.1812.6629082744363202560; 12.5812.7412.4512.4622802103286893924; 12.4212.5612.2612.3 15584448193329056; 12.2612.6812.2612.6719746980246494080; 12.8212.9712.5512.7827583354351219296; 12.7713.4212.6613.3643462230570755526;13.0113.37 13.0113.1931144350 410931872; 13.1613.5913.1413.4323668448316467424; 13.4913.5 13.1213.1919269676255614928; 13.1913.7213.0213.6 36358424487460544; 13.6 13.7313.5113.6223845804324467584; 13.6213.7112.9512.9922462342299506784; 12.9913.1212.7512.8920363860263010736; 12.7 12.8312.2 12.5317330308217278656; 12.4 12.5712.3112.417140875 88986592; 12.4912.5512 12.0410509253128913712; 12.0912.2511.9712.017511755 90902304; 12.0212.1811.9612.157514297 90803536; 12.1 12.3212.0312.147283098 88802800;12.1 12.15 11.58 11.7111352825 133326640; 11.7311.9211.5711.597573305 89033640; 11.6711.9 11.2111.8910277141119762592;11.76 11.89 11.61 11.73 11368580 133410400; 11.4412.6511.3612.1135556024430798464; 12.0912.2911.6711.9313918940166163120; 11.9312.0211.7511.8710202644121107256; 12 12.0211.7911.9 8337176 98893768; 11.9 11.9611.8211.896640187 78795592; 11.9111.9511.8411.936213950 73982808; 11.9 12.2 11.8511.9810342758124693128;用用 BP 神经网络进行预测神经网络进行预测用用 BP 神经网络进行预测神经网络进行预测11.9812.0211.7111.966952637 82441696; 11.8512.2 11.8112.199931446 119920744; 12.1912.4912.1512.4116455316203530048; 12.38 12.55 12.27 12.34 11542922 143000448; 12.3412.7712.3212.6617138950216009424; 12.6712.7112.4212.5914056620176113952; 12.6 12.6312.4512.6211645531146168336; 12.6 12.9712.2212.2821390096270573504; 12.2812.6412.2412.4414494819180426080; 12.4712.5212.3 12.3710144725125570008; 12.3 12.3512.0512.269879639 120649136; 12.2512.3612 12.049657725 117189536; 12.1 12.1611.8711.967706144 92401216; 12 12.0411.7811.798360817 99209584; 11.7811.8711.2911.4519292420221751744; 11.4911.5411.3 11.537994094 91515968; 11.5511.7811.4811.7712833044149231184; 11.7611.8311.6611.728246960 96896400; 11.7611.8511.6411.816818095 80201072; 11.8 11.9111.7511.876776051 80297552; 11.8511.8911.6211.787782495 91447728; 11.8211.8311.6611.696816861 79911968; 11.6911.6911.4511.467720525 88956312; 11.4711.6911.4511.635151524 59730096; 11.6911.8911.6911.8 13983169165247696; 11.8 11.8811.7611.8311766064 138909840 ; for i=1:5P(i,:)=(p(i,:)-min(p(i,:)/(max(p(i,:)-min(p(i,:); endt= 12.66 12.46 12.3 12.67 12.78 13.36 13.19 13.43 13.19 13.6 13.62 12.9912.89 12.53 12.41 12.04 12.01 12.15 12.14 11.71 11.59 11.89 11.73 12.11 11.9311.87 11.9 11.89 11.93 11.98 11.96 12.19 12.41 12.34 12.66 12.59 12.62 12.2812.44 12.37 12.26 12.04 11.96 11.79 11.45 11.53 11.77 11.72 11.81 11.87 11.78用用 BP 神经网络进行预测神经网络进行预测用用 BP 神经网络进行预测神经网络进行预测11.69 11.4611.63 11.811.83 11.82;for i=1:57T(1,i)=(t(1,i)-min(t)/(max(t)-min(t); end threshold=0 1;0 1;0 1;0 1;0 1; net=newff(threshold,7,1,tansig,logsig,trainlm); net=train(net,P,T); y_test=sim(net,P) Y_test=y_test*(max(t)-min(t)+min(t); Y_test P_test= 11.75 11.8511.7 11.8218916234223018080 11.84 11.9711.7911.9625926092307388896 11.97 11.9811.8311.9317332436206247184 11.911.9 11.7511.8 16090465190226112 11.76 11.9911.7511.9 25872632307294816 11.89 11.9311.7711.8422329792264373664 11.86 11.8911.6411.6719268084226253664 11.71 11.8811.5811.8322292468262448816 11.83 12 11.8 11.9933137402394032864 11.94 11.9411.6 11.7419153084226116128 11.74 11.7711.5411.6 12339411 143391136 11.55 11.5510.9110.9419457130218281936 10.97 11.0910.7410.9111189915 121600920 10.94 11.0810.8211 12121000132738072 1111 10.7610.8313177050142735072 10.81 10.9110.5610.6710931088117223056 11.84 11.8611.6611.718286360 97152416 ; for i=1:5P_test(i,:)=(p_test(i,:)-min(p_test(i,:)/(max(p_test(i,:)-min(p_test(i,:); end format long ; y=sim(net,P_test) Y=y*(max(t)-min(t)+min(t); Y figure; plot(1:57,t,k*);title(预测误差()); hold on; plot(1:57,Y_test,bo);title(预测误差()); hold off;用用 BP 神经网络进行预测神经网络进行预测用用 BP 神经网络进行预测神经网络进行预测W= 11.82 11.96 11.93 11.811.9 11.84 11.67 11.83 11.9911.74 11.6 10.94 10.91 1110.83 10.67 11.71 ;figure; plot(1:17,W,k*);title(预测误差()); hold on; plot(1:17,Y,bo);title(预测误差()); hold off;BP 神经网络训练运行结果如图 31:010203040506070809010010-410-310-210-1100 EpochsTraining-BluePerformance is 0.000446608, Goal is 0图 31 BP 神经网络训练效果用用 BP 神经网络进行预测神经网络进行预测用用 BP 神经网络进行预测神经网络进行预测BP 神经网络对训练样本的预测结果与实际结果比较见图 32:01020304050601111.51212.51313.514差 差 差 差 差 差 差图 32 BP 神经网络对训练样本的预测误差 *代表实际值代表实际值 o 代表预测值代表预测值由图 32 可以看出,BP 神经网络对训练样本的预测精度很高,
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号