vilhess/fmano

0

stars

2

commits

Jupyter Notebook

primary language

Sep 10, 2026

updated

Browse cluster: Time Series Anomaly Detection

README

Fusing Raw-Window and Learned-Representation Memory Banks from TSFMs for Time-Series Anomaly Detection

Code and experiment scripts for the paper: Fusing Raw-Window and Learned-Representation Memory Banks from TSFMs for Time-Series Anomaly Detection. We compare four ways of turning a frozen time-series foundation model (TSFM) into an anomaly detector — forecast error, a cosine/euclidean memory bank, the bank with an amplitude-preserving correction (PAI), and a raw-window kNN detector — across five backbones (TiRex, FlowState, T0-alpha, Chronos-2, Toto-2) on TSB-AD-U, and show that fusing the kNN detector with any backbone's memory bank beats every one of those interfaces alone, for every backbone, on both VUS-ROC and VUS-PR.

Layout

  • models/ — one file per detector (encoder + scoring logic), dispatched by name through TSB_AD/model_wrapper.py. Shared building blocks: bank_scoring.py (memory-bank construction/scoring), pai.py (the magG/T2 amplitude correction), KNNBankFusion.py / KNNDetectorFusion.py (the score-level fusion).
  • TSB_AD/HP_list.py — hyperparameter grids (Uni_algo_HP_dict) and the tuned optima used for evaluation (Optimal_Uni_algo_HP_dict).
  • benchmark_exp/ — tuning, evaluation, and every script that reproduces a number or figure in the paper (below).
  • Datasets/File_List/ — TSB-AD-U's tuning (48 series) and evaluation (350 series) file lists.

Setup

Get TSB-AD-U from the original benchmark, then point dataset_dir in benchmark_exp/configs.py at your local copy.

Extra dependency per backbone: tirex (TiRex); IBM's tsfm_public, vendored in other_modules/ (FlowState); tfc-t0, install with --no-deps to avoid conflicts (T0-alpha); chronos-forecasting (Chronos-2); toto2, requires Python ≥ 3.12 (Toto-2). Checkpoints download from the Hugging Face Hub on first use.

Detector naming

Every --AD_Name follows one of these patterns ({B} = TiRex, FlowState, T0alpha, Chronos2, or Toto2):

Paper interface--AD_Name pattern
Forecaster{B}Forecaster
Bank (cosine / euclidean){B}BankEmbeddingCosine / {B}BankEmbeddingEuclidean
Bank+PAI{B}BankEmbeddingPAI
kNN (raw window, no backbone)KNN
Bank+kNNKNN{B}Fusion
Bank+PAI+kNNKNN{B}PAIFusion
Windowed-statistic floorOneLiner
Amplitude-only diagnostic (not in the paper's tables)AmplitudeOnly

Reproducing the paper

Run the tuning/evaluation commands from the repository root; the analysis scripts from inside benchmark_exp/ (they read benchmark_exp/eval/ with relative paths).

Hyperparameter tuning (48-series validation split, grids in Uni_algo_HP_dict):

python -m benchmark_exp.HP_Tuning_U --AD_Name TiRexBankEmbeddingPAI

Writes every grid point's metrics to benchmark_exp/eval/HP_tuning/uni/. The resulting optima are already frozen into Optimal_Uni_algo_HP_dict, so this step is only needed to reproduce the tuning itself, not to evaluate.

Evaluation (350-series split, tuned optimum from Optimal_Uni_algo_HP_dict):

python -m benchmark_exp.Run_Detector_U --AD_Name TiRexBankEmbeddingPAI

Writes one row per file, incrementally, to benchmark_exp/eval/metrics/uni/. Repeat for every --AD_Name in TSB_AD.model_wrapper.AD_Pool to reproduce the full grid.

Table I and Fig. 1 (family comparison, generalization across backbones):

cd benchmark_exp
python make_main_table.py                        # per-family mean VUS-ROC/VUS-PR + average rank
python make_fig_critical_difference_categories.py  # Nemenyi groups (the table's superscripts)
python make_fig_generalization.py                # Fig. 1

Table II and the correlation numbers in Sec. IV-C (PAI's gain alone vs. inside the fusion; the 0.19→0.63 / 0.49→0.78 correlation shift):

cd benchmark_exp
python compute_pai_delta_table.py
python compute_knn_pai_correlation.py

Everything under benchmark_exp/figs/ (tables and figures) and benchmark_exp/eval/ (raw per-file results) is regenerated by the commands above — nothing there needs to be edited by hand.

Credits

Benchmark: TSB-AD (Qiu & Paparrizos). Backbones: TiRex (NX-AI), FlowState (IBM Research, research checkpoint, non-commercial use), T0-alpha (The Forecasting Company), Chronos-2 (Amazon), Toto-2 (Datadog).

Contributors

vilhess

2 commits

vilhess/fmano

0

stars

2

commits

Jupyter Notebook

primary language

Sep 10, 2026

updated

Browse cluster: Time Series Anomaly Detection

README

Fusing Raw-Window and Learned-Representation Memory Banks from TSFMs for Time-Series Anomaly Detection

Code and experiment scripts for the paper: Fusing Raw-Window and Learned-Representation Memory Banks from TSFMs for Time-Series Anomaly Detection. We compare four ways of turning a frozen time-series foundation model (TSFM) into an anomaly detector — forecast error, a cosine/euclidean memory bank, the bank with an amplitude-preserving correction (PAI), and a raw-window kNN detector — across five backbones (TiRex, FlowState, T0-alpha, Chronos-2, Toto-2) on TSB-AD-U, and show that fusing the kNN detector with any backbone's memory bank beats every one of those interfaces alone, for every backbone, on both VUS-ROC and VUS-PR.

Layout

  • models/ — one file per detector (encoder + scoring logic), dispatched by name through TSB_AD/model_wrapper.py. Shared building blocks: bank_scoring.py (memory-bank construction/scoring), pai.py (the magG/T2 amplitude correction), KNNBankFusion.py / KNNDetectorFusion.py (the score-level fusion).
  • TSB_AD/HP_list.py — hyperparameter grids (Uni_algo_HP_dict) and the tuned optima used for evaluation (Optimal_Uni_algo_HP_dict).
  • benchmark_exp/ — tuning, evaluation, and every script that reproduces a number or figure in the paper (below).
  • Datasets/File_List/ — TSB-AD-U's tuning (48 series) and evaluation (350 series) file lists.

Setup

Get TSB-AD-U from the original benchmark, then point dataset_dir in benchmark_exp/configs.py at your local copy.

Extra dependency per backbone: tirex (TiRex); IBM's tsfm_public, vendored in other_modules/ (FlowState); tfc-t0, install with --no-deps to avoid conflicts (T0-alpha); chronos-forecasting (Chronos-2); toto2, requires Python ≥ 3.12 (Toto-2). Checkpoints download from the Hugging Face Hub on first use.

Detector naming

Every --AD_Name follows one of these patterns ({B} = TiRex, FlowState, T0alpha, Chronos2, or Toto2):

Paper interface--AD_Name pattern
Forecaster{B}Forecaster
Bank (cosine / euclidean){B}BankEmbeddingCosine / {B}BankEmbeddingEuclidean
Bank+PAI{B}BankEmbeddingPAI
kNN (raw window, no backbone)KNN
Bank+kNNKNN{B}Fusion
Bank+PAI+kNNKNN{B}PAIFusion
Windowed-statistic floorOneLiner
Amplitude-only diagnostic (not in the paper's tables)AmplitudeOnly

Reproducing the paper

Run the tuning/evaluation commands from the repository root; the analysis scripts from inside benchmark_exp/ (they read benchmark_exp/eval/ with relative paths).

Hyperparameter tuning (48-series validation split, grids in Uni_algo_HP_dict):

python -m benchmark_exp.HP_Tuning_U --AD_Name TiRexBankEmbeddingPAI

Writes every grid point's metrics to benchmark_exp/eval/HP_tuning/uni/. The resulting optima are already frozen into Optimal_Uni_algo_HP_dict, so this step is only needed to reproduce the tuning itself, not to evaluate.

Evaluation (350-series split, tuned optimum from Optimal_Uni_algo_HP_dict):

python -m benchmark_exp.Run_Detector_U --AD_Name TiRexBankEmbeddingPAI

Writes one row per file, incrementally, to benchmark_exp/eval/metrics/uni/. Repeat for every --AD_Name in TSB_AD.model_wrapper.AD_Pool to reproduce the full grid.

Table I and Fig. 1 (family comparison, generalization across backbones):

cd benchmark_exp
python make_main_table.py                        # per-family mean VUS-ROC/VUS-PR + average rank
python make_fig_critical_difference_categories.py  # Nemenyi groups (the table's superscripts)
python make_fig_generalization.py                # Fig. 1

Table II and the correlation numbers in Sec. IV-C (PAI's gain alone vs. inside the fusion; the 0.19→0.63 / 0.49→0.78 correlation shift):

cd benchmark_exp
python compute_pai_delta_table.py
python compute_knn_pai_correlation.py

Everything under benchmark_exp/figs/ (tables and figures) and benchmark_exp/eval/ (raw per-file results) is regenerated by the commands above — nothing there needs to be edited by hand.

Credits

Benchmark: TSB-AD (Qiu & Paparrizos). Backbones: TiRex (NX-AI), FlowState (IBM Research, research checkpoint, non-commercial use), T0-alpha (The Forecasting Company), Chronos-2 (Amazon), Toto-2 (Datadog).

Contributors

vilhess

2 commits

Languages

Jupyter Notebook

63.8%

Python

36.1%