【GRU时序预测】基于贝叶斯网络优化门控循环单元BO-GRU实现时间序列数据预测附matlab代码

简介: 【GRU时序预测】基于贝叶斯网络优化门控循环单元BO-GRU实现时间序列数据预测附matlab代码

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法  神经网络预测雷达通信 无线传感器

信号处理图像处理路径规划元胞自动机无人机 电力系统

⛄ 内容介绍

石油是世界经济政治发展不能缺少的重要能源之一,它在世界经济发展中产生了重要的影响。减少其负面影响的办法就是了解并掌握石油价格的变化,因此目前全球热衷于的话题就是石油价格。石油价格被种种因素影响,包括供需、经济、国际政治、军事、外交等。由于石油价格的不确定性、复杂非线性、多种影响因素,非数值型的信息,数值型信息的数据噪声也十分大。由于传统石油价格预测方法不可依靠或预测结果精度较低。故此,学术和工业界研究者的目标就是找到一种预测模型,使其研究精度相对较高、性能等各方面均相对较好,同时还可以广泛使用。基于贝叶斯网络优化门控循环单元BO-GRU实现时间序列数据预测附matlab代码。

⛄ 部分代码

%% Mackey Glass Time Series Prediction Using Least Mean Square (LMS)

% Author: SHUJAAT KHAN

clc

clear all

close all


%% Loading Time series data

% I generated a series y(t) for t = 0,1, . . . ,3000, using

% mackey glass series equation with the following configurations:

% b = 0.1, a = 0.2, Tau = 20, and the initial conditions y(t - Tau) = 0.

load Dataset\Data.mat

time_steps=2;

teacher_forcing=1; % recurrent ARMA modelling with forced desired input after defined time steps

%% Training and Testing datasets

% For training

Tr=Data(100:2500,1);    % Selecting a Interval of series data t = 100~2500

Yr(Tr)=Data(Tr,2);      % Selecting a chuck of series data y(t)

% For testing

Ts=Data(2500:3000,1);   % Selecting a Interval of series data t = 2500~3000

Ys(Ts)=Data(Ts,2);      % Selecting a chuck of series data y(t)


%% LMS Parameters


eta=5e-3;       % Learning rate

M=1;            % Order of LMS filter


U=zeros(M+1,1); % Initial values of taps

W=zeros(M+1,1); % Initial weight of LMS


MSE=[];         % Initial mean squared error (MSE)


%% Learning weights of LMS (Training)

tic % start

for t=Tr(1):Tr(end)-time_steps

   U(1:end-1)=U(2:end);    % Shifting of tap window

   

   if (teacher_forcing==1)

       if rem(t,time_steps)==0 || (t==Tr(1))

           U(end)=Yr(t);           % Input (past/current samples)

       else

           U(end)=Yp(t-1);          % Input (past/current samples)          

       end

   else

       U(end)=Yr(t);           % Input (past/current samples)

   end

 

   Yp(t)=W'*U;                         % Predicted output

   e(t)=Yr(t+time_steps)-Yp(t);        % Error in predicted output


   W=W+eta*e(t)*U;     % Weight update rule of LMS

   

   E(t)=e(t).^2;   % Current mean squared error (MSE)

end

training_time=toc; % total time including training and calculation of MSE


%% Prediction of a next outcome of series using previous samples (Testing)

tic % start

U=U*0;  % Reinitialization of taps (optional)

for t=Ts(1):Ts(end)-time_steps+1

   U(1:end-1)=U(2:end);    % Shifting of tap window


   if (teacher_forcing==1)

       if rem(t,time_steps)==0 || (t==Ts(1))

           U(end)=Ys(t);           % Input (past/current samples)

       else

           U(end)=Yp(t-1);          % Input (past/current samples)          

       end

   else

       U(end)=Ys(t);           % Input (past/current samples)

   end

   

   

   Yp(t)=W'*U;             % Calculating output (future value)

   e(t)=Ys(t+time_steps-1)-Yp(t);        % Error in predicted output


   E(t)=e(t).^2;   % Current mean squared error (MSE)

end

testing_time=toc; % total time including testing and calculation of MSE


%% Results

figure(1)

plot(Tr,10*log10(E(Tr)));   % MSE curve

hold on

plot(Ts(1:end-time_steps+1),10*log10(E(Ts(1:end-time_steps+1))),'r');   % MSE curve

grid minor


title('Cost Function');

xlabel('Iterations (samples)');

ylabel('Mean Squared Error (MSE)');

legend('Training Phase','Test Phase');


figure(2)

plot(Tr(2*M:end),Yr(Tr(2*M:end)));      % Actual values of mackey glass series

hold on

plot(Tr(2*M:end),Yp(Tr(2*M:end))','r')   % Predicted values during training

plot(Ts,Ys(Ts),'--b');        % Actual unseen data

plot(Ts(1:end-time_steps+1),Yp(Ts(1:end-time_steps+1))','--r');  % Predicted values of mackey glass series (testing)

xlabel('Time: t');

ylabel('Output: Y(t)');

title('Mackey Glass Time Series Prediction Using Least Mean Square (LMS)')

ylim([min(Ys)-0.5, max(Ys)+0.5])

legend('Training Phase (desired)','Training Phase (predicted)','Test Phase (desired)','Test Phase (predicted)');


mitr=10*log10(mean(E(Tr)));  % Minimum MSE of training

mits=10*log10(mean(E(Ts(1:end-time_steps+1))));  % Minimum MSE of testing


display(sprintf('Total training time is %.5f, \nTotal testing time is %.5f \nMSE value during training %.3f (dB),\nMSE value during testing %.3f (dB)', ...

training_time,testing_time,mitr,mits));

⛄ 运行结果

⛄ 参考文献

[1]周洁超. 基于贝叶斯网络的时间序列预测[D]. 大连海事大学, 2016.

⛄ 完整代码

❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料


相关文章
|
8月前
|
存储 传感器 分布式计算
针对大尺度L1范数优化问题的MATLAB工具箱推荐与实现
针对大尺度L1范数优化问题的MATLAB工具箱推荐与实现
|
8月前
|
机器学习/深度学习 供应链 算法
【电动车】基于削峰填谷的电动汽车多目标优化调度策略研究(Matlab代码实现)
【电动车】基于削峰填谷的电动汽车多目标优化调度策略研究(Matlab代码实现)
291 0
|
8月前
|
机器学习/深度学习 算法 机器人
【水下图像增强融合算法】基于融合的水下图像与视频增强研究(Matlab代码实现)
【水下图像增强融合算法】基于融合的水下图像与视频增强研究(Matlab代码实现)
734 0
|
8月前
|
算法 定位技术 计算机视觉
【水下图像增强】基于波长补偿与去雾的水下图像增强研究(Matlab代码实现)
【水下图像增强】基于波长补偿与去雾的水下图像增强研究(Matlab代码实现)
1002 0
|
8月前
|
算法 机器人 计算机视觉
【图像处理】水下图像增强的颜色平衡与融合技术研究(Matlab代码实现)
【图像处理】水下图像增强的颜色平衡与融合技术研究(Matlab代码实现)
260 0
|
8月前
|
新能源 Java Go
【EI复现】参与调峰的储能系统配置方案及经济性分析(Matlab代码实现)
【EI复现】参与调峰的储能系统配置方案及经济性分析(Matlab代码实现)
267 0
|
8月前
|
机器学习/深度学习 算法 机器人
使用哈里斯角Harris和SIFT算法来实现局部特征匹配(Matlab代码实现)
使用哈里斯角Harris和SIFT算法来实现局部特征匹配(Matlab代码实现)
360 8
|
8月前
|
机器学习/深度学习 编解码 算法
基于OFDM技术的水下声学通信多径信道图像传输研究(Matlab代码实现)
基于OFDM技术的水下声学通信多径信道图像传输研究(Matlab代码实现)
359 8
|
8月前
|
机器学习/深度学习 数据采集 测试技术
基于CEEMDAN-VMD-BiLSTM的多变量输入单步时序预测研究(Matlab代码实现)
基于CEEMDAN-VMD-BiLSTM的多变量输入单步时序预测研究(Matlab代码实现)
315 8
|
8月前
|
机器学习/深度学习 算法 自动驾驶
基于导向滤波的暗通道去雾算法在灰度与彩色图像可见度复原中的研究(Matlab代码实现)
基于导向滤波的暗通道去雾算法在灰度与彩色图像可见度复原中的研究(Matlab代码实现)
416 8

热门文章

最新文章