11.3 Model Construction - ravkorsurv/kor-ai-core GitHub Wiki

11.3 Model Construction – Kor.ai Bayesian Network Architecture

This section outlines how Bayesian Networks (BNs) are constructed for each alert typology (e.g., Insider Dealing, Spoofing) in Kor.ai. It includes network principles, file structure, node connections, CPT design, and test harnesses.


🧬 Design Philosophy

  • Use causal reasoning from root causes → behaviors → risk outcome

  • Reuse modular components across models via shared node library

  • Ensure each model is explainable, testable, and API-compatible

  • Support partial evidence input, non-linear propagation, and latent variables


📊 Core BN Structure

Example: Insider Dealing

Access to Info + Role Sensitivity + Negative News
→ Intent to Trade
→ Price Spike + High PnL
→ RiskNode (Insider Risk)

Example: Spoofing

Algo Use + Desk Type
→ Quote Behavior + Cancel Rate
→ Price Move Before Fill
→ RiskNode (Spoofing Risk)

📁 File System Layout

Folder Contents
/models/ JSON model definitions
/components/ Reusable nodes and CPT structures
/payloads/ Example evidence sets for validation
/transformations/ Mapping rules: raw data → node input
/validation/ Model + payload test results

📅 Validation & Testing

Each model is:

  • Checked in Agena UI for CPT logic

  • Validated via /validation/ test cases

  • Compared against known case patterns

Example Test Flow:

python run_test.py --model models/SpoofingModel.json --input payloads/spoofing_case_high.json

⚖️ Explainability

  • Contributors to RiskNode are returned per inference

  • Contributors are mapped (Qx → Label) in UI

  • Each alert logs risk score, evidence, contributors, and rationale


🌐 Workflow for New Model Creation

  1. Draft causal graph with input from SMEs

  2. Identify nodes to reuse from components/

  3. Define any new CPTs (manual or flat)

  4. Save JSON to /models/

  5. Create test payloads in /payloads/

  6. Validate model via CLI or Agena

  7. Attach to alerting pipeline with evidence map


🔮 Future Additions

  • CPT templates for common logic (e.g., 2-of-3 cause effect)

  • Graphical UI builder for SMEs

  • Auto-learning from reviewed alerts (Phase 3)

⚠️ **GitHub.com Fallback** ⚠️