Score Stability and Migration Matrix
Install and import#
npm install fintech-algorithmsimport { scoreStabilityAndMigrationMatrix } from "fintech-algorithms/model-validation-and-backtesting/classification-and-score-validation/score-stability-and-migration-matrix";Signature#
scoreStabilityAndMigrationMatrix(inputs)Worked example#
verified This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.
Input#
{
"baseline": [
{
"id": "E01",
"score": 0.08
},
{
"id": "E02",
"score": 0.14
},
{
"id": "E03",
"score": 0.19
}
],
"current": [
{
"id": "E01",
"score": 0.1
},
{
"id": "E02",
"score": 0.18
},
{
"id": "E03",
"score": 0.17
}
],
"band_edges": [0, 0.2, 0.4, 0.6, 0.8, 1],
"higher_score_higher_risk": true,
"baseline_observed_at": "2025-01-01T00:00:00Z",
"current_observed_at": "2026-01-01T00:00:00Z"
}Call#
scoreStabilityAndMigrationMatrix(inputs)Returns#
object with 17 fields: band_edges, matrix, row_rates, baseline_band_shares, current_band_shares, migrations, matched_count, stable_count, …
{
"band_edges": [0, 0.2, 0.4, 0.6, 0.8, 1],
"matrix": [
[3, 0, 0, 0, 0],
[0, 2, 1, 0, 0],
[0, 0, 2, 1, 0]
],
"row_rates": [
[1, 0, 0, 0, 0],
[0, 0.6666666666666666, 0.3333333333333333, 0, 0],
[0, 0, 0.6666666666666666, 0.3333333333333333, 0]
],
"baseline_band_shares": [0.25, 0.25, 0.25, 0.16666666666666666, 0.08333333333333333],
"current_band_shares": [0.25, 0.16666666666666666, 0.25, 0.16666666666666666, 0.16666666666666666],
"migrations": [
{
"id": "E01",
"baseline_score": 0.08,
"current_score": 0.1,
"baseline_band": 1,
"current_band": 1,
"band_move": 0,
"score_change": 0.020000000000000004
},
{
"id": "E02",
"baseline_score": 0.14,
"current_score": 0.18,
"baseline_band": 1,
"current_band": 1,
"band_move": 0,
"score_change": 0.03999999999999998
},
{
"id": "E03",
"baseline_score": 0.19,
"current_score": 0.17,
"baseline_band": 1,
"current_band": 1,
"band_move": 0,
"score_change": -0.01999999999999999
}
],
"matched_count": 12,
"stable_count": 9,
"improved_count": 0,
"worsened_count": 3,
"stable_rate": 0.75,
"mean_band_move": 0.25,
"mean_absolute_band_move": 0.25,
"mean_score_change": 0.02583333333333333
}Showing 14 of 17 fields.
Other exports#
This module also exports
rocCurveAndRocAuc, precisionRecallCurveAndPrAuc, brierScore, logLoss, reliabilityDiagramAndExpectedCalibrationError, gainsLiftAndDecileCapture, costSensitiveThresholdOptimization, sliceBasedValidationBySectorCountryAndRegime, rareEventBacktestAndConfidenceBounds, calculate. Every module additionally exports run as an alias of its
primary function, and a meta object carrying its catalog id, domain, family,
shape and article URL.
Diagrams#
How it works#
This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.
References#
- Revised Guidance on Model Risk Management — Board of Governors of the Federal Reserve System, OCC, and FDIC
- Credit Risk Modelling: Current Practices and Applications — Basel Committee on Banking Supervision
- Evidence boundary