Repository navigation
ECVCDetector: vectorise the score and skip windows seen in training - #397
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task
No issue. ECVC detection was too slow to run on HDFS and BGL (days per detector run).
Description
ECVCOp.calculate_scorecompared 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_scorenow scores all rows at once with numpy. Same formula, same result (sum |m - y| / sum max(m, y), minimum over the rows; stillinffor an empty matrix).detectnow 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?
calculate_scoreon random matrices, anddetectagainst 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.--run-ignored.window_size: 10(BGL and HDFS truncated to 200k rows):Alert rows and scores are identical on all three.
Checklist
Need help on this PR? Tag
@codesmith-botwith what you need.