当前位置:网站首页>Mathematical modeling for war preparation 34-bp neural network prediction 2
Mathematical modeling for war preparation 34-bp neural network prediction 2
2022-06-30 16:41:00 【nuist__ NJUPT】
Catalog
One 、 Prediction of octane number
1- Topic analysis and principle introduction
2- Neural network building process
3- Analysis of prediction results
BP Neural network model , Include input layer , The hidden layer and the output layer , The forward propagation process is through the input samples to the input layer , Through the input layer, the hidden layer passes through each layer , Finally, it reaches the output layer ; If the output value of the output layer does not match the output of the expected value , And then the error propagates back , Correct the weight of each unit , When the error of the network output reaches an acceptable level or the preset number of learning times is reached . I won't introduce the theory part this time , Look directly at the example , Need to learn the theory part , You can see my last neural network blog .
One 、 Prediction of octane number
1- Topic analysis and principle introduction
Let's take a look at this example 1, about 50 Group data , We think of it as a large sample , It can be considered to establish a neural network model for prediction , Because octane number is the object of prediction , We use absorbance as input , Octane number as output .
Using neural networks to predict , We need to know three nouns : Training set , Verification set , Test set , The details are as follows , We choose 70% As a training set , The remaining 30% As validation set and test set respectively .

About just starting to use Matlab Writing neural networks appears Input data size does not match net.inputs{1}.size problem , Because the input and output dimensions of training data are inconsistent , Make sure that the number of input columns is equal to the number of output columns .
2- Neural network building process
Take absorbance as input , Octane number as output , Building neural networks , The number of hidden layer neurons is 7 individual , The number of neurons in the output layer is 1 individual , As follows :

50 Group data , front 40 Group as training set , Back 10 Group as test set , Training set training model , Test set for generalization capability evaluation , We calculate root mean square error and mean error . Finally, 10 Group data for prediction .
Train the network , Then make predictions ,MATLAB Code and the future 10 The forecast results for the year are as follows :
clear; clc
load data_Octane.mat
%% First step Reading data
input=X; % Load input data
output=Y; % Load output data
%% The second step Set training data and prediction data
input_train = input(1:40,:)';
output_train =output(1:40,:)';
input_test = input(41:50,:)';
output_test =output(41:50,:)';
input_10 = new_X(1:10,:)' ;
output_10 = zeros(10,1)' ;
% Number of nodes
inputnum=2; % Enter the number of layer nodes
hiddennum=7;% Number of hidden layer nodes
outputnum=1; % Number of output layer nodes
%% The third book Training sample data normalization
[inputn,inputps]=mapminmax(input_train);% Normalize to [-1,1] Between ,inputps To do the same normalization next time
[outputn,outputps]=mapminmax(output_train);
%% Step four structure BP neural network
net=newff(inputn,outputn,hiddennum,{'tansig','purelin'},'trainlm');% Build a model , The transfer function uses purelin, The gradient descent method is used to train
W1= net. iw{1, 1};% Input the weight from layer to middle layer
B1 = net.b{1};% Threshold of neurons in the middle layer
W2 = net.lw{2,1};% The weight from the middle layer to the output layer
B2 = net. b{2};% The threshold of each neuron in the output layer
%% Step five Network parameter configuration ( Training times , Learning rate , Minimum error of training target, etc )
net.trainParam.epochs=1000; % Training times , I'm going to set it to 1000 Time
net.trainParam.lr=0.01; % Learning rate , I'm going to set it to 0.01
net.trainParam.goal=0.00001; % The minimum error of training target , I'm going to set it to 0.00001
%% Step six BP Neural network training
net=train(net,inputn,outputn);% Start training , among inputn,outputn Input and output samples respectively
%% Step seven Test sample normalization
inputn_test=mapminmax('apply',input_test,inputps);% Normalize the sample data
inputn_10 = mapminmax('apply',input_10,inputps);
%% Step eight BP Neural networks predict
an=sim(net,inputn_test); % Use the trained model for simulation
an1 = sim(net,inputn_10) ;% Last 10 Group prediction
%% Step nine Inverse normalization of prediction results and error calculation
test_simu=mapminmax('reverse',an,outputps); % Restore the simulated data to the original order of magnitude
output_10 = mapminmax('reverse',an1,outputps);
error=test_simu-output_test; % The error between the predicted value and the real value
%% Step 10 Comparison of error between real value and predicted value
figure(1);
plot(output_test,'bo-')
hold on
plot(test_simu,'r*-')
hold on
plot(error,'square','MarkerFaceColor','b')
legend(' Expectations ',' Predictive value ',' error ')
xlabel(' Number of data groups ')
ylabel(' Sample value ')
title('BP Comparison between predicted value and actual value of neural network test set ')
[c,l]=size(output_test);
MAE1=sum(abs(error))/l;
MSE1=error*error'/l;
RMSE1=MSE1^(1/2);
disp(['----------------------- Error calculation --------------------------']);
disp([' The number of hidden layer nodes is ',num2str(hiddennum),' The error results are as follows :']);
disp([' Mean absolute error MAE by :',num2str(MAE1)]);
disp([' Mean square error MSE by : ',num2str(MSE1)]);
disp([' Root mean square error RMSE by : ',num2str(RMSE1)]);
disp(' Last 10 The predicted result of group octane is :') ;
disp(output_10) ;
figure(2);
plot(51:60,output_10,'o-') ;
xlabel(' sample ID');
ylabel(' Octane predicted value ') ;3- Analysis of prediction results
Let's take a look at the comparison between the predicted value and the real value of the test set , It can be found that the error is very small , Almost close to 0, It can be considered that the model training is better .

Then let's take a look at , Last 10 Prediction results of group octane number , As follows :


Let's look at the mean square error and mean error of the prediction , As follows :

Let's take a look at the training set 、 Verification set 、 The change of mean square error of test set and population with training times , Basically, validation sets and test sets 5 It converges every time , Training set Essentials 6 More than once .

Regress the fitting value to the true value , The higher the goodness of fit , It shows that the better the fitting effect , We can see that the goodness of fit of the set is close to 1 Of .

边栏推荐
- Compulsory national standard for electronic cigarette GB 41700-2022 issued and implemented on October 1, 2022
- 备战数学建模35-时间序列预测模型
- 【活动报名】探秘元宇宙,就差你了!7月2号我在深圳现场等你!
- 云和恩墨中标天津滨海农村商业银行2022-2023年度Oracle维保项目
- Policy Center > Malware > Malware
- 2022蓝桥杯国赛B组-费用报销-(线性dp|状态dp)
- 药品管理系统加数据库,一夜做完,加报告
- 猎头5万挖我去VC
- [CVE-2019-0193] - Apache Solr DataImport 远程命令执行分析
- 深入分析GadgetInspector核心代码
猜你喜欢

猎头5万挖我去VC

搬运两个负载均衡的笔记,日后省的找

'<', hexadecimal value 0x3C, is an invalid 问题解决

【牛客网刷题系列 之 Verilog快速入门】~ 位拆分与运算
![[bjdctf2020]the mystery of ip|[ciscn2019 southeast China division]web11|ssti injection](/img/c2/d6760826b81589781574aebff61f9a.png)
[bjdctf2020]the mystery of ip|[ciscn2019 southeast China division]web11|ssti injection

BC1.2 PD协议

Hologres共享集群助力淘宝订阅极致精细化运营

【Unity UGUI】ScrollRect 动态缩放格子大小,自动定位到中间的格子

Finally understand science! 200 pictures to appreciate the peak of human wisdom

Cloud XR, how to help industrial upgrading
随机推荐
大学生研究生毕业找工作,该选择哪个方向?
Yunhe enmo won the bid for Oracle maintenance project of Tianjin Binhai rural commercial bank in 2022-2023
The new tea drinks are "dead and alive", but the suppliers are "full of pots and bowls"?
go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)
Symantec electronic sprint technology innovation board: Tan Jian, the actual controller, is an American who plans to raise 620million yuan
Hundreds of lines of code to implement a JSON parser
jspreadsheet/CE JExcel数据字段比给的字段(columns)多会导致空白列的问题解决方案
How cloudxr promotes the future development of XR
为了使远程工作不受影响,我写了一个内部的聊天室 | 社区征文
In depth analysis of the core code of the gadgetinspector
mysql主从配置
招标公告:天津市住房公积金管理中心数据库一体机及数据库软件项目(预算645万)
360数科、蚂蚁集团等入选中国信通院“业务安全推进计划”成员单位
Explain in detail the use of for loop, break and continue in go language
Open source STM32 USB-CAN project
mysql8报错:ERROR 1410 (42000): You are not allowed to create a user with GRANT解决办法
Halcon knowledge: matrix topic [02]
Mysql8.0 method and steps for enabling remote connection permission
dart:字符串replace相关的方法解决替换字符
flink sql cdc 同步sqlserver 报错什么原因啊
