clc;
clear all
close all
%% VMD-SSA-LSTM预测
tic
load vmd_data.mat
load lstm.mat
disp('…………………………………………………………………………………………………………………………')
disp('VMD-SSA-LSTM预测')
disp('…………………………………………………………………………………………………………………………')
%% 建立
T_sim5 =[];
T_sim6 =[];
data1 = u';
for i = 1:size(data1,2)
disp(['对第',num2str(i),'个分量进行建模'])
data2= data1(:,i);
num_samples = length(data2); % 样本个数
kim = 5; % 延时步长(kim个历史数据作为自变量)
zim = 1; % 跨zim个时间点进行预测
or_dim = size(data2,2);
res=[];
% 重构数据集
for i = 1: num_samples - kim - zim + 1
res(i, :) = [reshape(data2(i: i + kim - 1,:), 1, kim*or_dim), data2(i + kim + zim - 1,:)];
end
% 训练集和测试集划分
outdim = 1; % 最后一列为输出
num_size = 0.7; % 训练集占数据集比例
num_train_s = round(num_size * num_samples); % 训练集样本个数
f_ = size(res, 2) - outdim; % 输入特征维度
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);文章来源:https://www.toymoban.com/news/detail-688417.html
p_test = mapminmax('apply', P_test, ps_input);文章来源地址https://www.toymoban.com/news/detail-688417.html
到了这里,关于VMD-SSA-LSTM基于变分模态分解和麻雀算法优化长短期记忆网络的时间序列预测MATLAB代码(含LSTM、VMD-LSTM、VMD-SSA-LSTM等模型的对比)。的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!