Sunday, August 3, 2025

KS Calculation - step by step

 let's walk through a step-by-step example of the KS statistic using 10 observations with:

  • Actuals (ground truth): 1 = defaulter, 0 = non-defaulter

  • Predicted scores: from a classification model


๐Ÿงพ Sample Data: 10 Observations

ObsActual (Y)Predicted Score
110.95
200.90
310.85
400.80
500.70
610.60
700.40
800.30
910.20
1000.10

๐Ÿ“Š Step 1: Sort by predicted score descending

RankActual (Y)ScoreCumulative Positives Cumulative Negatives (+ve%) - (-ve%)
110.951 / 4 = 0.250 / 6 = 0.000.25
200.901 / 4 = 0.251 / 6 = 0.1670.083
310.852 / 4 = 0.501 / 6 = 0.1670.333
400.802 / 4 = 0.502 / 6 = 0.3330.167
500.702 / 4 = 0.503 / 6 = 0.5000.00
610.603 / 4 = 0.753 / 6 = 0.5000.25
700.403 / 4 = 0.754 / 6 = 0.6670.083
800.303 / 4 = 0.755 / 6 = 0.833-0.083
910.204 / 4 = 1.005 / 6 = 0.8330.167
1000.104 / 4 = 1.006 / 6 = 1.0000.00

✅ Step 2: Identify KS

Look for the maximum difference between:

  • (Cumulative positives) — % of defaulters seen so far

  • (Cumulative negatives) — % of non-defaulters seen so far

The maximum value in the last column ((Cumulative positives%)  - (Cumulative negatives %)) is:

0.333 at Rank 3 (score = 0.85)\boxed{0.333} \text{ at Rank 3 (score = 0.85)}

๐Ÿ” Interpretation:

  • KS = 0.333 → The maximum separation between defaulters and non-defaulters occurs when the score threshold is around 0.85

  • At that point:

    • You've captured 50% of defaulters

    • Only 16.7% of non-defaulters

  • This is the optimal score threshold for maximum model discrimination

No comments:

Post a Comment