基于BILSTM、GMDH 及遗传COVID 预测研究(Matlab代码实现)

👨‍🎓个人主页:研学社的博客 

💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

2.1 BILSTM预测

 2.2  GA NN 预测​编辑

 2.3 GMDH预测

🎉3 参考文献

🌈4 Matlab代码实现


💥1 概述

BiLSTM 网络由正向 LSTM 结构和反向 LSTM 结构结合而成,这种特殊结构使得隐含层所获得的特
征数据能够同时拥有过去和未来的信息。与 LSTM相比,BiLSTM 可以捕捉输入数据双向的依赖信息, 有效提高了预测模型对输入数据的特征表达能力,网络结构如图5 所示。

从图 5 可以看到, BiLSTM 网络中正向 LSTM 结构计算过程与单个 LSTM 计算过程相似,将正向隐含层状态和反向隐含层状态组合得到 BiLSTM 网络的隐含层状态,其计算公式为:

本文用三种方法进行预测。 BILSTM、GMDH 及遗传COVID 预测。

📚2 运行结果

2.1 BILSTM预测

 2.2  GA NN 预测

 

 

 

 2.3 GMDH预测

 

 

 

 部分代码:

%% Input
x=load('hopkinsirandeath.txt');
Delays = [10 20 30 40 50];
[Inputs, Targets] = CreateTimeSeriesData(x,Delays);
nData = size(Inputs,2);
Perm = randperm(nData);
% Train 
pTrain = 0.8;
nTrainData = round(pTrain*nData);
TrainInd = Perm(1:nTrainData);
TrainInputs = Inputs(:,TrainInd);
TrainTargets = Targets(:,TrainInd);
% Test 
pTest = 1 - pTrain;
nTestData = nData - nTrainData;
TestInd = Perm(nTrainData+1:end);
TestInputs = Inputs(:,TestInd);
TestTargets = Targets(:,TestInd);

% Create GMDH Network
params.MaxLayerNeurons = 30;   % Maximum Number of Neurons in a Layer
params.MaxLayers = 9;          % Maximum Number of Layers
params.alpha = 0;              % Selection Pressure
params.pTrain = 0.2;           % Train Ratio

% Tran GMDH
gmdh = GMDH(params, TrainInputs, TrainTargets);

%  GMDH Model on Train and Test (Validation)
Outputs = ApplyGMDH(gmdh, Inputs);
TrainOutputs = Outputs(:,TrainInd);
TestOutputs = Outputs(:,TestInd);


%% Predict Plots
% figure;
% PlotResults(TrainTargets, TrainOutputs, 'Train Data');
% figure;
% PlotResults(TestTargets, TestOutputs, 'Test Data');
figure;
set(gcf, 'Position',  [50, 100, 1200, 450])
[MSE RMSE ErrorMean ErrorStd Errors]=PlotResults(Targets, Outputs, 'All Data');
figure;
plotregression(TrainTargets, TrainOutputs, 'Train Data', ...
               TestTargets, TestOutputs, 'TestData', ...
               Targets, Outputs, 'GMDH All Data');

% Forecast Plot
fore=180;
sizee=size(x);
sizee=sizee(1,2);
forecasted=Outputs(1,end-fore:end);
forecasted=forecasted+x(end)/2.5;
ylbl=sizee+fore;
t = linspace(sizee,ylbl,length(forecasted));

% Compare the simulated output with measured data to ensure it is a good fit.
nstep=32;
sys = nlarx(Outputs',64);
figure;
set(gcf, 'Position',  [50, 200, 1300, 400])
compare(Outputs',sys,nstep);title('Covid Iran Death');
grid on;
%
figure;
regres=compare(Outputs',sys,nstep);title('Covid Iran Death');
b1 = regres\Outputs';
yCalc1 = b1*regres;
scatter(regres,Outputs','MarkerEdgeColor',[0 .5 .5],...
              'MarkerFaceColor',[0 .8 .8],...
              'LineWidth',1);
hold on
plot(regres,yCalc1,':',...
    'LineWidth',2,...
    'MarkerSize',5,...
    'Color',[0.6350 0.0780 0.1840]);
title(['Regression :   ' num2str(b1) ])
grid on

%
figure;
set(gcf, 'Position',  [20, 20, 1000, 250])
plot(x,'--',...
    'LineWidth',1,...
    'MarkerSize',5,...
    'Color',[0,0,0.7]);
hold on;
plot(t,forecasted,'-.',...
    'LineWidth',2,...
    'MarkerSize',10,...
    'Color',[0.9,0.5,0]);
title('Johns Hopkins Data for Iran COVID Deaths - Orange is Forcasted')
xlabel('Days - From Jan 2020 Till Dec 2021','FontSize',12,...
       'FontWeight','bold','Color','b');
ylabel('Number of People','FontSize',12,...
       'FontWeight','bold','Color','b');
   datetick('x','mmm');
legend({'Measured','GMDH Forecasted'});
%% Metrics
% Explained Variance (EV)
va=var(Outputs-Targets);vc=var(Targets);
vd=abs(va/vc);vb = vd / 10^floor(log10(vd));
EV=vb*0.1
% MSE
MSE 
% RMSE
RMSE
% Mean Error
ErrorMean
% STD Error
ErrorStd 
% Mean Absolute Error (MAE)

🎉3 参考文献

部分理论来源于网络,如有侵权请联系删除。

[1]Seyed Muhammad Hossein Mousavi (2023). BILSTM, GMDH and Genetic COVID Forecasting Into Desired Step.

[2]高明,郝妍.基于BiLSTM网络与误差修正的超短期负荷预测[J].综合智慧能源,2023,45(01):31-40. 

🌈4 Matlab代码实现

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

荔枝科研社

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值