I built the Kestrel Home service as a FastAPI application that predicts pre‑dispatch return risk. It runs with Python 3.10+, uses uvicorn on port 8000, and requires no external cloud API keys.
The service exposes a POST /predict endpoint that scores a single order’s return risk.
- order_id
{
"order_id": "KO26-TEST-001",
"sku": "KH-RV-01",
"payment_mode": "cod",
"sales_channel": "marketplace",
"discount_pct": 20.0,
"qty": 1,
"delivery_pincode": "411001",
"promised_delivery_days": 5,
"customer_prior_orders": 3,
"customer_prior_returns": 2,
"shield_member": "Y",
"is_gift": "N",
"delivery_note": "Call before delivery"
}
- order_id
{
"order_id": "KO26-TEST-001",
"score": 0.7852,
"risk_band": "high",
"recommended_action": "confirm_call",
"action_label": "Trigger Pre-Dispatch Confirmation Call",
"top_3_reasons": [
"Customer has a history of high returns (67% return rate on prior orders).",
"Cash on Delivery (COD) payment mode carries higher rejection and return risk.",
"Shield membership accounts show significantly higher warranty and return claim frequency."
],
"model_version": "1.0.0-logistic-regression",
"threshold_applied": 0.34,
"warnings": []
}
GET /health returns the service health status, loaded model version, and catalog dimensions.
GET /catalog returns the product catalog, valid states, categories, and training clamping ranges.
- score
- risk_band
- recommended_action
- action_label
- top_3_reasons
- model_version
- threshold_applied
- warnings
- sku
- payment_mode
- sales_channel
- discount_pct
- qty
- delivery_pincode
- promised_delivery_days
- customer_prior_orders
- customer_prior_returns
- shield_member
- is_gift
- delivery_note

