File size: 2,978 Bytes
3af30c8 a4b2002 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 a4b2002 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 a4b2002 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 4d65552 3af30c8 a4b2002 3af30c8 a4b2002 3af30c8 a4b2002 3af30c8 a4b2002 3af30c8 a4b2002 3af30c8 a4b2002 4d65552 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | # Towards Foundation Models for Zero-Shot Time Series Anomaly Detection: Leveraging Synthetic Data and Relative Context Discrepancy
This repository contains the implementation of Time-RCD for time series anomaly detection, integrated with the TSB-AD (Time Series Benchmark for Anomaly Detection) datasets.
## Project Structure
```
.
βββ checkpoints/ # Pre-trained model checkpoints
βββ datasets/ # TSB-AD datasets (univariate and multivariate)
βββ evaluation/ # Evaluation metrics and visualization tools
βββ models/ # Model implementations
β βββ time_rcd/ # Time-RCD model components
βββ utils/ # Utility functions
βββ testing.py # Main entry point
βββ model_wrapper.py # Model wrapper for different algorithms
βββ README.md # This file
```
## Prerequisites
- Python 3.10
- conda (recommended for environment management)
- Git
## Installation
### 1. Create and Activate Conda Environment
```bash
conda create -n Time-RCD python=3.10
conda activate Time-RCD
```
### 2. Download the Repository
```bash
wget https://anonymous.4open.science/api/repo/TimeRCD-5BE1/zip -O Time-RCD.zip
unzip Time-RCD.zip -d Time-RCD
```
or dowload from the link: https://anonymous.4open.science/r/TimeRCD-5BE1 and unzip
### 3. Download TSB-AD Datasets
Create the datasets directory and download the TSB-AD-U (univariate) and TSB-AD-M (multivariate) datasets:
```bash
mkdir -p "datasets" \
&& wget -O "datasets/TSB-AD-U.zip" "https://www.thedatum.org/datasets/TSB-AD-U.zip" \
&& wget -O "datasets/TSB-AD-M.zip" "https://www.thedatum.org/datasets/TSB-AD-M.zip" \
&& cd datasets \
&& unzip TSB-AD-U.zip && rm TSB-AD-U.zip \
&& unzip TSB-AD-M.zip && rm TSB-AD-M.zip \
&& cd ..
```
### 4. Install Python Dependencies
#### Option A: Fast Install (using uv)
```bash
pip install uv
uv pip install jaxtyping einops pandas numpy scikit-learn transformers torch torchvision statsmodels matplotlib seaborn -U "huggingface_hub[cli]"
```
#### Option B: Normal Install
```bash
pip install jaxtyping einops pandas numpy scikit-learn transformers torch torchvision statsmodels matplotlib seaborn -U "huggingface_hub[cli]"
```
### 5. Download Pre-trained Checkpoints
Download the pre-trained model checkpoints from Hugging Face:
```bash
huggingface-cli download thu-sail-lab/Time-RCD checkpoints.zip --local-dir ./
unzip checkpoints.zip
```
### Single Variable Time Series
To run anomaly detection on univariate time series:
```bash
python testing.py
```
### Multi-Variable Time Series
To run anomaly detection on multivariate time series:
```bash
python testing.py --mode multi
```
<!--
### 6. Download Training Datasets
Download Training Datasets (Optional -for retraining models)
```bash
mkdir training_data
huggingface-cli download thu-sail-lab/Time-RCD training_data.zip --local-dir ./
unzip training_data.zip
```
-->
|