多维时序 | Matlab实现TCN-LSTM时间卷积长短期记忆神经网络多变量时间序列预测
目录
- 多维时序 | Matlab实现TCN-LSTM时间卷积长短期记忆神经网络多变量时间序列预测
- 预测效果
- 基本介绍
- 程序设计
- 参考资料
预测效果
基本介绍
1.【Matlab实现TCN-LSTM时间卷积长短期记忆神经网络多变量时间序列预测;
2.运行环境为Matlab2023a及以上;
3.data为数据集,输入多个特征,输出单个变量,考虑历史特征的影响,多变量时间序列预测,main.m为主程序,运行即可,所有文件放在一个文件夹;
4.命令窗口输出R2、MSE、RMSE、MAE、MAPE、MBE等多指标评价。
程序设计
- 完整程序和数据获取方式:私信博主回复Matlab实现TCN-LSTM时间卷积长短期记忆神经网络多变量时间序列预测获取。
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
%% 划分训练集和测试集
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);
%% 相关指标计算
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
% MAPE
maep1 = sum(abs(T_sim1 - T_train)./T_train) ./ M ;
maep2 = sum(abs(T_sim2 - T_test )./T_test) ./ N ;
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
disp(['训练集数据的MAPE为:', num2str(maep1)])
disp(['测试集数据的MAPE为:', num2str(maep2)])
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
% RMSE
RMSE1 = sqrt(sumsqr(T_sim1 - T_train)/M);
RMSE2 = sqrt(sumsqr(T_sim2 - T_test)/N);
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
disp(['训练集数据的RMSE为:', num2str(RMSE1)])
disp(['测试集数据的RMSE为:', num2str(RMSE2)])
参考资料
[1] http://t.csdn.cn/pCWSp
[2] https://download.csdn.net/download/kjm13182345320/87568090?spm=1001.2014.3001.5501
[3] https://blog.csdn.net/kjm13182345320/article/details/129433463?spm=1001.2014.3001.5501