Skip to content

feat(analysis): add anomaly detection module (Benford, HHI, round values) #13

Description

@guidevit-dealsmartai

Summary

Bring statistical anomaly detection functions from CEAP-Playbook into VigiaBR's processing pipeline.

Motivation

VigiaBR has robust data collection infrastructure (7 sources, Scrapy spiders, Airflow DAGs) but zero anomaly detection code. The CEAP-Playbook repository has battle-tested statistical functions that detect expense anomalies:

  • Benford's Law — chi-squared test on first-digit distribution
  • HHI (Herfindahl-Hirschman Index) — supplier concentration measurement
  • Round values detection — flags suspiciously round amounts

These are exactly the building blocks needed to populate VigiaBR's Inconsistencia model and begin SCI scoring.

Current State

  • pipeline/schemas/models/inconsistencia.py — model exists but nothing generates records
  • pipeline/processing/processing/transformers/camara.py — skips despesa records (_SKIPPED_TYPES)
  • No analysis/detection module exists in the pipeline

Acceptance Criteria

  • Analysis module created in pipeline/processing/processing/analyzers/
  • Benford, HHI, and round values functions adapted from CEAP-Playbook
  • Camara transformer processes expense records (remove from _SKIPPED_TYPES)
  • Analyzers generate InconsistenciaCreateSchema records when anomalies detected
  • Unit tests for all analyzer functions
  • Constants/thresholds configurable

References

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions