bias_variance() refits a fixed learner across training resamples and compares its predictions at a fixed test set. For squared-error loss, the variation of the fitted function and its average deviation from a reference function describe variance and squared bias.
24.1 A simulation with a known regression function
2026-10-08 02:54:05 Checking data is ready for training... ✔ [check_supervised]
2026-10-08 02:54:05 Estimating bias and variance over 10 resamples of 120 cases, at 40 fixed test cases. [bias_variance]⠋ Resamples 1/10⠙ Resamples 2/10ETA 0:08⠹ Resamples 3/10ETA 0:04⠸ Resamples 5/10ETA 0:02⠼ Resamples 7/10ETA 0:01⠴ Resamples 9/10ETA 0:00⠦ Resamples 10/102026-10-08 02:54:06 ✔ Resamples 10/10 done in 0:02
result
<BiasVariance>
Mean squared bias: 0.12 (0.43)
Mean variance: 0.22 (0.20)
The small number of resamples demonstrates the interface. Estimates of bias and variance themselves vary with the resampling experiment.
true_values supplies the known function at the test cases. Without it, squared deviations from observed outcomes include observation noise. For binary classification, the function decomposes squared probability error; it does not provide an additive decomposition of classification error.