Transformer-LSTM预测 | Matlab实现Transformer-LSTM时间序列预测


目录
  • Transformer-LSTM预测 | Matlab实现Transformer-LSTM时间序列预测
  • 效果一览
  • 基本介绍
  • 程序设计
  • 参考资料


效果一览

Transformer-LSTM预测 | Matlab实现Transformer-LSTM时间序列预测_transformer


Transformer-LSTM预测 | Matlab实现Transformer-LSTM时间序列预测_matlab_02

Transformer-LSTM预测 | Matlab实现Transformer-LSTM时间序列预测_matlab_03


Transformer-LSTM预测 | Matlab实现Transformer-LSTM时间序列预测_matlab_04


Transformer-LSTM预测 | Matlab实现Transformer-LSTM时间序列预测_transformer_05


Transformer-LSTM预测 | Matlab实现Transformer-LSTM时间序列预测_matlab_06


Transformer-LSTM预测 | Matlab实现Transformer-LSTM时间序列预测_lstm_07


Transformer-LSTM预测 | Matlab实现Transformer-LSTM时间序列预测_时间序列_08

基本介绍

1.Matlab实现Transformer-LSTM时间序列预测,Transformer-LSTM;

2.运行环境为Matlab2023b及以上;

3.data为数据集,输入输出单个变量,一维时间序列预测,main.m为主程序,运行即可,所有文件放在一个文件夹;

4.命令窗口输出R2、MSE、RMSE、MAE、MAPE、MBE等多指标评价;

Transformer-LSTM预测 | Matlab实现Transformer-LSTM时间序列预测_时间序列_09

程序设计
  • 完整程序和数据下载私信博主回复Matlab实现Transformer-LSTM时间序列预测
%%  清空环境变量
warning off             % 关闭报警信息
close all               % 关闭开启的图窗
clear                   % 清空变量
clc                     % 清空命令行

%%  导入数据



%%  划分训练集和测试集
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);

%%  数据平铺
P_train =  double(reshape(P_train, f_, 1, 1, M));
P_test  =  double(reshape(P_test , f_, 1, 1, N));

t_train = t_train';
t_test  = t_test' ;

%%  数据格式转换
for i = 1 : M
    p_train{i, 1} = P_train(:, :, 1, i);
end

for i = 1 : N
    p_test{i, 1}  = P_test( :, :, 1, i);
end
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.