Roll rate analysis for credit risk scorecards.
Project description
Roll Rate Analysis
Roll rate analysis is a credit-risk technique used to define the target variable when building Application or Behavioural scorecards. It's an iterative process — this package parametrises the moving parts so each iteration is a few lines of code rather than a fresh notebook.
The library has zero pandas dependency: inputs and outputs are Polars frames.
Installation
From PyPI:
uv add roll-rate-analysis # uv projects
pip install roll-rate-analysis # plain pip
Requires Python 3.10 or newer.
What's in the box
Two classes, one method each:
| Class | Use case |
|---|---|
MOMRollRateTable |
Transition matrix between two consecutive months. |
SnapshotRollRateTable |
Transition matrix between an observation window and a performance window around a snapshot month. |
Both expose compute() (full transition matrix) and reduce() (roll_down / stable / roll_up summary). Both return polars DataFrames whose first column (from_state) holds the row label.
Quick start
from roll_rate_analysis import MOMRollRateTable
table = MOMRollRateTable(
"data/jan.csv",
"data/feb.csv",
unique_key_col="id",
delinquency_col="delq",
max_delq=6,
)
table.compute() # polars.DataFrame, full transition matrix
table.reduce() # polars.DataFrame, roll_down / stable / roll_up percentages
In-memory polars frames work too:
import polars as pl
from roll_rate_analysis import SnapshotRollRateTable
snap = pl.read_csv("data/snap.csv")
obs = [pl.scan_csv(p) for p in ["data/obs1.csv", "data/obs2.csv"]]
perf = [pl.scan_csv(p) for p in ["data/perf1.csv", "data/perf2.csv"]]
table = SnapshotRollRateTable(
snap, obs, perf,
unique_key_col="id",
delinquency_col="delq",
detailed=True,
granularity=2,
)
table.compute()
See the notebooks under examples/ for end-to-end walkthroughs.
Development
This project uses uv. Clone and bootstrap with:
git clone https://github.com/alexliap/roll_rate_analysis.git
cd roll_rate_analysis
uv sync --dev
Run the test suite, linter, and formatter:
uv run pytest
uv run ruff check .
uv run ruff format .
Pre-commit hooks (ruff + standard checks) keep the tree clean:
uv run pre-commit install
uv run pre-commit run --all-files
License
MIT — see LICENSE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file roll_rate_analysis-0.2.0.tar.gz.
File metadata
- Download URL: roll_rate_analysis-0.2.0.tar.gz
- Upload date:
- Size: 20.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
635a84bb6eca4fe6b7ff6730e6c5b8ac531bb7391bf3eecfcf19626fdf138521
|
|
| MD5 |
19faf0ed4052b157f60aa460e6d46d85
|
|
| BLAKE2b-256 |
efe6532a00ffc4e2253c4861f3529500a90f7200a25db075b1b7fc3059e86ebe
|
Provenance
The following attestation bundles were made for roll_rate_analysis-0.2.0.tar.gz:
Publisher:
publish-package.yaml on alexliap/roll_rate_analysis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
roll_rate_analysis-0.2.0.tar.gz -
Subject digest:
635a84bb6eca4fe6b7ff6730e6c5b8ac531bb7391bf3eecfcf19626fdf138521 - Sigstore transparency entry: 1505649258
- Sigstore integration time:
-
Permalink:
alexliap/roll_rate_analysis@47f82f0a601074d32c69572ba24dd4fb79b4775a -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/alexliap
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yaml@47f82f0a601074d32c69572ba24dd4fb79b4775a -
Trigger Event:
release
-
Statement type:
File details
Details for the file roll_rate_analysis-0.2.0-py3-none-any.whl.
File metadata
- Download URL: roll_rate_analysis-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92bf9be08dae3706d4b6a65f4283546ae9995ccabc6c72d3ca163280ef335beb
|
|
| MD5 |
75c97406316f2c3afdd9554b64928e3d
|
|
| BLAKE2b-256 |
6cd98a5afd76a306f90ac5ac9d55c8836b3096b5e472b78046e92d116a09bd5a
|
Provenance
The following attestation bundles were made for roll_rate_analysis-0.2.0-py3-none-any.whl:
Publisher:
publish-package.yaml on alexliap/roll_rate_analysis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
roll_rate_analysis-0.2.0-py3-none-any.whl -
Subject digest:
92bf9be08dae3706d4b6a65f4283546ae9995ccabc6c72d3ca163280ef335beb - Sigstore transparency entry: 1505649326
- Sigstore integration time:
-
Permalink:
alexliap/roll_rate_analysis@47f82f0a601074d32c69572ba24dd4fb79b4775a -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/alexliap
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yaml@47f82f0a601074d32c69572ba24dd4fb79b4775a -
Trigger Event:
release
-
Statement type: