Skip to content

isolation_forest_prototype#1

Open
prachin-tuladhar wants to merge 5 commits into
mainfrom
prachin
Open

isolation_forest_prototype#1
prachin-tuladhar wants to merge 5 commits into
mainfrom
prachin

Conversation

@prachin-tuladhar

Copy link
Copy Markdown
Collaborator

feat(classical): validate IsolationForest + sklearn setup on toy data

  • Confirm fit/decision_function/predict work as expected in this env
  • Lock in interface shape for Week 2 model class: fit(X) -> score(X) -> predict(X)
  • Sanity-checked on synthetic normal-cluster vs outlier toy data (10/10 caught)

Ref: Task Tracker Week 1 (Prachin)

feat(classical): implement ClassicalDetector with per-class dynamic threshold

- Stub model class wrapping sklearn IsolationForest (fit/score/predict)
- Flip sklearn's raw convention to {0,1} labels, higher score = more anomalous
- Add fit_dynamic_threshold()/predict_dynamic() for per-process-class
  thresholding, following Shamim et al. (2023) rather than a global cutoff
- Smoke-tested on grouped toy data (quiet vs noisy classes): 0 false
  positives, 6/6 injected attacks caught

Ref: Task Tracker Week 2 & 3 (Prachin)
Note: label/threshold convention is my own design choice pending
test(classical): add unit test suite for ClassicalDetector

- 14 tests covering fit/score/predict, dynamic threshold, error
  handling, and reproducibility
- All passing against Week 3 baseline
- Documents score range behavior (not a fixed interval, see
  SCORE_RANGE_NOTES)

Ref: Task Tracker Week 4 (Prachin)

note for me 
python -m pytest test_classical_detector.py -v
cd C:\Users\Asus\Desktop
pip install pytest
feat(classical): add evaluation harness stand-in, tune dynamic threshold k

- evaluate(): FPR/Recall/F1/AUROC, no accuracy (Layman & Roden, Hesford et al.)
- tune_threshold(): sweeps k across ClassicalDetector's dynamic threshold
- Best F1 on toy data at k=3.0: FPR=0.000, Recall=0.933, F1=0.966, AUROC=0.998
- Stand-in until Vignesh's shared harness lands; same interface, drop-in swap

Ref: Task Tracker Week 5 (Prachin)
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.

1 participant