GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

Reading time required

6

minutes

Speed reading only takes 2 minutes

Please respect original labor achievementsPlease indicate the link of this article and the author: Machine Learning Heart

Click to read the original text or copy the following link to the browser to get the complete source code and data of the article:

https://mbd.pub/o/bread/mbd-Z56VmZtt

Abstract: Genetic Algorithm + Four Models + Bidirectional Network! GA-CNN-BiLSTM-Attention series four models for multivariate time series prediction

1

Basic Introduction

Based on GA-CNN-BiLSTM-Attention, CNN-BiLSTM-Attention, GA-CNN-BiLSTM, and CNN-BiLSTM four models for multivariate time series prediction with one-click comparison (just run one main to get all results)

Matlab code, the prediction results of each model and the comparison results are all included!
1. No complicated steps, just run one main to generate all images.
2. The program has been debugged, no need to change the code, just replace the dataset to run!!! The data format is Excel!
3. GA optimization parameters are: number of hidden layer nodes, learning rate, regularization coefficient.
4.Genetic Algorithm (GA) is an optimization search algorithm that simulates natural selection and genetic mechanisms, proposed by John Holland in the 1970s. It simulates the processes of crossover and mutation of chromosome genes during biological evolution, transforming the problem-solving process into computer simulation calculations to search for optimal solutions..
5. The running environment requires MATLAB version 2023b or above.
Evaluation metrics include: R2, MAE, MSE, RPD, RMSE, etc., with many graphs.
The code has clear Chinese comments, very high quality, and includes a test dataset that can be run directly. Just replace your data to use it. Suitable for beginners.

After purchase, you can add the author on QQ 1153460737 for consultation and exchange.Note: The pirated code purchased from other unofficial channels does not include model consultation and exchange services. Please be cautious, thank you.Official account Machine Learning Heart HML, CSDN blogger Machine Learning Heart, Zhihu, Bilibili with the same name, other similar accounts are not me, beware of scams. I am not responsible for others using my name. My QQ is 1153460737.

2

2.1

Dataset

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

2.2

Running Effect

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

Complete Code Link:https://mbd.pub/o/bread/mbd-Z56VmZtt

Also scan the QR code:

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

3

Part of the Source Code

%%  Clear environment variables
warning off             % Turn off warning messages
close all               % Close opened figure windows
clear                   % Clear variables
clc                     % Clear command line

%%  Import data
result = xlsread('dataset.xlsx');

%%  Data analysis
num_samples = length(result);  % Number of samples
kim = 2;                       % Delay step (previous multiple rows of historical data as independent variables)
zim =  1;                      % Predict across zim time points
nim = size(result, 2) - 1;     % Number of features in the original data

%%  Split dataset
for i = 1: num_samples - kim - zim + 1    
    res(i, :) = [reshape(result(i: i + kim - 1 + zim, 1: end - 1)', 1, ...        
        (kim + zim) * nim), result(i + kim + zim - 1, end)];
end

%%  Dataset analysis
outdim = 1;                                  % Last column is output
num_size = 0.7;                              % Training set occupies the proportion of the dataset
num_train_s = round(num_size * num_samples); % Number of training samples
f_ = size(res, 2) - outdim;                  % Length of input features

%%  Split training and testing sets
P_train = res(1: num_train_s, 1: f_)';
T_train = res(1: num_train_s, f_ + 1: end)';
M = size(P_train, 2);
P_test = res(num_train_s + 1: end, 1: f_)';
T_test = res(num_train_s + 1: end, f_ + 1: end)';
N = size(P_test, 2);

%%  Data normalization
[p_train, ps_input] = mapminmax(P_train, -1, 1);% Adjust training and testing data to between 0 and 1
p_test = mapminmax('apply', P_test, ps_input);
[t_train, ps_output] = mapminmax(T_train, -1, 1);% Normalize testing data
t_test = mapminmax('apply', T_test, ps_output);

%%  Data flattening
%   Flattening data into 1D is just one way of processing
%   It can also be flattened into 2D or 3D, which requires modifying the corresponding model structure
%   However, it should always be consistent with the input layer data structure
p_train =  double(reshape(p_train, f_, 1, 1, M));
p_test  =  double(reshape(p_test , f_, 1, 1, N));
t_train =  double(t_train)';
t_test  =  double(t_test )';

%%  Data format conversion
for i = 1 : M    
    Lp_train{i, 1} = p_train(:, :, 1, i);
end
for i = 1 : N    
    Lp_test{i, 1}  = p_test( :, :, 1, i);
end

disp('----------Running CNN-LSTM Model----------');
%%  CNN-LSTM

4

Other Codes

Well, careful readers will find: https://mbd.pub/o/slowtrain/work

Blog expert certification, creator in the field of machine learning, 2023 Blog Star TOP50, mainly engaged in program design and case analysis of time series, regression, classification, clustering, and dimensionality reduction in machine learning and deep learning.Research project model customization/simulation of horizontal project models/guidance on academic papers for professional titles/model program explanation can all be contacted through my only QQ 1153460737 (Others are all pirated, please be cautious

Technical exchange group: After purchasing the author’s desired code or sharing the author’s article to any third-party platform, you can add the author on QQ to join the group

GA-CNN-BiLSTM-Attention Series for Multivariate Time Series Prediction

Leave a Comment