Bias-Variance Decomposition
Xem dạng PDF
Gửi bài giải
Điểm:
100,00
Giới hạn thời gian:
2.0s
Giới hạn bộ nhớ:
256M
Tác giả:
Dạng bài
Ngôn ngữ cho phép
Python
Task
Given predictions from an ensemble of k models at a single test point, compute the classical bias-variance decomposition of expected squared error. The mean prediction is meanpred = (1/k) * sum(preds). Bias squared = (meanpred - ytrue)². Variance = (1/k) * sum((p - meanpred)²). Irreducible error = sigma², the noise variance. Total expected error = bias_squared + variance + irreducible.
Input
- Line 1:
k sigma2— number of model predictions, noise variance σ² - Line 2:
p_1 p_2 ... p_k— predictions from each model, space-separated - Line 3:
y_true— the true target value
Output
Print four values each on its own line: bias_squared, variance, irreducible, total — each with up to 10 significant digits.
Example
Input:
5 0.25
2.0 2.5 3.0 2.8 2.2
3.0
Output:
0.25
0.136
0.25
0.636
Scaffolding
Submit a Python file defining:
def bias_variance_decomp(preds: list[float], y_true: float,
sigma2: float) -> tuple[float, float, float, float]:
...
Receives a list of model predictions, the true target value, and the noise variance; returns a tuple (bias_squared, variance, irreducible, total).
Bình luận