/api/credit_risk_explain

Header
X-Customer-Api-Id: <uuid>
X-Secret: <secret>
Content-Type: application/json
Request Body Schema
// Request Body Schema
{
  "applicant": {
    "id": string,                   // copied back for tracing
    "features": {                   // same schema as scoring
      "<feature_name>": number|string,
      …
    }
  },
  "training_sample": [              // ≥50 rows WITH label for local explainer
    {
      "id": string,
      "features": {                 // numeric or categorical
        "<feature_name>": number|string,
        …
      },
      "label": 0|1                  // 0 = good payer, 1 = default
    },
    …
  ]
}
Example Request Body
// Example Request
{
  "applicant": {
    "id": "app-XYZ",
    "features": {
      "income": 42000,
      "age": 29,
      "country": "BR",
      "late_payments": 2
    }
  },
  "training_sample": [
    { "id": "s-001", "features": { "income": 55000, "age": 34, "country": "BR", "late_payments": 0 }, "label": 0 },
    // … 35 good (label=0) …
    { "id": "s-036", "features": { "income": 18000, "age": 22, "country": "BR", "late_payments": 4 }, "label": 1 },
    // … 15 bad (label=1) …
    { "id": "s-050", "features": { "income": 18500, "age": 24, "country": "BR", "late_payments": 8 }, "label": 1 }
  ]
}
Example Response Body
// Example Response
{
  "probability": 0.27,
  "explanation": {
    "income": -0.13,
    "age": +0.02,
    "late_payments": +0.09,
    "country_BR": +0.01
  },
  "interpretation": "PD 27% ⇒ MEDIUM risk. income -0.13 ↓ risk; age +0.02 ↑ risk; late_payments +0.09 ↑ risk; country_BR +0.01 ↑ risk."
}
Description

• Generates a local explainability report for one applicant. • Uses your supplied training_sample to fit a local surrogate (LIME) or Tree‐SHAP explainer. • Returns the PD, per‐feature contributions, and a human‐readable interpretation.

Business Usage

1. Slice ~50 historical labeled applicants from your last /credit_risk_score batch. 2. POST the applicant plus the slice to /credit_risk_explain. 3. Receive probability, explanation (feature impacts), and interpretation string. 4. Surface these details to credit officers or regulators for decision justification.

← Back to all routes