Time series forecasting | MATLAB implements time series forecasting based on BP neural network - recursively predicting the future (multi-index evaluation)

Time series forecasting | MATLAB implements time series forecasting based on BP neural network - recursively predicting the future (multi-index evaluation)

forecast result

insert image description here

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

basic introduction

Matlab implements BP neural network time series to predict the future (complete source code and data)
1. Matlab implements BP neural network time series to predict the future;
2. The operating environment is Matlab2018 and above, data is a data set, and univariate time series forecasting;
3. Recursive forecasting For future data, you can control the number of predicted future sizes, which is suitable for cyclical and periodic data prediction;
4. The command window outputs R2, MAE, MAPE, MBE, MSE and other evaluation indicators;

programming

%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
%% 数据集分析
outdim = 1;                                  % 最后一列为输出
num_size = 0.7;                              % 训练集占数据集比例
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
%%  划分训练集和测试集
P_train = res(1: num_train_s, 1: f_)';
T_train = res(1: num_train_s, f_ + 1: end)';
M = size(P_train, 2);
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
P_test = res(num_train_s + 1: end, 1: f_)';
T_test = res(num_train_s + 1: end, f_ + 1: end)';
N = size(P_test, 2);
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
%%  数据归一化
[p_train, ps_input] = mapminmax(P_train, 0, 1);
p_test = mapminmax('apply', P_test, ps_input);
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[t_train, ps_output] = mapminmax(T_train, 0, 1);
t_test = mapminmax('apply', T_test, ps_output);
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
%%  创建网络
net = newff(p_train, t_train, 5);

%%  设置训练参数
net.trainParam.epochs = 1000;     % 迭代次数 
net.trainParam.goal = 1e-6;       % 误差阈值
net.trainParam.lr = 0.01;         % 学习率

%%  训练网络
net= train(net, p_train, t_train);
————————————————
版权声明:本文为CSDN博主「机器学习之心」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/kjm13182345320/article/details/132093256

References

[1] https://blog.csdn.net/kjm13182345320/article/details/129036772?spm=1001.2014.3001.5502
[2] https://blog.csdn.net/kjm13182345320/article/details/128690229

Guess you like

Origin blog.csdn.net/kjm13182345320/article/details/132282102