A3 · AI Basics · Grade 7–11 · ages 12–17
How Machines Learn
Models, decision trees and testing
Going furtherFree · works offline
▶ Start the interactive lessonThe full lesson adds narration, an interactive mission and a 10-question bank, and the quiz explains any mistakes.
What a model is
When AI learns, it builds a model: a set of rules or numbers that turns inputs (features) into a prediction. A model for crop prices might take the season and the rainfall, and predict the price of maize next month. The model is the part that is "trained".
Decision trees
A decision tree is one simple kind of model. It asks yes/no questions, one after another, until it reaches an answer: "Does it have feathers? Yes → bird. No → Does it breathe with gills? Yes → fish. No → mammal." Training means finding which questions to ask, and in what order.
Training is trial and improvement
Most models start bad and improve. They make predictions on the training data, measure how wrong they are, adjust a little, and repeat, often thousands or millions of times. Neural networks, the models behind modern speech and image AI, learn this way by adjusting millions of numbers.
Accuracy and testing
Accuracy is the share of predictions that are correct. A model that is right 90 times out of 100 has 90% accuracy. It must be measured on test data the model has never seen. A model can score 100% on its training data and still fail on new examples.
Overfitting
Overfitting is when a model memorises its training examples instead of learning the general pattern, like a learner who memorises past-paper answers but can't solve a new question. In the explainer above, a tree can sort every training animal perfectly and still get a dolphin wrong.
Key points
- A trained model turns inputs into a prediction.
- A decision tree asks yes or no questions until it reaches an answer.
- Training is trial and improvement, repeated many times.
- Neural networks learn by adjusting millions of numbers.
- Accuracy is the share of predictions that are correct.
- Always measure accuracy on test data the model hasn't seen.
- Overfitting is memorising the examples instead of the pattern.
Try it for real: Train and test your tree
- In the explainer, build a tree that sorts all the training animals, then test it on the new ones. Note how many it gets right.
- Start again and build a different tree. Which questions worked best on the new animals, and why?