Dataset Preview
Duplicate
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed because of a cast error
Error code:   DatasetGenerationCastError
Exception:    DatasetGenerationCastError
Message:      An error occurred while generating the dataset

All the data files must have the same columns, but at some point there are 1 new columns ({'anomaly_type'}) and 1 missing columns ({'band'}).

This happened while the csv dataset builder was generating data using

hf://datasets/ranzouu/anomaly-detection-benchmark/runs/benchmark_by_type.csv (at revision c9324c72d11f2ebc8f312b8847c3347129a53adc), ['hf://datasets/ranzouu/anomaly-detection-benchmark@c9324c72d11f2ebc8f312b8847c3347129a53adc/runs/benchmark_by_magnitude.csv', 'hf://datasets/ranzouu/anomaly-detection-benchmark@c9324c72d11f2ebc8f312b8847c3347129a53adc/runs/benchmark_by_type.csv', 'hf://datasets/ranzouu/anomaly-detection-benchmark@c9324c72d11f2ebc8f312b8847c3347129a53adc/runs/benchmark_records.csv', 'hf://datasets/ranzouu/anomaly-detection-benchmark@c9324c72d11f2ebc8f312b8847c3347129a53adc/runs/benchmark_summary.csv']

Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)
Traceback:    Traceback (most recent call last):
                File "/usr/local/lib/python3.14/site-packages/datasets/builder.py", line 1856, in _prepare_split_single
                  writer.write_table(table)
                  ~~~~~~~~~~~~~~~~~~^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/arrow_writer.py", line 811, in write_table
                  self._write_table(pa_table, writer_batch_size=writer_batch_size)
                  ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/arrow_writer.py", line 822, in _write_table
                  pa_table = table_cast(pa_table, self._schema)
                File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2381, in table_cast
                  return cast_table_to_schema(table, schema)
                File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2309, in cast_table_to_schema
                  raise CastError(
                  ...<3 lines>...
                  )
              datasets.table.CastError: Couldn't cast
              method: string
              anomaly_type: string
              detected: int64
              total: int64
              detection_rate: double
              -- schema metadata --
              pandas: '{"index_columns": [{"kind": "range", "name": null, "start": 0, "' + 862
              to
              {'method': Value('string'), 'band': Value('string'), 'detected': Value('int64'), 'total': Value('int64'), 'detection_rate': Value('float64')}
              because column names don't match
              
              During handling of the above exception, another exception occurred:
              
              Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1379, in compute_config_parquet_and_info_response
                  parquet_operations, partial, estimated_dataset_info = stream_convert_to_parquet(
                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~^
                      builder, max_dataset_size_bytes=max_dataset_size_bytes
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  )
                  ^
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 956, in stream_convert_to_parquet
                  builder._prepare_split(split_generator=splits_generators[split], file_format="parquet")
                  ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/builder.py", line 1702, in _prepare_split
                  for job_id, done, content in self._prepare_split_single(
                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~^
                      gen_kwargs=gen_kwargs, job_id=job_id, **_prepare_split_args
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  ):
                  ^
                File "/usr/local/lib/python3.14/site-packages/datasets/builder.py", line 1858, in _prepare_split_single
                  raise DatasetGenerationCastError.from_cast_error(
                  ...<4 lines>...
                  )
              datasets.exceptions.DatasetGenerationCastError: An error occurred while generating the dataset
              
              All the data files must have the same columns, but at some point there are 1 new columns ({'anomaly_type'}) and 1 missing columns ({'band'}).
              
              This happened while the csv dataset builder was generating data using
              
              hf://datasets/ranzouu/anomaly-detection-benchmark/runs/benchmark_by_type.csv (at revision c9324c72d11f2ebc8f312b8847c3347129a53adc), ['hf://datasets/ranzouu/anomaly-detection-benchmark@c9324c72d11f2ebc8f312b8847c3347129a53adc/runs/benchmark_by_magnitude.csv', 'hf://datasets/ranzouu/anomaly-detection-benchmark@c9324c72d11f2ebc8f312b8847c3347129a53adc/runs/benchmark_by_type.csv', 'hf://datasets/ranzouu/anomaly-detection-benchmark@c9324c72d11f2ebc8f312b8847c3347129a53adc/runs/benchmark_records.csv', 'hf://datasets/ranzouu/anomaly-detection-benchmark@c9324c72d11f2ebc8f312b8847c3347129a53adc/runs/benchmark_summary.csv']
              
              Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

method
string
band
string
detected
int64
total
int64
detection_rate
float64
iqr
queda 0.65-0.75
1
4
0.25
iqr
queda <0.65
2
2
1
iqr
spike 2.0-2.5x
2
2
1
iqr
spike 2.5-3.0x
3
3
1
iqr
spike >3.0x
1
1
1
stl
queda 0.65-0.75
4
4
1
stl
queda <0.65
2
2
1
stl
spike 2.0-2.5x
2
2
1
stl
spike 2.5-3.0x
3
3
1
stl
spike >3.0x
1
1
1
zscore
queda 0.65-0.75
0
4
0
zscore
queda <0.65
0
2
0
zscore
spike 2.0-2.5x
2
2
1
zscore
spike 2.5-3.0x
3
3
1
zscore
spike >3.0x
1
1
1
iqr
null
6
6
1
iqr
null
3
6
0.5
stl
null
6
6
1
stl
null
6
6
1
zscore
null
6
6
1
zscore
null
0
6
0
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
zscore
null
null
null
null
End of preview.

Anomaly Detection Benchmark — receita diária (ground truth por construção)

Benchmark para detecção de anomalias em séries temporais de métricas de negócio, com rótulo perfeito por construção: a série é sintética (seed fixa) e as anomalias são injetadas em datas conhecidas. Inclui as predições de três detectores estatísticos clássicos (z-score, IQR, STL) já avaliadas contra o rótulo.

Faz parte do LeadForge Anomaly Detector — código, CLI e testes no repositório.

Protocolo de construção

  1. Série sintética determinística (seed=20260101): 180 dias de receita diária a partir de R$ 120 mil, com tendência linear suave, sazonalidade semanal (fim de semana mais fraco) e ruído multiplicativo (σ = 2.5%).
  2. Injeção de anomalias: 12 eventos em datas conhecidas — 6 spikes (×2.3 a ×3.2) e 6 quedas (×0.58 a ×0.75). O rótulo é a data de injeção: ground truth exato, sem ambiguidade.
  3. Detectores do pacote original (nenhuma lógica duplicada no script de construção): z-score (threshold 3), IQR (k = 1.5), STL (período 7, robusto, z-score modificado 3).
  4. Avaliação: precision / recall / F1 por método, por tipo (spike vs. queda) e por banda de magnitude.

Resultados

Método Precision Recall F1 Leitura
z-score 1.000 0.500 0.667 pega todos os spikes (6/6) e nenhuma queda (0/6)
IQR 1.000 0.750 0.857 melhor F1, zero falso positivo; perde quedas brandas
STL 0.550 1.000 0.714 detecta as 12, ao custo de 10 falsos positivos

Por tipo (detection rate): spikes 6/6 nos três métodos; quedas: IQR 3/6, STL 6/6, z-score 0/6.

Achado: detecção de queda é o problema difícil neste regime. Uma queda comprime a média e o desvio da janela, então o próprio desvio anômalo entra no denominador do z-score e o evento desaparece — daí o 0/6. Spike não sofre esse efeito (infla o desvio, mas o ponto sai da banda). Baldes de magnitude são definidos por tipo (spike ×2.0–2.5 vs. queda ×0.65–0.75) porque os fatores não comparam na mesma escala.

Por banda de magnitude (detection rate):

Método spike 2.0–2.5× spike 2.5–3.0× spike >3.0× queda 0.65–0.75 queda <0.65
z-score 2/2 3/3 1/1 0/4 0/2
IQR 2/2 3/3 1/1 1/4 2/2
STL 2/2 3/3 1/1 4/4 2/2

Uso

import json, pandas as pd

serie = pd.DataFrame(json.load(open("benchmark_metrics.json")))
rotulos = pd.DataFrame(json.load(open("benchmark_expected.json")))
records = pd.read_csv("runs/benchmark_records.csv")   # 540 linhas: 3 métodos × 180 pontos

print(rotulos.head())
print(records.groupby("method")[["predicted"]].sum())

Reproduzir tudo (série + detecção + métricas) com o pacote original:

git clone https://github.com/ranzouu/leadforge-anomaly-detector
cd leadforge-anomaly-detector && pip install -e .
python3 scripts/build_benchmark.py

Arquivos

Arquivo Conteúdo
benchmark_metrics.json série sintética: 180 pontos {date, metric="revenue", value}
benchmark_expected.json 12 rótulos {date, metric, is_anomaly, type, magnitude, factor}
runs/benchmark_records.csv predição por ponto × método vs. rótulo (540 linhas)
runs/benchmark_summary.csv tp/fp/fn + precision/recall/F1 por método
runs/benchmark_by_type.csv detection rate por método × tipo
runs/benchmark_by_magnitude.csv detection rate por método × banda
scripts/build_benchmark.py construtor do benchmark (série + injeção + avaliação)
LICENSE MIT

Limitações (leia antes de usar)

  • Série sintética de um único trimestre e uma única métrica (receita). O valor aqui é o protocolo — construção de ground truth por injeção + comparação cega de métodos — não a configuração específica.
  • Números de precision/recall são deste regime (sazonalidade semanal, σ=2.5%, magnitudes ×2–3). Em produção, com dados reais, os thresholds dos métodos precisam de recalibração.
  • STL exige ≥ 12 pontos por série (período 7); em séries curtas ele degrada para "não detecta".
  • O dataset de exemplo original do repo (25 pontos, 2 rótulos, receita de demonstração) não é este benchmark — os dois coexistem no repositório.
Downloads last month
-

Space using ranzouu/anomaly-detection-benchmark 1