> ## Documentation Index
> Fetch the complete documentation index at: https://docs.avra.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Risk Bands

> Optimal score binning and homogeneous risk groups for operationalizing credit decisions.

## From Scores to Policy

A credit score tells you *how risky* an entity is. **Risk bands** tell you *what to do about it*.

Risk bands (also known as homogeneous risk groups) are score bins where entities within each group behave similarly, while groups are clearly distinct from each other. Unlike arbitrary deciles or fixed ranges, optimal risk bands are **statistically optimized** using both the model score and observed outcomes.

## Why Risk Bands Matter

| Use Case                 | How Risk Bands Help                                                   |
| ------------------------ | --------------------------------------------------------------------- |
| **Policy Cutoffs**       | Set clear approve/review/deny thresholds aligned to observed outcomes |
| **Pricing Tiers**        | Map bins directly to interest rate or limit brackets                  |
| **Portfolio Monitoring** | Track bin migration over time as an early warning system              |
| **Model Validation**     | Verify bins remain separated as new data arrives                      |

## Creating Optimal Bins

We recommend using optimal binning algorithms that maximize separation between groups. The `optbinning` library provides a robust implementation:

```python theme={null}
from optbinning import OptimalBinning

# Create optimal bins from score and outcome
optb = OptimalBinning(name="avra_score", dtype="numerical")
optb.fit(scores, defaults)

# Get bin boundaries and statistics
binning_table = optb.binning_table.build()
print(binning_table)
```

### Alternative Approaches

| Method                        | Description                                            |
| ----------------------------- | ------------------------------------------------------ |
| **Chi-squared binning**       | Merge adjacent bins until chi-squared threshold is met |
| **Weight of Evidence (WoE)**  | Optimize bins for maximum information value            |
| **Equal-frequency quantiles** | Starting point before optimization                     |
| **Business-driven**           | Manual boundaries based on policy requirements         |

## Evaluating HRG Quality

### What You Want to See

Track default rates per bin over time. A well-constructed HRG shows:

* **Clear separation** — Default rates are distinct between adjacent bins
* **Stable PD over time** — Each bin's default rate stays consistent month-over-month
* **Balanced distribution** — Reasonable volume in each bin to support policy decisions

### Warning Signs

* **Line crossings** — When two bins' default rates cross over time, risk distinction is breaking down. This indicates the model may need recalibration.

* **Concentration** — If 80% of entities fall in 2-3 bins, setting policy cutoffs becomes difficult. Consider adjusting bin boundaries or reviewing score distribution.

* **Drift** — Systematic movement of default rates within bins signals model degradation. Monitor for gradual shifts that compound over time.

## Monitoring Over Time

We recommend visualizing default rates per bin across cohorts:

```python theme={null}
import matplotlib.pyplot as plt

# Each line represents a score bin
# X-axis: time (cohort month)
# Y-axis: realized default rate

for bin_name, data in bin_cohort_data.items():
    plt.plot(data['months'], data['default_rate'], label=bin_name)

plt.xlabel('Cohort Month')
plt.ylabel('Default Rate')
plt.legend()
plt.title('HRG Stability Over Time')
```

**Healthy pattern**: Parallel lines that maintain separation over time.

**Concerning pattern**: Lines that converge, cross, or show systematic drift.

<Info>
  We work with clients to define and monitor risk bands as part of model deployment. This includes tracking bin stability over time and alerting when recalibration may be needed.
</Info>
