预测是指在掌握客观对象已知信息的基础上,依照一定的方法与规律对事物的未知信息进行估计与测算.预测时所使用的预测模型多种多样,各种预测模型的预测效果如何,是应用中选择预测模型的重要依据,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))