# Running anomaly detection on TSB-AD datasets

## Reference
Most of the anomaly detection source codes are adopted directly from the TSB-AD Leaderboard "The Elephant in the Room: Towards A Reliable Time-Series Anomaly Detection Benchmark" Qinghua Liu and John Paparrizos. NeurIPS 2024.
We add the TSPulse code `tspulse/ad/TSB_AD/models/TSPulse.py` in the leaderboard code to evaluate TSPulse in both zero-shot and fine-tune settings.

## Download datasets
Follow the instruction in this file `tspulse/ad/Datasets/README.md` to download the TSB-AD datasets.

## Example scripts
Four example scripts are provided.
1. `run_ft_dataset.sh` -- To run TSPulse(FT) on a specific dataset.
2. `run_ft_file.sh` -- To run TSPulse(FT) on a particular time series of a specific dataset.
3. `run_zs_dataset.sh` -- To run TSPulse(ZS) on a specific dataset. 
4. `run_zs_file.sh` -- To run TSPulse(ZS) on a particular time series of a specific dataset.

## Arguments to provide
While running TSPulse for AD, output from the best TSPulse Head should be considered. To get the best TSPulse Head for any dataset please refer to Table-4 and Table-5 in the appendix, and activate the following args in the script:
- Head_time: `-utf=0 -uf=0 -eo=0`
- Head_FFT: `-utf=1 -uf=0 -eo=0`
- Head_Future: `-utf=0 -uf=1 -eo=0`
- Head_Ensemble: `-utf=0 -uf=0 -eo=1`

See the above example scripts for details. Please do not change any other arguments in the example scripts.
