Model Pipeline - Bias-variance tradeoff
This pipeline shows how a model learns from data and balances two types of errors: bias (too simple) and variance (too complex). It helps find the best fit for new data.
This pipeline shows how a model learns from data and balances two types of errors: bias (too simple) and variance (too complex). It helps find the best fit for new data.
Loss
0.5 |****
0.4 |***
0.3 |**
0.2 |*
0.1 |
+---------
1 3 5 7 10 Epochs| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 0.45 | 0.60 | Model starts learning with high error and low accuracy |
| 3 | 0.30 | 0.75 | Loss decreases and accuracy improves as model fits data better |
| 5 | 0.20 | 0.85 | Model fits training data well, risk of overfitting starts |
| 7 | 0.18 | 0.87 | Loss decreases slowly, accuracy plateaus, watch for variance |
| 10 | 0.17 | 0.88 | Model converges, balance between bias and variance reached |
import numpy as np np.random.seed(0) true_pattern = 5 model_predictions = [4, 5, 6, 7, 8] noise = np.random.normal(0, 1, 5) errors = [(pred - true_pattern + n) ** 2 for pred, n in zip(model_predictions, noise)] print(round(np.mean(errors), 2))
import numpy as np
np.random.seed(1)
true_value = 10
predictions = [true_value + np.random.normal(0, 5) for _ in range(5)]
bias = np.mean(predictions) - true_value
variance = np.var(predictions)
print(f"Bias: {bias:.2f}, Variance: {variance:.2f}")Pass the test and this pattern moves unknown