组合预测 | MATLAB实现EMD-KPCA-GRU、EMD-GRU、GRU多输入单输出回归预测对比

组合预测 | MATLAB实现EMD-KPCA-GRU、EMD-GRU、GRU多输入单输出回归预测对比

预测效果

1
2
3
4
5

基本介绍

MATLAB实现EMD-KPCA-GRU、EMD-GRU、GRU多输入单输出回归预测对比

模型描述

提高光伏功率预测精度,对于保证电力系统的安全调度和稳定运行具有重要意义。提出一种经验模态分解(EMD)、核主成分分析(KPCA)和门控循环单元(GRU)相结合的光伏功率预测模型。充分考虑制约光伏输出功率的5种环境因素,首先利用EMD将环境因素序列进行分解,得到数据信号在不同时间尺度上的变化情况,降低环境因素序列的非平稳性;其次利用PCA提取特征序列的关键影响因子,消除原始序列的相关性和冗余性,降低模型输入的维度;最终利用门控循环单元(GRU)对多变量特征序列进行动态时间建模,实现对光伏发电功率的预测。EMD 的本质是由数据的特征时间尺度来获得数量不同的本征模函数(intrinsic mode function,IMF),不同的本征模分量IMF 代表不同的特征波动序列,使原始数据的波动特征在不同时间尺度下突显出来,由于环境时间序列具有一定的随机性和间断性,通过EMD 分解,可在丰富输入变量多样性的同时,根据得到的IMF 分量,突出环境序列在不同时间尺度下的局部特性,反映出原始环境序列的波动性、周期性和趋势变化。经过EMD 分解得到的数据序列充实了特征序列的数量,但是输入变量的维数也随之增多。为了在提高预测精度的同时,保持 网络模型的计算速度,同时克服过拟合的问题,需通过KPCA 对输入变量进行降维处理,在保证信息有效性和代表性的前提下,提升模型的计算效率和精度。

程序设计

  • 完整程序和数据获取方式1:同等价值程序兑换;
  • 完整程序和数据获取方式2:私信博主获取。
figure
subplot(K+1,1,1)
plot(X(:,d))
ylabel('原始')
xlim([0 L])
title(['第',num2str(d),'个特征的EMD分解'])

for i=2:K+1
    subplot(K+1,1,i)
    plot(u_0(i-1,:))
    xlim([0 L])
    ylabel(['IMF',num2str(i-1)])
end
ylabel('res')

u=[u;u_0 ];
%  参数设置
options = trainingOptions('adam', ...                 % 优化算法Adam
    'MaxEpochs', 100, ...                            % 最大训练次数
    'MiniBatchSize',25,...
    'GradientThreshold', 1, ...                       % 梯度阈值
    'InitialLearnRate', 0.01, ...                    % 初始学习率
    'LearnRateSchedule', 'piecewise', ...             % 学习率调整
    'LearnRateDropPeriod', 70, ...                   % 训练60次后开始调整学习率
    'LearnRateDropFactor',0.2, ...                    % 学习率调整因子
    'L2Regularization', 0.001, ...                    % 正则化参数
    'ExecutionEnvironment', 'cpu',...                 % 训练环境
    'Verbose', 0, ...                                 % 关闭优化过程
    'Plots', 'training-progress');                    % 画出曲线

%  训练
net = trainNetwork(vp_train, vt_train, layers, options);
%analyzeNetwork(net);% 查看网络结构
%  预测
t_sim1 = predict(net, vp_train); 
t_sim2 = predict(net, vp_test); 

%  数据反归一化
T_sim1 = mapminmax('reverse', t_sim1, ps_output);
T_sim2 = mapminmax('reverse', t_sim2, ps_output);
T_train1 = T_train;
T_test2 = T_test;

%  数据格式转换
T_sim1 = cell2mat(T_sim1);% cell2mat将cell元胞数组转换为普通数组
T_sim2 = cell2mat(T_sim2);

% 指标计算
disp('训练集误差指标')
[mae1,rmse1,mape1,r1,error1]=calc_error(T_train1,T_sim1');
fprintf('\n')

disp('测试集误差指标')
[mae2,rmse2,mape2,r2,error2]=calc_error(T_test2,T_sim2');
fprintf('\n')
toc
%   Options
%
%
%  stopping criterion options:
%
% STOP: vector of stopping parameters [THRESHOLD,THRESHOLD2,TOLERANCE]
% if the input vector's length is less than 3, only the first parameters are
% set, the remaining ones taking default values.
% default: [0.05,0.5,0.05]
%
% FIX (int): disable the default stopping criterion and do exactly <FIX> 
% number of sifting iterations for each mode
%
% FIX_H (int): disable the default stopping criterion and do <FIX_H> sifting 
% iterations with |#zeros-#extrema|<=1 to stop [4]
%
%  bivariate/complex EMD options:
%
% COMPLEX_VERSION: selects the algorithm used for complex EMD ([3])
% COMPLEX_VERSION = 1: "algorithm 1"
% COMPLEX_VERSION = 2: "algorithm 2" (default)
% 
% NDIRS: number of directions in which envelopes are computed (default 4)
% rem: the actual number of directions (according to [3]) is 2*NDIRS
% 
%  other options:
%
% T: sampling times (line vector) (default: 1:length(x))
%
% MAXITERATIONS: maximum number of sifting iterations for the computation of each
% mode (default: 2000)
%
% MAXMODES: maximum number of imfs extracted (default: Inf)
%
% DISPLAY: if equals to 1 shows sifting steps with pause
% if equals to 2 shows sifting steps without pause (movie style)
% rem: display is disabled when the input is complex
%
% INTERP: interpolation scheme: 'linear', 'cubic', 'pchip' or 'spline' (default)
% see interp1 documentation for details
%
% MASK: masking signal used to improve the decomposition according to [5]
%
%
%   Examples
%
%
%X = rand(1,512);
%
%IMF = emd(X);
%
%IMF = emd(X,'STOP',[0.1,0.5,0.05],'MAXITERATIONS',100);
%
%T=linspace(0,20,1e3);
%X = 2*exp(i*T)+exp(3*i*T)+.5*T;
%IMF = emd(X,'T',T);
%
%OPTIONS.DISLPAY = 1;
%OPTIONS.FIX = 10;
%OPTIONS.MAXMODES = 3;
%[IMF,ORT,NBITS] = emd(X,OPTIONS);

参考资料

[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

猜你喜欢

转载自blog.csdn.net/kjm13182345320/article/details/129659229