Diagnose Bias vs Variance from Learning Curves

easy
Unit 6 · Kernels0/3 to milestone

A learning curve plots training and validation error as the training set grows. Its shape tells you what to do next:

  • High bias (underfitting): both errors are high and close together. More data won't help; use a bigger model.
  • High variance (overfitting): a large gap between low training error and high validation error. More data or regularisation will help.
  • Good fit: both errors are low and close.

Implement diagnose(train_errors, val_errors, target_error, gap_tol=0.1) using the last point of each curve:

  • "high_variance" if val - train > gap_tol
  • otherwise "high_bias" if train > target_error
  • otherwise "good_fit"

Also implement still_improving(val_errors, window=3, min_delta=0.01): True if the mean of the last window validation errors is lower than the mean of the window before it by more than min_delta. Return False if there are fewer than 2 * window points.

#model-selection#diagnostics#bias-variance2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Diagnose Bias vs Variance from Learning Curves · TechGradify