预测是指在掌握客观对象已知信息的基础上,依照一定的方法与规律对事物的未知信息进行估计与测算.预测时所使用的预测模型多种多样,各种预测模型的预测效果如何,是应用中选择预测模型的重要依据,BP神经网络预测模型,回归预测模型是最为常用的预测模型。为了实现对数据准确的预测,本文提出了基于正余弦算法优化神经网络实现数据回归预测
% INITIALIZE THE NEURAL NETWORK PROBLEM %
clc
clear all
close all
% inputs for the neural net(AND gate example== 2 inputs && 4 samples)
inputs = [0 0;0 1;1 0;1 1]';
% targets for the neural net
targets = [0;0;0;1]';
% number of neurons
n = 4;
% create a neural network
net = feedforwardnet(n);
% configure the neural network for this dataset
net = configure(net, inputs, targets);
% get the normal NN weights and bias
getwb(net)
% error MSE normal NN
error = targets - net(inputs);
calc = mean(error.^2)/mean(var(targets',1))
% create handle to the MSE_TEST function, that
% calculates MSE
h = @(x) NMSE(x, net, inputs, targets);
% PLEASE NOTE: For a feed-forward network
% with n hidden neurons, 3n+n+1 quantities are required
% in the weights and biases column vector.
% a. n for the input weights=(features*n)=2*n
% b. n for the input biases=(n bias)=n
% c. n for the output weights=(n weights)=n
% d. 1 for the output bias=(1 bias)=1
% running the sine cosine algorithm with desired options
SearchAgents_no=30; % Number of search agents
Max_iteration=1000; % Maximum numbef of iterations
[err_ga, x] = SCA(SearchAgents_no,Max_iteration,-5,5,2*n+n+n+1,h)
net = setwb(net, x);
% get the SCA optimized NN weights and bias
getwb(net)
% error MSE SCA optimized NN
error = targets - net(inputs);
calc = mean(error.^2)/mean(var(targets',1))
figure
plot(targets,'ro-')
hold on
plot(round(net(inputs)),'bs-')
legend('目标值','预测值')
[1]赵星宇. 基于广义回归神经网络的燃煤锅炉NO_x排放预测[J]. 东北电力技术, 2019(10):13-16.
[2]孔雪卉, 张慧芬. 基于优化广义回归神经网络的变电站设备温度预测[J]. 中国电力, 2016, 49(7):6.
部分理论引用网络文献,若有侵权联系博主删除。