| default | student | balance | income | |
|---|---|---|---|---|
| 0 | No | No | 729.526495 | 44361.625074 |
| 1 | No | Yes | 817.180407 | 12106.134700 |
| 2 | No | No | 1073.549164 | 31767.138947 |
| 3 | No | No | 529.250605 | 35704.493935 |
| 4 | No | No | 785.655883 | 38463.495879 |
2026-02-16
| Day | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| Prediction | π§οΈ | π§οΈ | π§οΈ | π§οΈ | π§οΈ | π§οΈ | π§οΈ | π§οΈ | π§οΈ | π§οΈ |
| Observed | π§οΈ | π§οΈ | π§οΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ |
| Day | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| Prediction | π§οΈ | π§οΈ | π§οΈ | π§οΈ | π§οΈ | π§οΈ | π§οΈ | π§οΈ | π§οΈ | π§οΈ |
| Observed | π§οΈ | π§οΈ | π§οΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ |
| Day | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| Prediction | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ |
| Observed | π§οΈ | π§οΈ | π§οΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ |
It depends on the consequences of your decisions!
| Day | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| Prediction | 0.8 | 0.8 | 0.8 | 0.6 | 0.6 | 0.6 | 0.6 | 0.6 | 0.6 | 0.6 |
| Observed | π§οΈ | π§οΈ | π§οΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ |
| Day | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| Prediction | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Observed | π§οΈ | π§οΈ | π§οΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ |
Both classify to βno diseaseβ, but in patient 2 you might recommend further testing or monitoring
\[ \frac{1}{n}\sum_{i=1}^n I(y_i \neq g(\mathbf{x}_i)) \]
\[ p(y|\mathbf{x}) \]
Classification often works with a threshold function: \[ g(\mathbf{x}) = 1\quad\quad \mathrm{if}\quad\quad \eta(\mathbf{x}) > 0 \\ g(\mathbf{x}) = 0\quad\quad \mathrm{if}\quad\quad \eta(\mathbf{x}) < 0 \]
Minimizing standard error function is computationally intractable!




\[ p(y=k|\mathbf{x}) = \frac{\exp{\mathbf{w}_k\cdot\mathbf{x}}}{1 + \sum_{j=1}^{K-1} \exp{\mathbf{w}_j\cdot\mathbf{x}}} \]
| Day | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| Prediction | 0.8 | 0.8 | 0.8 | 0.6 | 0.6 | 0.6 | 0.6 | 0.6 | 0.6 | 0.6 |
| Observed | π§οΈ | π§οΈ | π§οΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ |
| Day | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| Prediction | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Observed | π§οΈ | π§οΈ | π§οΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ | βοΈ |
βlogβ loss massively penalizes overconfident wrong predictions!
If this is a problem, consider using Brier score or some other loss function
| default | student | balance | income | |
|---|---|---|---|---|
| 0 | No | No | 729.526495 | 44361.625074 |
| 1 | No | Yes | 817.180407 | 12106.134700 |
| 2 | No | No | 1073.549164 | 31767.138947 |
| 3 | No | No | 529.250605 | 35704.493935 |
| 4 | No | No | 785.655883 | 38463.495879 |
| feature | coefficient | |
|---|---|---|
| 0 | num__balance | 2.699375 |
| 2 | cat__student_Yes | -0.518437 |
| 1 | num__income | 0.121987 |
Most people do not intuitively understand log-odds ratios, nor should they be expected to be
| feature | coefficient | odds_ratio | |
|---|---|---|---|
| 0 | num__balance | 2.699375 | 14.870429 |
| 2 | cat__student_Yes | -0.518437 | 0.595451 |
| 1 | num__income | 0.121987 | 1.129739 |
shape: (3, 3)
βββββββββββ¬βββββββββββ¬βββββββββββ
β Term β Contrast β Estimate β
β --- β --- β --- β
β str β str β str β
βββββββββββͺβββββββββββͺβββββββββββ‘
β balance β dY/dX β 0.119 β
β income β dY/dX β 0.000202 β
β student β Yes - No β -0.0103 β
βββββββββββ΄βββββββββββ΄βββββββββββ
shape: (3, 3)
βββββββββββ¬ββββββββββββββββββββββ¬βββββββββββ
β Term β Contrast β Estimate β
β --- β --- β --- β
β str β str β str β
βββββββββββͺββββββββββββββββββββββͺβββββββββββ‘
β balance β (x+sd/2) - (x-sd/2) β 0.0613 β
β income β (x+sd/2) - (x-sd/2) β 0.00269 β
β student β Yes - No β -0.0103 β
βββββββββββ΄ββββββββββββββββββββββ΄βββββββββββ
Solution: Bias your prediction towards the mistake that has worse consequences
Bayes Decision Rule
precision recall f1-score support
No Default 0.98 1.00 0.99 1933
Default 0.75 0.27 0.40 67
accuracy 0.97 2000
macro avg 0.86 0.63 0.69 2000
weighted avg 0.97 0.97 0.97 2000
10% threshold
precision recall f1-score support
No Default 0.99 0.94 0.97 1933
Default 0.30 0.72 0.43 67
accuracy 0.94 2000
macro avg 0.65 0.83 0.70 2000
weighted avg 0.97 0.94 0.95 2000

DATA 622