How ogunsolaolalekanoo-dev/behavioral-anomaly-detection works
This repository implements behavioral anomaly detection for authentication events. The documented workflow generates synthetic login events, derives per-user behavioral baselines and deviation features, trains Isolation Forest and autoencoder detectors, then serves real-time risk scores and risk-adaptive authentication decisions through FastAPI. Evaluation and anomaly-distribution plots are also part of the detector capability. The API and training code show the principal calls and artifact handoffs; generated data and model files are runtime artifacts, not files present in the supplied tree.
Main entry points: api.py Scoring API · detector.py Model Training · features.py Feature Engineering · simulator.py Event Simulator
Components 14
Event Simulation
- Event Simulator
src/simulator.py - Auth Event Data
Behavioral Features
- Feature Engineering
src/features.py - User Baselines
- Feature Data
Detection Models
- Model Training
src/detector.py - Trained Models
- Model Evaluation
src/detector.py
Risk Scoring
- Scoring API
src/api.py - Request Features
src/api.py - Anomaly Scoring
src/detector.py - Risk Decision
src/api.py - Risk Response
src/api.py
Other components
- Auth Client
Connections 17
- Event Simulator → Auth Event Data: writes events
src/simulator.py - Auth Event Data → Feature Engineering: loads events
src/features.py - Feature Engineering → User Baselines: writes baselines
src/features.py - Feature Engineering → Feature Data: writes features
src/features.py - Auth Event Data → Model Training: loads events
src/detector.py - Model Training → Feature Engineering: calls build_features
src/detector.py - Model Training → Trained Models: saves models
src/detector.py - Model Training → Model Evaluation: evaluates scores
src/detector.py - Model Evaluation → Trained Models: plots results
src/detector.py - Auth Client → Scoring API: submits event
README.md - Scoring API → Trained Models: loads models
src/api.py - Scoring API → User Baselines: loads baselines
src/api.py - Scoring API → Request Features: prepares event
src/api.py - Request Features → Anomaly Scoring: requests scores
src/api.py - Anomaly Scoring → Trained Models: scores with
src/detector.py - Scoring API → Risk Decision: assigns tier
src/api.py - Scoring API → Risk Response: returns result
src/api.py