This folder provides evaluation scripts and notebooks for time-series anomaly detection on the [TSB-AD](https://github.com/TheDatumOrg/TSB-AD) dataset using MOMENT (both “vanilla” and CAE variants), Chronos, Moirai, and Time-MOE models.

## Data Preparation

1. Clone the TSB-AD repository and download the data:
   ```bash
   git clone https://github.com/TheDatumOrg/TSB-AD.git
   cd TSB-AD
   # follow README there to download the CSV files under TSB-AD-U/

2.Make sure the TSB-AD-U folder (with all <id>.csv) lives at:
'../dataset/TSB-AD-U/TSB-AD-U/'
relative to this repo root.

##Environment Setup

1. TSB-AD + MOMENT

conda create -n TSB-AD python=3.11 -y
conda activate TSB-AD

# JupyterLab
conda install jupyterlab -y

# PyTorch (CUDA 11.8)
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

# Core packages
pip install pandas matplotlib

# TS-AD & MOMENT
pip install tsb-ad
pip install momentfm

# (When done)
conda deactivate

2. Chronos
conda create -n Chronos python=3.11 -y
conda activate Chronos

conda install jupyterlab -y
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install pandas matplotlib

# Chronos forecasting package
pip install chronos-forecasting

conda deactivate

3. Moirai

conda create -n Moirai python=3.11 -y
conda activate Moirai

conda install jupyterlab -y

# PyTorch 2.4.1 + CUDA 11.8
conda install pytorch==2.4.1 torchvision==0.19.1 torchaudio==2.4.1 pytorch-cuda=11.8 \
    -c pytorch -c nvidia

pip install pandas matplotlib

# Moirai dependencies
pip install uni2ts gluonts

conda deactivate

4. Time-MOE

conda create -n Time-moe python=3.11 -y
conda activate Time-moe

conda install jupyterlab -y
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install pandas matplotlib

# Time-MOE dependencies
pip install pyyaml numpy scikit-learn
pip install transformers==4.40.1 datasets==2.18.0 accelerate==0.28.0 flash-attn==2.6.3

conda deactivate

## How to Run

1. Synthetic Submission (submission_synthetic.ipynb)
No additional data download is required.

Activate the TSB-AD Conda environment (as described in the main README’s setup section).

Launch JupyterLab and open submission_synthetic.ipynb.

2. Real Submission (submission_real.ipynb)
Download the TSB-AD-U dataset into:

../dataset/TSB-AD-U/TSB-AD-U/
Activate TSB-AD Conda environment (as described in the main README’s setup section).

Launch JupyterLab and open submission_real.ipynb.

3. Shell Scripts
Ensure the TSB-AD-U CSV files are in:

../dataset/TSB-AD-U/TSB-AD-U/
Activate the matching Conda environment, then run the script. For example:

conda activate TSB-AD
bash MOMENT_ft_M.sh

4. Multivariate Experiments
Download the TSB-AD-M dataset into:

../dataset/TSB-AD-M/TSB-AD-M/
Activate the matching Conda environment, then run the script and run the multivariate notebooks or scripts.