Post

KAIROS: Decision Intelligence System for Risk & Demographic Analytics

Open in Github Page

KAIROS: Decision Intelligence System

Standard gradient-boosted models output scores, not decisions. KAIROS is a production-grade risk intelligence engine that turns hybrid ensembles into a mission-critical decision system with statistical calibration, precision gates, and full observability for banking risk and demographic analytics.

LightGBM · CatBoost · Isotonic calibration · precision gates · Prometheus/Grafana · FastAPI · Docker.

KAIROS dashboard


Project Overview

KAIROS transforms ML from a classification tool into a Decision Engine. By acknowledging uncertainty and enforcing high-precision gates, it reduces manual review costs by ~70% while achieving 96% decision accuracy on high-stakes tasks like credit underwriting and fraud risk.

The system handles diverse data contracts through a unified Discriminated Union architecture:

  • Banking Risk (Home Credit) — financial ratios, credit strength, loan underwriting
  • Census Analytics (UCI Adult) — demographic distributions and baseline benchmarking

Type-safe inference via Pydantic v2 schemas validates every request before it hits the model. Every experiment is logged via MLflow, tracking code version, data hashes, and metric curves.


Key Results

Run the canonical evaluation suite with:

1
PYTHONPATH=. python src/kairos/evaluate.py
DomainBaseline AccuracyKAIROS PrecisionNotes
Banking Risk~74%93.4%+19% via calibrated loan underwriting
Census Data~81%96.1%High-precision demographic gates
Drift LogicNoneEnforcedAuto-alerting for >15% rejection spike
InferenceAmbiguousType-SafeDiscriminated Union schemas

A production Hybrid Ensemble (LightGBM/CatBoost) runs behind an automated regression gate protecting logic across a 16k+ sample test set. Predictions passing the precision gate are auto-decided; the rest route to human review.

Statistical calibration: ECE < 0.02

Standard GBDT models produce biased scores, not true probabilities. KAIROS applies Isotonic Regression after Optuna HPO to normalize outputs:

  • ECE reduced from ~0.15 to < 0.02
  • An 80% confidence score actually represents an ~80% success rate

Architecture

1
2
3
4
5
Raw Data → Domain Transformers → Optuna HPO & Trainer → MLflow Registry
         → Isotonic Calibration → Serialized Engines → FastAPI Multi-Engine
         → Discriminated Union Contract → Precision Gate
         → Auto Decision / Human Review
         → Prometheus → Alertmanager / Grafana

Production hardening

  • X-API-KEY authentication on all prediction routes
  • Adaptive rate limiting via slowapi
  • Security scanning — Snyk, Bandit, pip-audit on every CI push
  • Secret management — Pydantic-Settings with encrypted .env injections
  • Async batching — Celery + Redis queue for high-throughput workloads
  • Stateless design — horizontal scaling without sticky sessions; /health and /metrics for load balancers

Observability

KAIROS ships a full production observability suite:

  1. Prometheus — scrapes latency and decision-mix metrics every 5 seconds
  2. Alertmanager — real-time Gmail SMTP alerts on critical rejection drift
  3. Grafana dashboards
    • Banking: Risk Strategy — underwriting load and loss prevention
    • Census: Demographic Analytics — baseline model stability and trends
  4. Integrated web UI — simulation and case review frontend

CI/CD Gates

Every push runs through production-ready logic gates:

  1. Linting — Ruff code quality checks
  2. Security — mandatory Snyk, Bandit, and pip-audit scans
  3. Coverage — enforced 82% code coverage floor
  4. Precision gate — CI fails automatically if precision drops below 95% on the holdout set

Repository Structure

  • src/kairos/api/ — FastAPI engines and Discriminated Union contracts
  • src/kairos/web/ — real-time frontend dashboard and simulator
  • src/kairos/core/ — ensembles, calibration, and policy logic
  • src/kairos/data/ — domain-specific transformers and loaders
  • docker/ — Prometheus, Alertmanager, Grafana orchestration
  • docs/ — architecture, onboarding, and research deep-dives
  • tests/integration/ — programmatic verification of decision logic and metrics

Getting Started

1
2
3
git clone https://github.com/AbhijitMore/kairos.git
cd kairos
docker compose up --build -d

Access the API at http://localhost:8000, Grafana at http://localhost:3000, and the integrated dashboard via the web UI.


Design Trade-offs

Current limitations:

  • Cold start latency — loading the full 10-model weighted ensemble takes ~3-5s at container startup
  • Local MLflow — model storage on a local volume; multi-region production would migrate to S3/GCS

Roadmap:

  • Automated drift detection via Prometheus/Alertmanager
  • Shadow mode for running new model versions in parallel
  • Kubernetes Helm charts with HPA

Why It Matters

KAIROS treats decision quality as a first-class metric, not just accuracy on a leaderboard. Hybrid ensembles, isotonic calibration, precision gates, and drift alerting are composed into a stateless microservice stack where every claim is measured, gated in CI, and observable in production.


Contributions and feedback are welcome.


This post is licensed under CC BY 4.0 by the author.