CPO-CNN-GRU-Attention、CNN-GRU-Attention、CPO-CNN-GRU、CNN-GRU四模子多
CPO-CNN-GRU-Attention、CNN-GRU-Attention、CPO-CNN-GRU、CNN-GRU四模子多变量时序预测对比预测结果
https://i-blog.csdnimg.cn/direct/593d26b189034dec9f2ace322d665198.png
https://i-blog.csdnimg.cn/direct/0bbe0bd72ed34fd0b5780a379772fa7a.png
https://i-blog.csdnimg.cn/direct/273be3d4f57a419fbf89f204a28f62e1.png
https://i-blog.csdnimg.cn/direct/738d2b54d810496192f2962c8416fcfe.png
https://i-blog.csdnimg.cn/direct/dc903bf3f73440ab843ec822e4e8a200.png
https://i-blog.csdnimg.cn/direct/747d69abea4544e084d5757b43cc9122.png
https://i-blog.csdnimg.cn/direct/01312d8f8457426587810e369b520453.png
https://i-blog.csdnimg.cn/direct/c85fce0640344c60b00dff50c339702b.png
https://i-blog.csdnimg.cn/direct/fcbdfb21bbc44e0d9aaeb6d7c0f4a3fc.png
https://i-blog.csdnimg.cn/direct/ad33a21e58634da6aaef1d0531f1b2e1.png
基本介绍
基于CPO-CNN-GRU-Attention、CNN-GRU-Attention、CPO-CNN-GRU、CNN-GRU四模子多变量时序预测一键对比(仅运行一个main即可)
Matlab代码,每个模子的预测结果和组合对比结果都有!
1.无需繁琐步骤,只需要运行一个main即可一键出所有图像。
2.程序已经调试好,无需更改代码替换数据集即可运行!!!数据格式为excel!
3.CPO优化参数为:隐藏层节点数,学习率,正则化系数
4.CPO作为24年新算法,冠豪猪优化器(Crested Porcupine Optimizer,CPO)。该结果于2024年1月发表在中科院1区SCI期刊Knowledge-Based Systems上。
运行情况要求MATLAB版本为2023b及其以上
评价指标包罗:R2、MAE、MSE、RPD、RMSE等,图许多
代码中文注释清晰,质量极高,赠送测试数据集,可以直接运行源程序。替换你的数据即可用 适合新手小白
程序计划
[*]完备代码私信复兴CPO-CNN-BiLSTM-Attention、CNN-BiLSTM-Attention、CPO-CNN-BiLSTM、CNN-BiLSTM四模子对比多变量时序预测。
%%CSDN:机器学习之心
%%清空环境变量
warning off % 关闭报警信息
close all % 关闭开启的图窗
clear % 清空变量
clc % 清空命令行
%%导入数据
result = xlsread('数据集.xlsx');
%%数据分析
num_samples = length(result);% 样本个数
kim = 2; % 延时步长(前面多行历史数据作为自变量)
zim =1; % 跨zim个时间点进行预测
nim = size(result, 2) - 1; % 原始数据的特征是数目
%%划分数据集
for i = 1: num_samples - kim - zim + 1
res(i, :) = [reshape(result(i: i + kim - 1 + zim, 1: end - 1)', 1, ...
(kim + zim) * nim), result(i + kim + zim - 1, end)];
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);
%%数据归一化
= mapminmax(P_train, -1, 1);%将训练集和测试集的数据调整到0到1之间
p_test = mapminmax('apply', P_test, ps_input);
= mapminmax(T_train, -1, 1);% 对测试集数据做归一化
t_test = mapminmax('apply', T_test, ps_output);
%%数据平铺
% 将数据平铺成1维数据只是一种处理方式
% 也可以平铺成2维数据,以及3维数据,需要修改对应模型结构
% 但是应该始终和输入层数据结构保持一致
p_train =double(reshape(p_train, f_, 1, 1, M));
p_test=double(reshape(p_test , f_, 1, 1, N));
t_train =double(t_train)';
t_test=double(t_test )';
%%数据格式转换
for i = 1 : M
Lp_train{i, 1} = p_train(:, :, 1, i);
end
for i = 1 : N
Lp_test{i, 1}= p_test( :, :, 1, i);
end
%% 建立模型
lgraph = layerGraph(); % 建立空白网络结构
tempLayers = [
sequenceInputLayer(, "Name", "sequence") % 建立输入层,输入数据结构为
sequenceFoldingLayer("Name", "seqfold")]; % 建立序列折叠层
lgraph = addLayers(lgraph, tempLayers); % 将上述网络结构加入空白结构中
tempLayers = [
convolution2dLayer(, 16, "Name", "conv_1", "Padding", "same")% 建立卷积层,卷积核大小,16个特征图
reluLayer("Name", "relu_1") % Relu 激活层
convolution2dLayer(, 32, "Name", "conv_2", "Padding", "same")% 建立卷积层,卷积核大小,32个特征图
reluLayer("Name", "relu_2")]; % Relu 激活层
lgraph = addLayers(lgraph, tempLayers); % 将上述网络结构加入空白结构中
tempLayers = [
sequenceUnfoldingLayer("Name", "sequnfold") % 建立序列反折叠层
flattenLayer("Name", "flatten") % 网络铺平层
fullyConnectedLayer(1, "Name", "fc") % 全连接层
regressionLayer("Name", "regressionoutput")]; % 回归层
参考资料
https://blog.csdn.net/kjm13182345320/article/details/128577926?spm=1001.2014.3001.5501
https://blog.csdn.net/kjm13182345320/article/details/128573597?spm=1001.2014.3001.5501
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]