时序预测 | MATLAB实现基于PSO-BiGRU、BiGRU时间序列预测对比

时序预测 | MATLAB实现基于PSO-BiGRU、BiGRU时间序列预测对比

目录

效果一览






基本描述

1.时序预测 | MATLAB实现基于PSO-BiGRU、BiGRU时间序列预测;

2.单变量时间序列数据集;

3.运行环境Matlab2020及以上,依次运行Main1GRUTS、Main2PSOBiGRUTS、Main3CDM即可,其余为函数文件无需运行,所有程序放在一个文件夹,data为数据集,单变量时间序列;

BiGRU(双向门控循环单元模型)与粒子群算法优化后的BiGRU(PSOBiGRU)对比实验,可用于风电、光伏等负荷预测,时序预测,数据为单变量时间序列数据集,PSO优化超参数为隐含层1节点数、隐含层2节点数、最大迭代次数和学习率。

4.命令窗口输出MAE、MAPE、RMSE和R2。

程序设计

  • 完整程序和数据下载:私信博主回复MATLAB实现基于PSO-BiGRU、BiGRU时间序列预测对比
clike 复制代码
Function_name='F1'; % Name of the test function that can be from F1 to F23 (Table 1,2,3 in the paper) 设定适应度函数
[lb,ub,dim,fobj]=Get_Functions_details(Function_name);  %设定边界以及优化函数

N=20;
M=1000;
[xm1,trace1]=pso(N,M,dim,lb,ub,fobj);
[xm2,trace2]=qpso(N,M,dim,lb,ub,fobj);

figure('Position',[269   240   660   290])
%Draw search space
subplot(1,2,1);
func_plot(Function_name);
title('Parameter space')
xlabel('x_1');
ylabel('x_2');
zlabel([Function_name,'( x_1 , x_2 )'])

%Draw objective space
subplot(1,2,2);
plot(trace1,'Color','b','linewidth',1.5)
hold on
plot(trace2,'Color','r','linewidth',1.5)
title('Objective space')
xlabel('Iteration');
ylabel('Best score obtained so far');

axis tight
grid on
box on
legend('PSO','QPSO')

%% 取对数 更方便看
figure
plot(log10(trace1),'linewidth',1.5)
hold on
plot(log10(trace2),'linewidth',1.5)
legend('PSO','QPSO')
title('PSO VS QPSO')
xlabel('iteration/M')
ylabel('fitness value(log10)')
function func_plot(func_name)

[lb,ub,dim,fobj]=Get_Functions_details(func_name);

switch func_name 
    case 'F1' 
        x=-100:2:100; y=x; %[-100,100]
        
    case 'F2' 
        x=-100:2:100; y=x; %[-10,10]
        
    case 'F3' 
        x=-100:2:100; y=x; %[-100,100]
        
    case 'F4' 
        x=-100:2:100; y=x; %[-100,100]
    case 'F5' 
        x=-200:2:200; y=x; %[-5,5]
    case 'F6' 
        x=-100:2:100; y=x; %[-100,100]
    case 'F7' 
        x=-1:0.03:1;  y=x  %[-1,1]
    case 'F8' 
        x=-500:10:500;y=x; %[-500,500]
    case 'F9' 
        x=-5:0.1:5;   y=x; %[-5,5]    
    case 'F10' 
        x=-20:0.5:20; y=x;%[-500,500]
    case 'F11' 
        x=-500:10:500; y=x;%[-0.5,0.5]
    case 'F12' 
        x=-10:0.1:10; y=x;%[-pi,pi]
    case 'F13' 
        x=-5:0.08:5; y=x;%[-3,1]
    case 'F14' 
        x=-100:2:100; y=x;%[-100,100]
    case 'F15' 
        x=-5:0.1:5; y=x;%[-5,5]
    case 'F16' 
        x=-1:0.01:1; y=x;%[-5,5]
    case 'F17' 
        x=-5:0.1:5; y=x;%[-5,5]
    case 'F18' 
        x=-5:0.06:5; y=x;%[-5,5]
    case 'F19' 
        x=-5:0.1:5; y=x;%[-5,5]
    case 'F20' 
        x=-5:0.1:5; y=x;%[-5,5]        
    case 'F21' 
        x=-5:0.1:5; y=x;%[-5,5]
    case 'F22' 
        x=-5:0.1:5; y=x;%[-5,5]     
    case 'F23' 
        x=-5:0.1:5; y=x;%[-5,5]  
end    

    

L=length(x);
f=[];

for i=1:L
    for j=1:L
        if strcmp(func_name,'F15')==0 && strcmp(func_name,'F19')==0 && strcmp(func_name,'F20')==0 && strcmp(func_name,'F21')==0 && strcmp(func_name,'F22')==0 && strcmp(func_name,'F23')==0
            f(i,j)=fobj([x(i),y(j)]);
        end
        if strcmp(func_name,'F15')==1
            f(i,j)=fobj([x(i),y(j),0,0]);
        end
        if strcmp(func_name,'F19')==1
            f(i,j)=fobj([x(i),y(j),0]);
        end
        if strcmp(func_name,'F20')==1
            f(i,j)=fobj([x(i),y(j),0,0,0,0]);
        end       
        if strcmp(func_name,'F21')==1 || strcmp(func_name,'F22')==1 ||strcmp(func_name,'F23')==1
            f(i,j)=fobj([x(i),y(j),0,0]);
        end          
    end
end

参考资料

[1] https://blog.csdn.net/kjm13182345320/article/details/127596777?spm=1001.2014.3001.5501

[2] https://download.csdn.net/download/kjm13182345320/86830096?spm=1001.2014.3001.5501

相关推荐
随风飘摇的土木狗4 个月前
【MATLAB第97期】基于MATLAB的贝叶斯Bayes算法优化BiGRU双向门控循环单元的多输入单输出回归预测模型,含GRU与BiGRU多层结构优化选择
matlab·贝叶斯·双向门控循环单元·gru·回归预测·bigru·长短期记忆网络
Eastmount5 个月前
[当人工智能遇上安全] 11.威胁情报实体识别 (2)基于BiGRU-CRF的中文实体识别万字详解
人工智能·python·bigru·威胁情报·实体识别
预测及优化5 个月前
锦上添花!特征选择+深度学习:mRMR-CNN-BiGRU-Attention故障识别模型!特征按重要性排序!最大相关最小冗余!
人工智能·深度学习·cnn·bigru·特征选择·最大相关最小冗余·特征降维
机器学习之心6 个月前
时序预测 | MATLAB实现ICEEMDAN-SSA-GRU、ICEEMDAN-GRU、SSA-GRU、GRU时间序列预测对比
时间序列预测对比·iceemdan·ssa-gru·iceemdan-gru
神经网络机器学习智能算法画图绘图6 个月前
基于LSTM的负荷预测,基于BILSTM的负荷预测,基于GRU的负荷预测,基于BIGRU的负荷预测,基于BP神经网络的负荷预测
神经网络·gru·lstm·bp·bilstm·负荷预测·bigru
机器学习之心10 个月前
时序预测 | MATLAB实现TCN-BiGRU时间卷积双向门控循环单元时间序列预测
tcn-bigru·时间卷积双向门控循环单元·时间序列预测·bigru·tcn
机器学习之心1 年前
分类预测 | MATLAB实现BO-BiGRU贝叶斯优化双向门控循环单元多输入分类预测
双向门控循环单元·贝叶斯优化·多输入分类预测·bo-bigru·bigru