Credit risk foundations
Obligor, facility, and portfolio grain
Choose a consistent entity grain before building labels or aggregating exposures.

Purpose
Explain how borrower, account, facility, and portfolio records represent different analytical units.
Key terms
Hover over or focus a term for a quick definition, or open its glossary entry.
Key definitions
- An obligor is the borrower or counterparty whose credit quality is assessed.
- A facility is a contractual lending arrangement; a portfolio is a defined group of exposures.
Portfolio exposure = Σ facility exposure after the approved aggregation and netting rules.Worked example
A borrower with two cards and one line of credit has one obligor and three facilities; report counts at the grain relevant to the question.
Detailed explanation
Many model defects begin as grain mismatches. An application score may be one row per application, a behavioural score one row per account-month, and a portfolio report one row per obligor or facility. If labels are attached at one grain and features at another, one-to-many joins can duplicate outcomes and distort rates.
Maintain durable obligor, facility, account, and application keys, along with effective dates and relationship types. Record the unit used for default assignment, exposure aggregation, collateral allocation, and reporting. When a borrower has several facilities, determine whether default is assigned to the obligor, facility, or both under the purpose-specific definition. Those choices affect sample counts, transition matrices, and downstream PD/LGD/EAD estimates.
Try a reproducible Python example
These examples use synthetic inputs and run locally in a browser worker. Edit the code, run it, and compare its output with the published example.
Runnable Python · local in your browser
Compare expected loss and uncertainty across two distributions
Calculate the probability-weighted mean, variance, and standard deviation for two fully synthetic loss distributions.
Output
Run the code to see the output.
Runtime loads only after you press Run. Code runs in a separate browser worker with a 10-second limit and a 20,000-character output cap. Use synthetic examples only; browser execution is not a secure environment for secrets or sensitive records.
Runnable Python · local in your browser
Calculate WOE and IV from grouped counts
Use synthetic good and bad counts for three ordered scorecard bins. The 0.5 adjustment avoids a zero distribution in this small example.
Output
Run the code to see the output.
Runtime loads only after you press Run. Code runs in a separate browser worker with a 10-second limit and a 20,000-character output cap. Use synthetic examples only; browser execution is not a secure environment for secrets or sensitive records.
Assumptions
- Identifiers are stable across source systems or are connected through a governed crosswalk.
Limitations
- Joint borrowers, guarantees, group structures, and related facilities need explicit rules.
- A simple sum may double-count balances if source feeds overlap.
References
- Basel Framework: IRB approach and credit-risk components — Basel Committee on Banking Supervision
- pandas user guide — pandas documentation
Educational material only. Methods and examples are simplified; state and validate the assumptions required for your use case.