Digital Technologies · Artificial intelligence and machine learning
Train a simple AI
Teach a computer to tell ripe plantain from unripe by giving it labelled examples, then test how accurate it is.
- Curriculum: Digital Technologies, Artificial intelligence and machine learning
- Class: JSS 3 – SSS 3
- For BECE, WAEC, NECO practicals
- Readings, table and graph
- Quiz with answers explained
Start this experimentAll Digital Technologies experiments
Aim
To show how a machine-learning model learns from labelled examples, and how the amount and quality of training data affect its accuracy.
Apparatus
- This simulator
- A set of plantains to label (as data points)
Theory
Many AI systems learn from examples instead of being given rules. Here each plantain is described by two features: how yellow it is and how soft it is (both scored 0 to 1).
The model uses k-nearest neighbours: to classify a new plantain, it finds the k training examples most like it and takes a vote. We then test it on 40 plantains it has never seen and measure its accuracy.
Good AI needs enough examples, correctly labelled, that cover all the cases. Careless labels teach the model mistakes.
Procedure
- Choose a label (Ripe or Unripe) and tap the chart to add an example, or collect 10 labelled examples at once.
- Watch the shading: it shows what the model would predict everywhere on the chart.
- Test the model on 40 new plantains and record its accuracy.
- Add more examples and test again. Then try with careless labelling turned on.
- Change k and see how the predictions change.
What you do in the virtual lab
Set up the apparatus on screen, take readings and record them in a table (Training examples; k; Careless labels; Test accuracy (%)), then plot Test accuracy (%) against Number of training examples and read the result from the graph. Simulated instruments give slightly different readings each time, as real ones do. Finish with a short quiz; every answer is explained.
Teachers can set the experiment for a class, see each student’s results and use it as a WAEC- or NECO-style practical paper in exam practice.
Practice questions
In machine learning, the examples used to teach a model are called
- training data
- test data
- hardware
- output
Show the answer
A. training data The model learns patterns from training data, then is checked on separate test data.
Why is the model tested on plantains it has never seen?
- To save time
- Because the training data is lost
- To find out how well it works on new cases, not just the ones it memorised
- To make it learn faster
Show the answer
C. To find out how well it works on new cases, not just the ones it memorised Testing on new data shows whether the model has really learned the pattern.
If many training examples are labelled wrongly, the model will
- correct the labels itself
- refuse to work
- become faster
- learn the mistakes and become less accurate
Show the answer
D. learn the mistakes and become less accurate A model can only be as good as its data: “garbage in, garbage out”.
Related Digital Technologies experiments
- Logic gates and truth tablesSwitch the inputs of AND, OR, NOT, NAND, NOR and XOR gates and build each truth table.
- Binary, octal and hexadecimalFlip eight bit-switches to see how computers store numbers, then hit target values in binary.
- Programming a robot: sequence and loopsWrite a program of moves and turns to steer a robot to its goal, then shorten it with a loop.
- How strong is a password?Test made-up passwords, measure their strength in bits and see how long an attacker would need to guess them.
- Spreadsheet formulas and functionsUse cell references, SUM, AVERAGE, MAX and IF to complete a shop sales record and a class result sheet.
- Coding in PythonWrite real Python – print, variables, loops and if statements – and have each program checked automatically.