Skip to content

ECVCDetector: vectorise the score and skip windows seen in training - #397

Merged
viktorbeck98 merged 1 commit into
developmentfrom
feat/ecvc-fast-scoring
Oct 31, 2026
Merged

viktorbeck98 merged 1 commit into
developmentfrom
feat/ecvc-fast-scoring

Conversation

@viktorbeck98

@viktorbeck98 viktorbeck98 commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Task

No issue. ECVC detection was too slow to run on HDFS and BGL (days per detector run).

Description

ECVCOp.calculate_score compared each detection window with every learned count vector in a Python loop, so the cost per log line grew with the number of learned vectors.

  • calculate_score now scores all rows at once with numpy. Same formula, same result (sum |m - y| / sum max(m, y), minimum over the rows; still inf for an empty matrix).
  • A window equal to a learned vector scores 0, which never exceeds the threshold. detect now returns early for those, using a set of the learned vectors (known_vecs, training split only). The key is built from the vector that would be scored, so windows containing eventID -1 are handled exactly as the score handles them.

No config or behaviour change: alerts and scores are identical.

How Has This Been Tested?

  • New tests compare against the old row loop: calculate_score on random matrices, and detect against a full scan over random windows, including validation-split vectors and eventID -1. A third test checks that a window seen in training skips the scan.
  • ECVC, persistence and pipeline tests pass, including --run-ignored.
  • Old vs new on real data at cut 0.5, with ECVC at window_size: 10 (BGL and HDFS truncated to 200k rows):
dataset lines detected learned vectors alerts old / new old new
AIT Firewall (russell_mitchell) 30k 157 8,515 / 8,515 1.04 ms/line 0.22 ms/line
BGL 30k 841 814 / 814 7.0 ms/line 1.7 ms/line
HDFS 20k 1,168 5 / 5 6.9 ms/line 0.21 ms/line

Alert rows and scores are identical on all three.

Checklist

  • This Pull-Request goes to the development branch.
  • I have successfully run prek locally.
  • I have added tests to cover my changes.
  • I have linked the issue-id to the task-description.
  • I have performed a self-review of my own code

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

calculate_score compared a window with each learned count vector in a
Python loop, so detection cost grew with the number of learned vectors
and made HDFS and BGL take days. It now scores all rows at once.

A window equal to a learned vector scores 0, which never exceeds the
threshold, so detect returns early for those via a set of the learned
vectors. The key is built from the scored vector, so eventID -1 is
handled the same way as in the score.

Alerts and scores are unchanged. Old vs new at cut 0.5 (BGL and HDFS
truncated to 200k rows): identical alerts on Firewall_russell_mitchell,
BGL and HDFS; detection 5x, 4x and 32x faster.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@viktorbeck98
viktorbeck98 requested a review from ipmach October 29, 2026 15:47

@ipmach ipmach left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@viktorbeck98
viktorbeck98 merged commit 965ccf2 into development Oct 31, 2026
4 checks passed
@viktorbeck98
viktorbeck98 deleted the feat/ecvc-fast-scoring branch October 31, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants