Home

Awesome

SegRNN

Welcome to the official repository of the SegRNN paper: "Segment Recurrent Neural Network for Long-Term Time Series Forecasting."

Updates

🚩 News (2024.10): SegRNN has been included in [PyPOTS], a widely acclaimed and popular repository dedicated to multivariate partially-observed time series with missing values.

🚩 News (2024.09) Another one of our recent works, CycleNet has been accepted as NeurIPS 2024 Spotlight. CycleNet pioneers the exploration of explicitly modeling periodic patterns in time-series data through learnable recurrent cycles to enhance the accuracy of time series forecasting tasks.

🚩 News (2024.06) We have fixed a long-standing bug (see description in FITS and TFB ) in the code framework and updated SegRNN's performance in shorter lookback windows (L=96) in this table, demonstrating that SegRNN still achieves state-of-the-art performance in this case.

🚩 News (2024.05) Another one of our recent works, SparseTSF has been accepted as an Oral paper at ICML 2024 (acceptance rate less than 1.5%). As an ultra-lightweight LTSF model, it achieves near state-of-the-art performance with less than 1k parameters.

🚩 News (2024.04) SegRNN has been included in [Time-Series-Library] and serves as the only RNN-based baseline.

Introduction

SegRNN is an innovative RNN-based model designed for Long-term Time Series Forecasting (LTSF). It incorporates two fundamental strategies:

  1. The replacement of point-wise iterations with segment-wise iterations
  2. The substitution of Recurrent Multi-step Forecasting (RMF) with Parallel Multi-step Forecasting (PMF)

image

By combining these two strategies, SegRNN achieves state-of-the-art results with just a single layer of GRU, making it extremely lightweight and efficient.

image

Lots of readers have inquired about why there is a significant difference between the MSE and MAE metrics for Traffic data in the paper. This is because the presence of outlier extreme values in the Traffic data amplifies the MSE error. After adopting the mainstream ReVIN strategy, this issue was resolved, and the forecast accuracy was further improved.

Getting Started

Environment Requirements

To get started, ensure you have Conda installed on your system and follow these steps to set up the environment:

conda create -n SegRNN python=3.8
conda activate SegRNN
pip install -r requirements.txt

Data Preparation

All the datasets needed for SegRNN can be obtained from the Google Drive provided in Autoformer. Create a separate folder named ./dataset and place all the CSV files in this directory. Note: Place the CSV files directly into this directory, such as "./dataset/ETTh1.csv"

Training Example

You can easily reproduce the results from the paper by running the provided script command. For instance, to reproduce the main results, execute the following command:

sh run_main.sh

Similarly, you can specify separate scripts to run independent tasks, such as obtaining results on etth1:

sh scripts/SegRNN/etth1.sh

You can reproduce the results of the ablation learning by using other instructions:

sh scripts/SegRNN/ablation/rnn_variants.sh

Citation

If you find this repo useful, please cite our paper.

@article{lin2023segrnn,
  title={Segrnn: Segment recurrent neural network for long-term time series forecasting},
  author={Lin, Shengsheng and Lin, Weiwei and Wu, Wentai and Zhao, Feiyu and Mo, Ruichao and Zhang, Haotong},
  journal={arXiv preprint arXiv:2308.11200},
  year={2023}
}

Comparison Results for Lookback L = 96

There was a longstanding bug in our current framework where the last batch of data was discarded during the testing phase (i.e., drop_last = False). This might have affected the model's performance, especially when using a large batch size on small datasets. We have now fixed this issue (see data_provider/data_factory.py and exp/exp_main.py).

In addition, many recent works have tested their models' performance with a Lookback of L = 96. To investigate SegRNN’s performance with a shorter input window, we reran SegRNN using MSE as the loss function under the fixed framework (the run script is located in scripts/SegRNN/Lookback_96).

The comparison results below indicate that SegRNN still achieves state-of-the-art performance with a Lookback of 96. (Results for models other than SegRNN are taken from iTransformer.)

SegRNNiTransformerTimesNetPatchTSTCrossformerDLinearFEDformer
DatasetHorizonMSEMAEMSEMAEMSEMAEMSEMAEMSEMAEMSEMAEMSEMAE
ETTh1960.3680.3950.3860.4050.3840.4020.4140.4190.4230.4480.3860.4000.3760.419
1920.4080.4190.4410.4360.4360.4290.4600.4450.4710.4740.4370.4320.4200.448
3360.4440.4400.4870.4580.4910.4690.5010.4660.5700.5460.4810.4590.4590.465
7200.4460.4570.5030.4910.5210.5000.5000.4880.6530.6210.5190.5160.5060.507
ETTh2960.2780.3350.2970.3490.3400.3740.3020.3480.7450.5840.3330.3870.3580.397
1920.3590.3890.3800.4000.4020.4140.3880.4000.8770.6560.4770.4760.4290.439
3360.4210.4360.4280.4320.4520.4520.4260.4331.0430.7310.5940.5410.4960.487
7200.4320.4550.4270.4450.4620.4680.4310.4461.1040.7630.8310.6570.4630.474
ETTm1960.3300.3690.3340.3680.3380.3750.3290.3670.4040.4260.3450.3720.3790.419
1920.3690.3920.3770.3910.3740.3870.3670.3850.4500.4510.3800.3890.4260.441
3360.3990.4120.4260.4200.4100.4110.3990.4100.5320.5150.4130.4130.4450.459
7200.4540.4430.4910.4590.4780.4500.4540.4390.6660.5890.4740.4530.5430.490
ETTm2960.1730.2550.1800.2640.1870.2670.1750.2590.2870.3660.1930.2920.2030.287
1920.2370.2980.2500.3090.2490.3090.2410.3020.4140.4920.2840.3620.2690.328
3360.2960.3360.3110.3480.3210.3510.3050.3430.5970.5420.3690.4270.3250.366
7200.3890.4070.4120.4070.4080.4030.4020.4001.7301.0420.5540.5220.4210.415
Electricity960.1510.2450.1480.2400.1680.2720.1810.2700.2190.3140.1970.2820.1930.308
1920.1640.2580.1620.2530.1840.2890.1880.2740.2310.3220.1960.2850.2010.315
3360.1800.2770.1780.2690.1980.3000.2040.2930.2460.3370.2090.3010.2140.329
7200.2180.3130.2250.3170.2200.3200.2460.3240.2800.3630.2450.3330.2460.355
Traffic960.4190.2690.3950.2680.5930.3210.4620.2900.5220.2900.6500.3960.5870.366
1920.4340.2760.4170.2760.6170.3360.4660.2900.5300.2930.5980.3700.6040.373
3360.4500.2840.4330.2830.6290.3360.4820.3000.5580.3050.6050.3730.6210.383
7200.4830.3020.4670.3020.6400.3500.5140.3200.5890.3280.6450.3940.6260.382
Weather960.1650.2270.1740.2140.1720.2200.1770.2100.1580.2300.1960.2550.2170.296
1920.2110.2730.2210.2540.2190.2610.2250.2500.2060.2770.2370.2960.2760.336
3360.2700.3180.2780.2960.2800.3060.2780.2900.2720.3350.2830.3350.3390.380
7200.3570.3760.3580.3490.3650.3590.3540.3400.3980.4180.3450.3810.4030.428
Average0.3320.3450.3420.3470.3760.3620.3530.3500.5420.4660.4100.3960.3940.396

Acknowledgement

We extend our heartfelt appreciation to the following GitHub repositories for providing valuable code bases and datasets:

https://github.com/yuqinie98/patchtst

https://github.com/cure-lab/LTSF-Linear

https://github.com/zhouhaoyi/Informer2020

https://github.com/thuml/Autoformer

https://github.com/MAZiqing/FEDformer

https://github.com/alipay/Pyraformer

https://github.com/ts-kim/RevIN

https://github.com/timeseriesAI/tsai