时序预测 | MATLAB实现基于BP神经网络的时间序列预测-递归预测未来(多指标评价)
预测结果
基本介绍
Matlab实现BP神经网络时间序列预测未来(完整源码和数据)
1.Matlab实现BP神经网络时间序列预测未来;
2.运行环境Matlab2018及以上,data为数据集,单变量时间序列预测;
3.递归预测未来数据,可以控制预测未来大小的数目,适合循环性、周期性数据预测;
4.命令窗口输出R2、MAE、MAPE、MBE、MSE等评价指标;
程序设计
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
%% 数据集分析
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
参考资料
[1]
https://blog.csdn.net/kjm13182345320/article/details/129036772?spm=1001.2014.3001.5502
[2]
https://blog.csdn.net/kjm13182345320/article/details/128690229