Lesson 01.02
How computers learn from examples
You will be able to explain how training examples influence a model’s predictions on new inputs.
What you’ll do
- RelateHow would you teach a child?
- ExplainGive the computer some examples
- VisualizeTrain your first simple classifier
- ExperimentLearning is not memorizing
- ApplyThink like an AI engineer
- ReflectCheck your understanding
- Check4 questions, with feedback
How would you teach a child?
Imagine showing a child an apple for the very first time. You show them a red apple and say, “This is an apple.” Now imagine they encounter a green apple. Would they recognize it?
If the child only sees red apples, they might initially think apples must be red. Seeing different examples can help them notice other characteristics.
A machine learning model can face a similar problem, although its learning process is different from a child's. The examples we learn from influence the patterns we discover.
Give the computer some examples
Suppose we want a computer to recognize apples. We give it examples of apples and other fruit, along with their correct categories. Learning from examples with known target outputs is called supervised learning. Not all machine learning uses manually labelled data.
Text description
Labelled examples of an apple and a banana feed a learning algorithm. It produces a trained model. Later, a new fruit enters the trained model, which predicts a category.
Term 1 of 4
Data
Training data is the collection of examples used during learning. Here, each example describes a fruit.
A model does not automatically discover every characteristic that matters. Let's see what happens when we give it different examples and different information.
Train your first simple classifier
We're going to train a tiny classifier. It can only observe one characteristic at a time: color or shape. Unlike a modern neural network, it learns a small table of label counts from the training examples.
Before running the experiment, predict what will happen to a green apple if the model has never seen any green fruit.
ExperimentTeach your computer to recognize apples
Start with limited examples and color. Train and test the classifier, then change one setting at a time. What improves, and what remains difficult?
This toy classifier counts the training labels for each value of the selected feature. It predicts the most common label for a matching value. If the counts tie or no value matches, it reports Uncertain.
Labelled training examples
Red apple
Label: Apple
Color: red
Yellow banana
Label: Not apple
Color: yellow
Development examples
Train and test to see results for this configuration.
A deterministic teaching model, not a neural network. Pictures represent distinct specimens with the same displayed features. Development examples guide our choices. The challenge examples are held back until after the first experiment; once inspected, they are no longer an untouched independent test set.
Adding diverse examples helped the model recognize green apples. But color could not separate two different yellow fruits. Shape worked on our small development set, then failed on a round tomato.
Better data matters, but so does the information available to the model.
Learning is not memorizing
Imagine studying for an exam by memorizing the answers to four questions. Getting those same questions right is not proof that you can solve unfamiliar questions.
A model's ability to perform well on new examples is called generalization.
Text description
Training examples are used to build the model. Development examples help choose or improve it. A separate test set is used for final evaluation and must not influence those earlier choices.
Training data: used to learn.
Development data: used to compare choices and improve the model.
Independent test data: kept separate until final evaluation. If we repeatedly tune using the test set, it is no longer an independent test.
Even a good test score does not guarantee success on every future input. The test examples need to represent the situations where the application will be used.
Think like an AI engineer
Remember our customer support chatbot? We now want a classifier to recognize complaints.
Our first dataset includes messages such as “My order arrived damaged,” “I am unhappy with the delivery,” and “The product does not work.” All are direct English complaints.
What might happen when real customers express themselves differently?
ChallengeImprove the training dataset
Choose the most useful next addition for each observed gap. Assume the task is detecting complaints, not automatically deciding refunds.
Challenge 1 of 4
Sarcasm
The training set contains direct complaints. The model misses: “Great. Another package that hasn't arrived.” What would improve training coverage?
Before blaming a model for a mistake, inspect the examples it learned from, the labels and the information it receives. Then measure changes on separate examples. This is a practical part of AI engineering.
Check your understanding
Common misconception
MisconceptionIf we give a model enough examples, it will eventually get every prediction right.
A better understandingMore examples can help, but quality, diversity, correct labels, available information and the learning algorithm all matter. Performance must be checked on new inputs.
Apply what you learned to four new engineering scenarios in the knowledge check.