Skip to content

FICO Segmentation Tutorial

This guide shows the quickest way to segment a portfolio by score bands and turn that into simple portfolio diagnostics.

Problem

Use this workflow when you want to:

  • bucket a portfolio into score bands quickly
  • assign a simple risk grade
  • summarize portfolio mix by FICO band
  • estimate a collateral-based LGD view for the same loans

This is usually the fastest risk-tiering workflow in the package and a common first pass before deeper forecasting or modeling.

Inputs

Minimum input for segmentation:

  • fico_score

Useful additional columns for diagnostics:

  • loan_id
  • principal
  • collateral_value
  • collateral_type

segment_fico() only requires fico_score. calculate_lgd() requires principal and optionally uses collateral columns if they are present.

Code

import pandas as pd

from cranalytics import calculate_fico_mix, calculate_lgd, segment_fico

df = pd.DataFrame(
    {
        "loan_id": [1, 2, 3, 4],
        "fico_score": [780, 690, 640, 590],
        "principal": [10000.0, 9000.0, 12000.0, 7000.0],
        "collateral_value": [8000.0, 2500.0, 0.0, 0.0],
        "collateral_type": ["Vehicle", "Cash", "Unsecured", "Unsecured"],
    }
)

segmented = segment_fico(df)
print(segmented[["loan_id", "fico_score", "fico_band", "risk_grade"]])

mix = calculate_fico_mix(segmented)
print(mix)

lgd = calculate_lgd(df)
diagnostics = segmented.assign(lgd=lgd)
print(diagnostics[["loan_id", "fico_band", "risk_grade", "lgd"]])

Output

This workflow gives you three levels of signal:

  • row-level segmentation via fico_band and risk_grade
  • portfolio mix percentages via calculate_fico_mix(...)
  • loan-level LGD estimates via calculate_lgd(...)

Higher scores map to lower-numbered risk grades. If no collateral is provided, LGD falls back to 1.0 for unsecured exposure.

Common Errors

  • fico_score is missing or outside the 300-850 range. Segmentation validation will fail on bad scores.
  • You call calculate_lgd() without principal. LGD needs exposure even if you are using collateral fields.
  • You expect segmentation to require the full portfolio schema. It does not; only fico_score is required for segment_fico().
  • You pass collateral types outside the supported set. Use values like Real Estate, Vehicle, Equipment, Cash, or Unsecured.

Run the packaged segmentation demo with:

python -m cranalytics.examples.core_segmentation

That packaged demo focuses on banding and risk grades. The tutorial above adds mix and LGD diagnostics on top.