Interval prediction | MATLAB implements multi-variable time series interval prediction based on QRCNN-GRU-Multihead-Attention multi-head attention convolution gated recurrent unit

Interval prediction | MATLAB implements multi-variable time series interval prediction based on QRCNN-GRU-Multihead-Attention multi-head attention convolution gated recurrent unit

List of effects

1
2
3
4
5
6
7

basic introduction

1. Matlab implements QRCNN-GRU-Multihead-Attention convolutional neural network combined with gated recurrent unit multi-head attention multi-variable time series interval prediction; 2. Multi-
map output, point prediction and multi-index output (MAE, MAPE, RMSE, MSE , R2), interval prediction multi-finger ratio output (interval coverage rate PICP, interval average width percentage PINAW), multi-input single output, including point prediction map, different confidence interval prediction map, error analysis map, kernel density estimation probability density map;
3. data is a data set, power data set, using multiple associated variables to predict the last column of power data, which is also applicable to load forecasting and wind speed forecasting; MainQRCNN_GRU_MATTNTS is the main program, and the rest are function files, no need to run; 4. Code
quality High, with clear annotations, including data preprocessing, handling missing values, deleting if it is nan, and including kernel density estimation;
5. The operating environment is Matlab2021 and above.

Model description

The Multi-Head Attention Convolutional Gated Recurrent Unit is a deep learning model for interval prediction of multivariate time series, which combines a multi-head attention mechanism, a convolutional neural network, and a gated recurrent unit.
The specific principles of the model are as follows:
Data preprocessing: For multivariate time series data, it first needs to be preprocessed, including normalization, filling missing values, etc., to facilitate subsequent model training and prediction.
Feature extraction: Use convolutional neural network (CNN) to perform feature extraction on the time series data of each variable, and extract the feature vector of each time step.
Multi-head attention: For the feature vector of each time step, the multi-head attention mechanism is used to select important features of each variable to generate a weighted average feature vector.
Gated Recurrent Units: Use Gated Recurrent Units (GRUs) to model relationships between time series, as well as dependencies between variables. GRU is a recurrent neural network with a gating mechanism that controls the flow of information.
Output: Finally, the output of the GRU is concatenated with the attention-weighted feature vector to obtain the final output of the model. This output can be used for interval forecasting of multivariate time series, such as predicting the value of a variable some time in the future.
The training process of the whole model is an end-to-end process, using the backpropagation algorithm to optimize the model parameters. In the forecasting process, historical data can be used as input to obtain the output of the model, so as to perform interval forecasting.

programming

  • Complete program and data acquisition method: private message blogger.
ntrain=round(nwhole*num_size);
	ntest =nwhole-ntrain;
	% 准备输入和输出训练数据
	input_train =input(:,temp(1:ntrain));
	output_train=output(:,temp(1:ntrain));
	% 准备测试数据
	input_test =input(:, temp(ntrain+1:ntrain+ntest));
	output_test=output(:,temp(ntrain+1:ntrain+ntest));
	%% 数据归一化
	method=@mapminmax;
	[inputn_train,inputps]=method(input_train);
	inputn_test=method('apply',input_test,inputps);
	[outputn_train,outputps]=method(output_train);
	outputn_test=method('apply',output_test,outputps);
	% 创建元胞或向量,长度为训练集大小;
	XrTrain = cell(size(inputn_train,2),1);
	YrTrain = zeros(size(outputn_train,2),1);
	for i=1:size(inputn_train,2)
		XrTrain{
    
    i,1} = inputn_train(:,i);
		YrTrain(i,1) = outputn_train(:,i);
	end
	% 创建元胞或向量,长度为测试集大小;
	XrTest = cell(size(inputn_test,2),1);
	YrTest = zeros(size(outputn_test,2),1);
	for i=1:size(input_test,2)
		XrTest{
    
    i,1} = inputn_test(:,i);
		YrTest(i,1) = outputn_test(:,i);
	end

	%% 创建混合网络架构
%%  区间覆盖率
RangeForm = [T_sim(:, 1), T_sim(:, end)];
Num = 0;

for i = 1 : length(T_train)
    Num = Num +  (T_train(i) >= RangeForm(i, 1) && T_train(i) <= RangeForm(i, 2));
end

picp = Num / length(T_train);     


    S = cumtrapz(X,Y);
    Index = find(abs(m-S)<=1e-2);
    Q = X(max(Index));



References

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

Guess you like

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