Model Pipeline - Fairness metrics
This pipeline shows how fairness metrics help us check if a machine learning model treats different groups of people fairly. It measures if the model's predictions are balanced across groups like gender or race.
This pipeline shows how fairness metrics help us check if a machine learning model treats different groups of people fairly. It measures if the model's predictions are balanced across groups like gender or race.
Loss
0.7 |****
0.6 |****
0.5 |***
0.4 |**
0.3 |*
+---------
1 2 3 4 5 Epochs
| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 0.65 | 0.6 | Model starts learning, loss high, accuracy low |
| 2 | 0.5 | 0.72 | Loss decreases, accuracy improves |
| 3 | 0.4 | 0.8 | Model learns important patterns |
| 4 | 0.35 | 0.83 | Training converges, loss stabilizes |
| 5 | 0.33 | 0.85 | Final epoch, good accuracy and low loss |
def stat_parity_diff(y_true, y_pred, group):
pos_rate_group1 = sum(y_pred[group == 1]) / len(y_pred[group == 1])
pos_rate_group0 = sum(y_pred[group == 0]) / len(y_pred[group == 0])
return pos_rate_group0 - pos_rate_group1
What is the main bug?Pass the test and this pattern moves unknown