Interval forecast | MATLAB implements QRGRU gated recurrent unit quantile regression time series interval forecast

Interval forecast | MATLAB implements QRGRU gated recurrent unit quantile regression time series interval forecast

List of effects

  • advanced version
    1
    2
    3

  • basic version
    4

basic introduction

MATLAB implements QRGRU gated recurrent unit quantile regression time series interval prediction

Model description

Quantile regression is simple regression, like ordinary least squares, but instead of minimizing the sum of squared errors, it minimizes the sum of absolute errors resulting from the chosen quantile cut point. If q=0.50 (the median), then there is a special case for quantile regression - the smallest absolute error (since the median is the central quantile). We can tune the hyperparameter q to choose a threshold that is appropriate for balancing false positives and false negatives specific to the problem we want to solve. GRU has two gates, a reset gate and an update gate. Intuitively, the reset gate determines how new input information is combined with the previous memory, and the update gate defines the amount of previous memory saved to the current time step. If we set the reset gate to 1 and the update gate to 0, then we get the standard RNN model again.

programming

% gru
layers = [ ...
    sequenceInputLayer(inputSize,'name','input')   %输入层设置
    gruLayer(numhidden_units1,'Outputmode','sequence','name','hidden1') 
    dropoutLayer(0.3,'name','dropout_1')
    gruLayer(numhidden_units2,'Outputmode','last','name','hidden2') 
    dropoutLayer(0.3,'name','drdiopout_2')
    fullyConnectedLayer(outputSize,'name','fullconnect')   % 全连接层设置(影响输出维度)(cell层出来的输出层) %
    quanRegressionLayer('out',i)];
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
% 参数设定
opts = trainingOptions('adam', ...
    'MaxEpochs',10, ...
    'GradientThreshold',1,...
    'ExecutionEnvironment','cpu',...
    'InitialLearnRate',0.001, ...
    'LearnRateSchedule','piecewise', ...
    'LearnRateDropPeriod',2, ...   %2个epoch后学习率更新
    'LearnRateDropFactor',0.5, ...
    'Shuffle','once',...  % 时间序列长度
    'SequenceLength',1,...
    'MiniBatchSize',24,...
    'Verbose',0);
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
%
% 网络训练
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
y = Test.demand;
x = Test{
    
    :,3:end};
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
% 归一化
[xnorm,xopt] = mapminmax(x',0,1);
xnorm = mat2cell(xnorm,size(xnorm,1),ones(1,size(xnorm,2)));
[ynorm,yopt] = mapminmax(y',0,1);
ynorm = ynorm';
        % 平滑层
        flattenLayer('Name','flatten')
        % GRU特征学习
        gruLayer(50,'Name','gru1','RecurrentWeightsInitializer','He','InputWeightsInitializer','He')
        % GRU输出
        gruLayer(NumOfUnits,'OutputMode',"last",'Name','bil4','RecurrentWeightsInitializer','He','InputWeightsInitializer','He')
        dropoutLayer(0.25,'Name','drop3')
        % 全连接层
        fullyConnectedLayer(numResponses,'Name','fc')
        regressionLayer('Name','output')    ];

    layers = layerGraph(layers);
    layers = connectLayers(layers,'fold/miniBatchSize','unfold/miniBatchSize');
————————————————
版权声明:本文为CSDN博主「机器学习之心」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/kjm13182345320/article/details/130447132

References

[1] https://blog.csdn.net/kjm13182345320/article/details/127931217
[2] https://blog.csdn.net/kjm13182345320/article/details/127418340
[3] https://blog.csdn.net/kjm13182345320/article/details/127380096

Guess you like

Origin blog.csdn.net/kjm13182345320/article/details/130551256