Time-Series-Library README

The project's README from github.com/thuml/Time-Series-Library. As one markdown file: README.md.

Time Series Library (TSLib)

TSLib is an open-source library for deep learning researchers, especially for deep time series analysis.

中文文档:README_zh.md

We provide a neat code base to evaluate advanced deep time series models or develop your model, which covers five mainstream tasks: long- and short-term forecasting, imputation, anomaly detection, and classification.

:triangular_flag_on_post:News (2026.04) Due to the limited bandwidth of the current maintainers, we will not be actively adding new features to this library. Since the library was originally released three years ago, many of its benchmarks may no longer be meaningful for evaluating the effectiveness or progress of current research. However, the baseline implementations remain correct. We therefore recommend seeking out newer benchmarks.

:triangular_flag_on_post:News (2025.12) Many thanks to the great work from ailuntz, which provides an updated requirements and docker deployment, as well as a well-organized document. This is quite meaningful to this project and beginners.

:triangular_flag_on_post:News (2025.11) Considering the rapid development of Large Time Series Models (LTSMs), we have newly added a [zero-shot forecasting] feature in TSLib. You can try this script to evaluate LTSMs.

:triangular_flag_on_post:News (2025.10) Given the recent confusion among researchers regarding minor improvements on standard benchmarks, we propose the [Accuracy Law] to characterize the objectives of deep time series forecasting tasks, which can be used to identify saturated datasets.

:triangular_flag_on_post:News (2024.10) We have included [TimeXer], which defined a practical forecasting paradigm: Forecasting with Exogenous Variables. Considering both practicability and computation efficiency, we believe the new forecasting paradigm defined in TimeXer can be the "right" task for future research.

:triangular_flag_on_post:News (2024.10) Our lab has open-sourced [OpenLTM], which provides a distinct pretrain-finetuning paradigm compared to TSLib. If you are interested in Large Time Series Models, you may find this repository helpful.

:triangular_flag_on_post:News (2024.07) We wrote a comprehensive survey of [Deep Time Series Models] with a rigorous benchmark based on TSLib. In this paper, we summarized the design principles of current time series models supported by insightful experiments, hoping to be helpful to future research.

:triangular_flag_on_post:News (2024.04) Many thanks for the great work from frecklebars. The famous sequential model Mamba has been included in our library. See this file, where you need to install mamba_ssm with pip at first.

:triangular_flag_on_post:News (2024.03) Given the inconsistent look-back length of various papers, we split the long-term forecasting in the leaderboard into two categories: Look-Back-96 and Look-Back-Searching. We recommend researchers read TimeMixer, which includes both look-back length settings in experiments for scientific rigor.

:triangular_flag_on_post:News (2023.10) We add an implementation to iTransformer, which is the state-of-the-art model for long-term forecasting. The official code and complete scripts of iTransformer can be found here.

:triangular_flag_on_post:News (2023.09) We added a detailed tutorial for TimesNet and this library, which is quite friendly to beginners of deep time series analysis.

:triangular_flag_on_post:News (2023.02) We release the TSlib as a comprehensive benchmark and code base for time series models, which is extended from our previous GitHub repository Autoformer.

Leaderboard for Time Series Analysis

Till March 2024, the top three models for five different tasks are:

Model
Ranking
Long-term
Forecasting
Look-Back-96
Long-term
Forecasting
Look-Back-Searching
Short-term
Forecasting
Imputation Classification Anomaly
Detection
🥇 1st TimeXer TimeMixer TimesNet TimesNet TimesNet TimesNet
🥈 2nd iTransformer PatchTST Non-stationary
Transformer
Non-stationary
Transformer
Non-stationary
Transformer
FEDformer
🥉 3rd TimeMixer DLinear FEDformer Autoformer Informer Autoformer

Note: We will keep updating this leaderboard. If you have proposed advanced and awesome models, you can send us your paper/code link or raise a pull request. We will add them to this repo and update the leaderboard as soon as possible.

Compared models of this leaderboard. ☑ means that their codes have already been included in this repo.

See our latest paper [TimesNet] for the comprehensive benchmark. We will release a real-time updated online version soon.

Newly added baselines. We will add them to the leaderboard after a comprehensive evaluation.

Newly added Large Time Series Models. This library also supports the zero-shot evaluation of the following LTSMs.

Getting Started

Prepare Data

You can obtain the well-preprocessed datasets from [Google Drive], [Baidu Drive] or [Hugging Face]. Then place the downloaded data in the folder ./dataset.

Installation

  1. Clone this repository.

    git clone https://github.com/thuml/Time-Series-Library.git
    cd Time-Series-Library
    
  2. Create a new Conda environment.

    conda create -n tslib python=3.11
    conda activate tslib
    
  3. Install Core Dependencies

    ⚠️ CUDA Compatibility Notice The torch prebuilt package is CUDA-version specific. (See https://pytorch.org/get-started/previous-versions/) Please make sure to install the package that matches your local CUDA version (e.g., cu118 or cu121). Recommended: torch==2.5.1

    pip install torch==2.5.1 --index-url https://download.pytorch.org/whl/cu121
    
    pip install -r requirements.txt
    
  4. Install Dependencies for Mamba Model (Required for Time-Series-Library/models/Mamba.py)

    ⚠️ Linux only ⚠️ CUDA Compatibility Notice The prebuilt Mamba wheel is CUDA-version specific. Please make sure to install the wheel that matches your local CUDA version (e.g., cu11 or cu12). Installing a mismatched version may result in runtime errors or import failures.

    Example for CUDA 12:

    pip install https://github.com/state-spaces/mamba/releases/download/v2.2.6.post3/mamba_ssm-2.2.6.post3+cu12torch2.5cxx11abiFALSE-cp311-cp311-linux_x86_64.whl
    
  5. Install Dependencies for Moirai Model (Required for Time-Series-Library/models/Moirai.py)

    pip install uni2ts --no-deps
    

Docker Deployment

# Build and start the Docker container in detached mode
docker compose -f 'Time-Series-Library/docker-compose.yml' up -d --build

# Download / place the dataset into a newly created folder ./dataset at the repository root
mkdir -p dataset  # create the dataset directory

# Copy the local dataset into the container at /workspace/dataset
docker cp ./dataset tslib:/workspace/dataset

# Enter the running container to continue training / evaluation
docker exec -it tslib bash

# Switch to the workspace directory inside the container
cd /workspace

# Run zero-shot forecasting with the pre-trained Moirai model
python -u run.py \
  --task_name zero_shot_forecast \   # task type: zero-shot forecasting
  --is_training 0 \                  # 0 = inference only (no training)
  --root_path ./dataset/ETT-small/ \ # root directory of the dataset
  --data_path ETTh1.csv \            # dataset file name
  --model_id ETTh1_512_96 \          # experiment/model identifier
  --model Moirai \                   # model name (TimesFM / Moirai)
  --data ETTh1 \                     # dataset name
  --features M \                     # multivariate forecasting
  --seq_len 512 \                    # input sequence length
  --pred_le

Time-Series-Library (thuml/Time-Series-Library)

Searching Database…

这是什么东西?TSLib 是一个面向时间序列研究方向深度学习研究者的开源 Python 库,代码整洁,可用于评估先进的深度时间序列模型或开发自己的模型,在 GitHub 上已有约 13,000 颗星。
它是导入我自己代码里用的库,还是一套要跑的实验?它是一个用来运行的科研代码库,不是用 pip 装的包:里面包含各模型的实现和一个 run.py 脚本,用于在标准数据集上训练和评估这些模型。你主要是启动实验,而不是调用 API。
怎么把它跑起来?克隆仓库,创建 Conda 环境并安装核心依赖,然后把预处理好的数据集(Google Drive、百度网盘或 Hugging Face)下载到 ./dataset 目录,再用 run.py 启动实验。项目也提供了 Docker Compose 方案作为替代。
安装时有什么坑需要提前知道?有:预编译的 torch 包必须与你本地的 CUDA 版本匹配(比如 cu118 或 cu121;推荐 torch 2.5.1)。另外 Mamba 的额外依赖只支持 Linux,且需要特定 CUDA 版本的 wheel,版本不匹配会导致导入错误或运行时报错。
Accuracy Law(精度定律)是什么?这是作者在 2025 年 10 月提出的一条原则,用来刻画深度时间序列预测任务的目标;它有助于识别已经饱和的数据集——在这类数据集上,基准指标的微小提升已不再代表真正的进步。
这个库为什么会被做出来?它于 2023 年 2 月发布,是在作者之前的仓库 Autoformer 基础上扩展而来的时间序列模型综合基准和代码库,目的是让研究者能在同一套干净的环境下比较各个模型。
TimesNet 是什么?为什么它总排在排行榜第一?TimesNet 是作者发表于 ICLR 2023 的通用时间序列分析模型,通过建模二维时序变化来处理数据。在 README 的排行榜中,它在短期预测、缺失值填补、分类和异常检测上都排名第一。
有没有适合新手的内容?有,作者在 2023 年 9 月发布了关于 TimesNet 和这个库的详细教程,并称它对深度时间序列分析的新手很友好。
Creator
thuml
Size
78.4 MB
Stars
13K
Updated
CommitApr 18
Age
3y
Commits · 90 Days