Teaching machine learning without coding: a classroom experiment

Teach machine learning without programming using classroom objects: an 80-minute activity on data, training, errors, accuracy, and biases.

To teach machine learning without programming, start with an experiment that can make mistakes. A pencil and eraser classifier allows students to work with data, training, and errors in about 80 minutes. The key is explaining which examples the model saw, how it was evaluated, and to what extent its results can be trusted.

This activity uses Teachable Machine and objects from a desk. Students label examples, train a classifier and test it on objects they held back. The numbers in the worked example are simulated so students can practise the calculations.

TL;DR

  • Separate physical objects before photographing them: training, validation, and final testing serve distinct purposes.
  • A background associated with each class can become a visual shortcut; changing it helps investigate errors.
  • Overall accuracy needs context: a confusion matrix shows what is being misclassified.

Learning from examples without starting from scratch

In supervised learning, each sample has a known label: here, pencil or eraser. Training adapts a classifier to these examples. Afterward, it’s important to check whether the model correctly assigns labels to new images. This ability to function beyond the examples used for learning is generalization.

Teachable Machine lets students build image classifiers without writing code. Its image library uses transfer learning: a pretrained model provides the starting point for distinguishing the new classes. The official repository documents this approach. The activity does not train a visual network from scratch.

These are tasks with different requirements. The Valinkey guide on hardware for local AI provides background on hardware resources. For this session, first check that the browser and tool work on the classroom equipment. A high-end computer is unnecessary.

Materials and privacy before opening the camera

Prepare a computer, two different plain backgrounds, a stable surface, a calculator, and a recording sheet. Gather 15 distinct physical pencils and 15 erasers, or a set of images prepared by the teacher with that distribution. It’s beneficial to vary colors, shapes, and wear.

Define two categories: graphite pencils and separate erasers. Leave out pens, mechanical pencils and combined objects that would be difficult to label. Frame only the materials. Move faces, names, documents, schoolwork and screens out of view. This exercise does not require students’ voices, body positions or personal data.

We checked the Spanish interface through to the standard image editor on 1 November 2026. We did not run a full training session. Before class, test capture, training and preview on the equipment and network the students will use.

Separate objects, not nearly identical frames

Before taking photos, give the objects codes and write them on a sheet outside the frame. Shuffle the cards within each class and record the split. Keep every image of a held-out object out of the training set.

Objects and images per class
Dataset Objects and views Function
Training 8 objects × 6 views = 48 images Learning the classes
Validation 2 objects × 4 views = 8 images Compare versions
Final assessment 5 objects × 4 views = 20 images Evaluate the selected version

The two classes together give 96 training images, 16 validation images and 40 final test images. Taking a different photo of the same pencil still lets the model recognise features it has seen before. This is why all views of each physical object belong in the same split.

The scikit-learn evaluation documentation explains why testing on training data can give misleading results. This exercise uses a convenience sample: objects available on a desk. It does not represent all school supplies.

The 80-minute activity

Prepare before class: save the 16 validation and 40 final test images in separate folders. Record the object, background and orientation for each file. Open those files in the preview. Keep them out of the training classes. Allow extra time if students will take the pictures themselves.

Work sequence
Minutes Action Recording
0–8 Define classes and prepare framing Question and hypothesis
8–23 Separate objects and capture training data Split and capture conditions
23–33 Train version A Settings used
33–45 Test the 16 validation images Errors due to background
45–55 Retake samples and train version B Selected version
55–70 Evaluate the 40 final images All predictions
70–80 Calculate and discuss Confusion matrix and limits

For the first version, deliberately introduce a flaw: photograph every pencil on blue and every eraser on white. Take six views of each training object under comparable lighting and at a similar distance.

In the tool, go to Get Started → Image Project → Standard image model. Rename the two classes, include only training data, and click Train Model. The waiting time depends on the device.

For validation, prepare four conditions per object: the two backgrounds and two orientations. Record the true label, background, orientation, and prediction. If an eraser changes its label when the background changes, a clue for investigation appears; the error is not guaranteed nor does it alone prove its cause.

Build version B using the same training objects and the same quantity: three views per background and per object. Replace the initial samples, keep the settings, and compare using validation. Choose a version before opening the final test.

Validation serves to compare A and B and select a version. There is information leakage if the final test data influence training or selection. If you adjust the model based on its final errors, you will need a separate reserved test to announce an independent result.

In the test, use the four predefined conditions and one fixed prediction per image: the class with the highest score; in case of a tie, eraser, according to the agreed rule. Do not select the frame that seems most suitable nor count continuous webcam updates as new tests.

For 60 minutes, prepare images and distribution in advance and reduce discussion; if the team is slow, work on a single version. For 90 minutes, expand the error analysis. If the tool fails, use prediction simulation cards and declare that evaluation is being practiced without actual training performed.

A confusion matrix to understand the errors

DATA LAB · SIMULATED EXAMPLE

The same result. Three different questions.

40 images, two classes, and seven errors. Explore what each metric represents. The positive class is Pencil.

ROWS = REAL CLASS · COLUMNS = PREDICTION

Simulated confusion matrix for 40 images. Rows and columns ordered as Eraser, Pencil.
Actual ↓
Prediction →
Eraser Pencil
Eraser 18True Negatives
2False Positives
Pencil 5False Negatives
15True Positives

The diagonal cells contain the 33 correct predictions. The other two cells contain the seven errors.

Overall accuracy

How many images were correctly classified across both classes?

33/40=82,5 %

Overall accuracy: 33 out of 40 images, 82.5 percent.

Add 18 correctly classified erasers and 15 correctly classified pencils. The denominator includes all 40 images.

(TP + TN) / total = (15 + 18) / 40

Count the samples

Each point represents one image. The green outline marks the denominator; the purple fill marks the numerator.

40 test images, grouped by outcome Overall accuracy: the 40 images are in the denominator and 33 correct predictions in the numerator. The counts per group are 18 true negatives, 2 false positives, 5 false negatives, and 15 true positives.

Numerator: 33 images · Denominator: 40 images.

The three formulas, always available
  • Overall accuracy: (15 + 18) / 40 = 33/40 = 82,5 %.
  • Pencil precision: 15 / (15 + 2) = 15/17 ≈ 88,24 %.
  • Pencil recall: 15 / (15 + 5) = 15/20 = 75 %.

Fictional data for didactic purposes. These illustrative figures are neither measured results nor a prediction of the tool’s performance. The 40 images represent just ten objects. Different views of one object are related observations. TP/TN mean true positives/negatives. FP/FN mean false positives/negatives.

Suppose there are 20 images of actual erasers and 20 of actual pencils. Rows give the true class and columns show the prediction. We define Pencil as the positive class. Here “positive” is a convention and carries no value judgement.

Simulated confusion matrix: 40 images
True class Prediction: eraser Prediction: pencil
Eraser 18 true negatives 2 false positives
Pencil 5 false negatives 15 true positives

This arrangement follows the definition of scikit-learn’s confusion matrix. We abbreviate the four counts as TN, FP, FN and TP.

  • Overall accuracy: (TP + TN) / total = (15 + 18) / 40 = 33/40 = 82,5 %.
  • Pencil precision: TP / (TP + FP) = 15 / (15 + 2) = 15/17 ≈ 88,24 %.
  • Pencil recall: TP / (TP + FN) = 15 / (15 + 5) = 15/20 = 75 %.

The precision asks how many Pencil predictions were correct. recall asks how many actual pencils the classifier found. The denominator changes the question. Of 17 positive predictions, 15 were correct. Of the 20 actual pencils, five were missed.

What a high percentage cannot tell you

Another example, also fictical: there are 95 images of gomas and five of lapis. A system that always responds goma achieves a 95% success rate, but its recall of lapis is 0/5 = 0 %. Its precision of lapis remains undefined: it has not issued any positive prediction and the denominator is zero.

These are different sets; that 95% does not prove an improvement over 82.5%. The accuracy summarises the proportion of correct predictions. It cannot explain each kind of mistake or guarantee performance in different conditions.

Nor does the result establish understanding, freedom from bias or safety. Balancing the background reduces one association in the design. Differences in lighting, shape or selection may remain. The 40 final images depict just ten objects. Multiple views of one object are related and cannot be treated as 40 independent objects.

A two-class classifier may still choose one of its labels when neither applies. Show it a pair of scissors and it may predict Pencil or Eraser. Record that as a separate exploratory test. It does not belong in the pencil-and-eraser confusion matrix.

Assess students’ reasoning

Ask for a short conclusion that says which objects were held back, which errors occurred and what the results cannot establish. Give credit for spotting data leakage, entering errors in the correct cells and choosing the right denominator, even when the classifier made many mistakes.

This approach connects with AI4K12 and data-driven learning, and with critical judgment from the UNESCO competency framework. These educational frameworks guide the activity. Neither certifies it or guarantees improved learning.

Keep the class record. Before using the classifier in another setting, ask which new test would give you a reason to trust its predictions there.

Frequently asked questions

Do students need to know how to code?

No. The activity uses Teachable Machine’s image interface. The work involves preparing examples, splitting datasets, recording predictions, and calculating metrics with a calculator.

Why split by physical objects?

Photos of the same object share many features. Distributing nearly identical views between training and testing can create an exaggerated impression of generalization. Reserving complete objects reduces this issue, though it does not eliminate all biases.

Do the images remain on the computer?

Google describes local sample preparation except when saving a project to Drive. Publishing hosts the model on Google’s servers. That description does not rule out other network traffic from the site. Consult Google’s FAQ and the school’s policies.

Does a 95% accuracy rate mean it works well?

It depends on the dataset and the purpose. If 95 out of 100 images are erasers, always predicting ‘eraser’ achieves that percentage but fails on all pencils. Review the confusion matrix, class-specific metrics, and test conditions.

Share this article

Send the link to someone who might find it helpful.

Explora Valinkey
Explore Valinkey

Configurar privacidad y cookies