tibble(
complexity = 1:10,
bias_sq = (5 / (1:10))^2,
variance = (0.3 * (1:10))^2,
) |>
dplyr::mutate(total = bias_sq + variance + 4) |>
tidyr::pivot_longer(-complexity) |>
ggplot(aes(complexity, value, color=name, linewidth=name)) +
geom_line() +
scale_color_manual(values=c("bias_sq"="#e63946","variance"="#2563eb",
"total"="#1b2e4b")) +
scale_linewidth_manual(values=c("bias_sq"=0.9,"variance"=0.9,"total"=1.4)) +
labs(title="Bias² + Variance + noise = total expected error",
x="Model complexity", y="Error", color=NULL, linewidth=NULL) + theme_di()

