时序预测 | MATLAB实现ELM极限学习机时间序列预测未来

时序预测 | MATLAB实现ELM极限学习机时间序列预测未来

目录

    • 时序预测 | MATLAB实现ELM极限学习机时间序列预测未来
      • 预测效果
      • 基本介绍
      • 程序设计
      • 参考资料

预测效果

时序预测 | MATLAB实现ELM极限学习机时间序列预测未来_第1张图片
时序预测 | MATLAB实现ELM极限学习机时间序列预测未来_第2张图片
时序预测 | MATLAB实现ELM极限学习机时间序列预测未来_第3张图片
时序预测 | MATLAB实现ELM极限学习机时间序列预测未来_第4张图片
时序预测 | MATLAB实现ELM极限学习机时间序列预测未来_第5张图片

基本介绍

1.MATLAB实现ELM极限学习机时间序列预测未来;
2.运行环境Matlab2018及以上,data为数据集,单变量时间序列预测,运行主程序ELMTSF即可,其余为函数文件,无需运行;
3.递归预测未来数据,可以控制预测未来大小的数目,适合循环性、周期性数据预测;
4.命令窗口输出R2、MAE、MAPE、MBE、MSE等评价指标。

程序设计

  • 完整程序和数据下载方式私信博主回复:MATLAB实现ELM极限学习机时间序列预测未来
%%  参数设置
%% 训练模型
%% 模型预测

%%  数据反归一化
T_sim1 = mapminmax('reverse', t_sim1, ps_output);
T_sim2 = mapminmax('reverse', t_sim2, ps_output);
function [IW,B,LW,TF,TYPE] = elmtrain(P,T,N,TF,TYPE)
% ELMTRAIN Create and Train a Extreme Learning Machine
% Syntax
% [IW,B,LW,TF,TYPE] = elmtrain(P,T,N,TF,TYPE)
% Description
% Input
% P   - Input Matrix of Training Set  (R*Q)
% T   - Output Matrix of Training Set (S*Q)
% N   - Number of Hidden Neurons (default = Q)
% TF  - Transfer Function:
%       'sig' for Sigmoidal function (default)
%       'sin' for Sine function
%       'hardlim' for Hardlim function
% TYPE - Regression (0,default) or Classification (1)
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
% Output
% IW  - Input Weight Matrix (N*R)
% B   - Bias Matrix  (N*1)
% LW  - Layer Weight Matrix (N*S)
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
% Example
% Regression:
% [IW,B,LW,TF,TYPE] = elmtrain(P,T,20,'sig',0)
% Y = elmtrain(P,IW,B,LW,TF,TYPE)
% Classification
% [IW,B,LW,TF,TYPE] = elmtrain(P,T,20,'sig',1)
% Y = elmtrain(P,IW,B,LW,TF,TYPE)
% See also ELMPREDICT
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if nargin < 2
    error('ELM:Arguments','Not enough input arguments.');
end
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if nargin < 3
    N = size(P,2);
end
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if nargin < 4
    TF = 'sig';
end
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if nargin < 5
    TYPE = 0;
end
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if size(P,2) ~= size(T,2)
    error('ELM:Arguments','The columns of P and T must be same.');
end
[R,Q] = size(P);
if TYPE  == 1
    T  = ind2vec(T);
end
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[S,Q] = size(T);
% Randomly Generate the Input Weight Matrix
IW = rand(N,R) * 2 - 1;
% Randomly Generate the Bias Matrix
B = rand(N,1);
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BiasMatrix = repmat(B,1,Q);
% Calculate the Layer Output Matrix H
tempH = IW * P + BiasMatrix;
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
switch TF
    case 'sig'
        H = 1 ./ (1 + exp(-tempH));
    case 'sin'
        H = sin(tempH);
    case 'hardlim'
        H = hardlim(tempH);
end
% Calculate the Output Weight Matrix
LW = pinv(H') * T';
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


参考资料

[1] https://blog.csdn.net/article/details/126072792?spm=1001.2014.3001.5502
[2] https://blog.csdn.net/article/details/126044265?spm=1001.2014.3001.5502

你可能感兴趣的:(时间序列,ELM,极限学习机)