Machine learning from data: more samples, better accuracy
Computer ScienceData, AI & Machine LearningAges 16–17
Use it with your class: students open it from a link or a QR code, with no account needed.
A simple classifier learns from labeled samples: it computes the centroid of each class, then uses the perpendicular bisector between the two centroids as the decision boundary. Students adjust the number of training samples, the label-noise rate and how skewed the data collection is, the model retrains, and its accuracy is measured on a fixed set of 400 test samples. When training data comes mostly from one group, overall accuracy still looks high, but accuracy for the underrepresented group drops sharply — that is data bias in action.
Lesson: Artificial intelligence and machine learning: machines learn from data, and data quality determines model quality
What it shows
A machine-learning model has no built-in rules; it infers them from labeled examples. Here a nearest-centroid classifier finds the average point of each class in the training data and uses the perpendicular bisector between the two centroids as its decision boundary. Accuracy is measured on 400 fixed test samples the model never saw during training. With few samples or many mislabeled ones, the learned boundary drifts away from the true one. When most data comes from one group, overall accuracy can stay high while accuracy for the other group falls: bias that comes from the data.
How to use
Choose a Problem, turn on Show the true boundary for comparison, then change one setting at a time: Number of training samples, Percentage of mislabeled samples and Share of data drawn from one group only. After each change, compare the learned boundary with the true one and read the accuracy overall and for groups A and B. Use Retrain for a fresh random sample, or click the chart to add your own samples.
Parameters you can change
- Problem Spam filtering, Ripeness detection
- Number of training samples 10–500 samples
- Percentage of mislabeled samples 0–40 %
- Share of data drawn from one group only 0–100 %
- Show the true boundary for comparison
Questions to explore
- Why is the model's accuracy measured on 400 samples that were not used for training?
- How does the decision boundary move when 30% of the training samples are mislabeled?
- If overall accuracy is high, can the model still perform badly for one group, according to the group A and group B figures?