Data Factory
Teach a robot to tell cats from dogs
Your mission
A little robot can measure ears and snouts, but it has never learned what a cat or a dog is. Become its trainer: find out why a hand-written rule isn't enough, label and clean the data, divide it, train the model, then test it on photos it has never seen.
Explore
Test a hand-written rule, find where machine learning fits, and look inside the training data.
1. Can a rule do the job?
2. Where does machine learning fit?
3. What does the robot learn from?
| Photo |
|---|
Meet your robot. It can measure two things about a photo, how pointy the ears are and how long the snout is, but it has no idea what a cat or a dog is. Your mission: teach it. First, find out why we don't just write the rule ourselves.
0 of 7 discoveries made
Experiment
Label new photos, clean the data, divide it, train the robot, test it on unseen photos, and try two other ways machines learn.
Eight new photos have arrived. Tap each one to label it cat or dog (tap again to change it).
Press Divide the dataset first.
What you did at the first two stations was supervised learning: the robot learned from examples with the correct answers (labels). Here are the other two main ways machines learn.
Unsupervised: find groups without labels
The same 40 photos, but with no labels at all.
Reinforcement: learn from rewards
The robot gets +10 for reaching the star and −1 for every step. Nobody tells it which way to go.
Factory jobs
Do each one. They tick themselves off.
0 of 6 experiments done
Challenge
Six trainer tasks: features or labels, accuracy, the workflow, the three datasets and the three types of learning.
Trainer's handbook
- Feature: an input used to make a prediction
- Label: the correct answer the model should learn
- Training set: adjusts the parameters
- Validation set: compares models and settings
- Test set: final check on unseen data
- Accuracy = correct ÷ total × 100%
Finish all 6 tasks to finish this stage.
Understand
Here is what the factory was showing you, in the words you need for the exam.
AI, machine learning and deep learning
Artificial intelligence (AI) is a field of computer science concerned with developing systems capable of performing tasks associated with intelligent behaviour: recognising patterns, learning from examples, making predictions, understanding language, planning.
- Rule-based AI follows explicit IF–THEN rules, like a smart air conditioner or a medical expert system.
- Machine learning (ML) is a branch of AI that learns patterns from data.
- Deep learning (DL) is a branch of ML that uses neural networks with multiple layers.
Remember: deep learning is a type of machine learning, and machine learning is a type of AI.
Traditional programming
The programmer defines the rules: input data + programmed rules → output. Our rule "pointy ears means cat" was fooled by a pointy-eared dog. The computer executes the rule; it does not learn it from data.
Machine learning
Instead of writing every rule, developers use a learning algorithm and training examples to produce a model. There are two stages: training (the algorithm analyses training data and adjusts the model's parameters) and inference (the trained model receives a new input and makes a prediction).
Data, features and labels
| Concept | Meaning | In the Data Factory |
|---|---|---|
| Dataset | A collection of examples used for training or evaluation | 40 labelled photos |
| Feature | An input characteristic used to make a prediction | Ear pointiness, snout length |
| Label (target) | The correct outcome the model should learn to predict (supervised learning) | "cat" or "dog" |
Models need numbers, because computers perform mathematical operations on numerical data: a "like" becomes 1, a video's length becomes 300 seconds, an image becomes pixel values (Unit 3), and "cat"/"dog" can become 1/0.
Training, validation and test data
- Training set (e.g. 70%): used to adjust the model's parameters.
- Validation set (e.g. 15%): used to compare models and tune settings.
- Test set (e.g. 15%): used for the final evaluation on held-out data.
The 70/15/15 division is one possible example, not a universal requirement. Evaluation should use examples that were not used to fit the model, to measure whether it can generalise.
What happens during training?
Training repeats a cycle with many examples: make a prediction, compare it with the correct target, calculate the loss (the prediction error) and update the model's parameters. The loss gets smaller as training proceeds. The learned patterns are stored in the model's parameters.
The machine-learning workflow
- 1Collect data: gather relevant examples.
- 2Prepare data: clean it and convert it into a usable form.
- 3Divide the dataset: training, validation and test examples.
- 4Train the model: adjust its parameters using training data.
- 5Evaluate performance: measure how well it handles unseen data.
- 6Deploy and monitor: use the model and check its performance over time.
Measuring performance
Accuracy = correct predictions ÷ total predictions × 100%. 8 correct out of 10 is 80%. Accuracy is not always sufficient: depending on the task, other measures may be more informative, especially when some outcomes are much more common than others.
Three types of machine learning
- Supervised: learns from examples with known targets (predicting whether a user will enjoy a video; cat or dog).
- Unsupervised: finds structure in data without predefined labels (grouping users with similar interests).
- Reinforcement: learns through actions and reward signals (an AI agent learning to play a game).
Words to know
- Model
- What a learning algorithm produces from training data; it makes predictions.
- Training
- Adjusting a model's parameters using training examples.
- Inference
- Using the trained model to make a prediction for new input.
- Parameters
- The numbers inside a model that store what it has learned.
- Loss
- A measure of the prediction error; training tries to make it smaller.
- Generalise
- Work well on new examples the model has not seen before.
Exam tip
When asked to compare traditional programming with machine learning, say who makes the rule: a programmer writes it, or a learning algorithm learns it from labelled examples. Name the features and the label in the example you are given, and always say which data a model is evaluated on: unseen test data, not the training data.