promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_

Overfitting and regularization you can see — step 7 of 7

Checkpoint

One last thing before we move on. pass this to mark the lesson done, or skip and keep moving. hop to the next when you're ready.

Reproduce the walkthrough's k experiment on fixed data (the train set has two noisy labels: the 2.0/1 and 2.5/0 points). Implement knn(k, x) (sort by distance, take k, majority vote with votes * 2 > k), then for k=1 and k=3 print the line f"k={k} train={tr:.0%} test={te:.0%} gap={tr - te:+.0%}". Finish with a line reporting whether the bigger k shrank the gap.

full-screen editor opens — close anytime to keep reading.