Sort the tasks: what kind of machine learning is it?
For each question, decide two things: are the right answers given in the examples, and is the answer a category, a number, or groups we must discover?
What to notice
- Supervised: every example comes with the right answer (a label). Unsupervised: no answers, we look for structure.
- Ask "is the answer a category or a number?": category = classification, number = regression.
- The same data can support different tasks: "is it spam?" versus "group messages by topic".
Try this
Be the model: find a rule from examples
Here are the training flowers (70% of iris, the lecture's split). Write a rule with two questions, then let the computer learn its own rule. The test flowers stay hidden until you have decided.
Your rule
Features (X) and label (y): five rows of the table
What to notice
- Examples in, a rule (model) out, answers for new flowers: that is machine learning.
- The computer's rule is chosen to fit the training flowers. It is not guaranteed to beat a sensible human rule on the test flowers.
- You judged your rule before seeing the test flowers. That is what makes the test score honest.
Try this
Same pattern, any model: fit, then score
Three datasets that ship with scikit-learn and three models. The code never changes except for the dataset name. Predict the winner, then run.
Which model will score highest on the test set?
Training and test accuracy
What to notice
fit,predictandscorework the same way for every scikit-learn model.- No model wins everywhere: the best choice depends on the data.
- A decision tree scores 100% on its own training data every time. Only the test column shows real skill.
Try this
Memorise or generalise?
120 training points of two classes, and 600 new points from the same source. With k = 1 the model draws a border around every training point.
k = 1 on real data (slide 11, homework 8.4)
What to notice
- Training accuracy of 100% means the model can recite the exam questions it studied, not that it understands.
- The score on new points is the one that matters: generalisation.
- Too smooth is bad too: with k = 101 the model barely looks at the data.