How a computer learns from examples: rules by hand, a nearest-neighbour model written yourself, fair testing, then scikit-learn and a model behind a Gradio app, with what models get wrong.
Each lesson works two ways. Students can work through the online tutorial at their own pace (it checks their answers and saves their progress in their browser), or you can teach it to the whole class from the slides, then send students into the tutorial for the Modify and Make steps.
Every lesson guide has plain-language notes, the answers to every check, a solution for every task, and slides and a worksheet for Waypoints Prepare. These guide pages are not linked from student pages, but they are not secret either: keep printed Teacher editions for answers you do not want students to find.
Whole-course cheat sheet: Open to print (every command, grouped by unit: a handout for the final challenge)
Rules, then a nearest-neighbour model you write yourself, and how to test a model fairly.
A model takes measurements and gives an answer: here, a penguin's bill and flipper length in, its species out. Its accuracy is how often it is right.
if flipper > 206: return "Gentoo". A person chooses the numbers by looking at the data. On the Palmer Penguins they get 95% right.Nearest neighbour is identifying a bird by finding the most similar picture in a field guide. A fair test is a practice exam with questions you have not seen. It breaks because the model never knows when nothing in the guide matches: it always picks the closest picture.
KNeighborsClassifier).Cheat sheet: Open to print (A4, with a picture of what each command draws) · Markdown
The same ideas in scikit-learn, then a model behind an app, and what models get wrong.
scikit-learn is the standard Python library for machine learning. Everything built by hand has a line in it: train_test_split (shuffle and split), KNeighborsClassifier (nearest neighbour), fit (learn from the training examples), score (accuracy on given data), predict (guess new examples). A decision tree learns if rules from the data, like Lesson 1's but chosen by the computer.
A model becomes useful in an app: a Gradio function turns slider values into a one-row table with the training columns, and the model predicts. predict_proba says how the 5 nearest penguins voted, which tells the user how sure it is.
Limits. A model can only answer with what it was trained on (an emperor penguin is called Gentoo), and it can be 100% sure and wrong. It knows the world its data came from (three islands, 2007 to 2009). A model card says what a model does, how well on a fair test, and where not to trust it.
scikit-learn is a well-made toolkit: you still need to know which tool does what, and to check the result. It breaks if you trust it blindly: the same fit and score on the wrong data give a convincing wrong answer.
Cheat sheet: Open to print (A4, with a picture of what each command draws) · Markdown