TCN-BILSTM time series prediction Python program based on self-attention

 TCN-BILSTM time series prediction Python program based on self-attention

Features: 1. Single-variable and multi-variable input, free switching 

           2. Single-step forecast, multi-step forecast, automatic switching

           3. Based on Pytorch architecture

           4. Multiple evaluation indicators (MAE, MSE, R2, MAPE, etc.)

           5. The data is read from the excel file, easy to replace

           6. Standard framework, the data is divided into training set, verification set and test set

All the complete code, the code that is guaranteed to run can be seen here.

http://t.csdn.cn/obJlChttp://t.csdn.cn/obJlC

  ! ! ! If the first link cannot be opened, please click on the personal homepage to view my personal introduction.

(After searching for the product, click on the avatar to see all the codes)

Blog of Black Technology Little Potato_CSDN Blog-Deep Learning, Blogger in 32 MCU Field

1. Background introduction: This model is based on TCN and BILSTM structure, plus a self-attention mechanism for time series prediction. TCN is a structure similar to convolutional neural network, but its convolutional layer is a reusable module, which can greatly increase the depth and breadth of the model. LSTM is a recurrent neural network that can handle long-term dependencies in time series. The self-attention mechanism focuses the network's attention on different parts of the input data, enabling the model to focus on the most important features.

 

2. Summary of advantages:

  • Due to the adoption of the TCN structure, it can handle multi-dimensional input, and is not limited by length, so it has strong adaptability;
  • The introduction of the self-attention mechanism allows the model to better focus on the most important part of the input sequence, thereby improving the accuracy of the model.

train_ratio = 0.7  # 训练集比例
val_ratio = 0.15  # 验证集比例
test_ratio = 0.15  # 测试集比例
input_length = 48  # 输入数据长度,多步预测建议长,单步预测建议短
output_length = 1  # 输出数据长度,1为单步预测,1以上为多步预测 请注意,随着输出长度的增长,模型训练时间呈指数级增长
learning_rate = 0.1  # 学习率
estimators = 100  # 迭代次数
max_depth = 5  # 树模型的最大深度
interval_length = 2000  # 预测数据长度,最长不可以超过总数据条数
scalar = True  # 是否使用归一化
scalar_contain_labels = True  # 归一化过程是否包含目标值的历史数据
target_value = 'load'  # 需要预测的列名,可以在excel中查看

Guess you like

Origin blog.csdn.net/qq_41728700/article/details/129889890