The Training Journey: From Data to Knowledge

The Training Journey: From Data to Knowledge

45 min
August 4, 2026
Step 1 of 6

Introduction: Why Do Models Need Training?

Introduction: Why Do Models Need Training?

Imagine you are handed a box of 10,000 photographs of animals and asked to sort them into "cat" and "dog" piles. You have never seen a cat or a dog in your life. You have no idea what they look like, what sounds they make, or what makes one different from the other. Where would you even begin?

This is exactly the situation a machine learning model faces. A model is not born knowing anything. It does not have instincts, prior experience, or a dictionary of concepts. It is a blank mathematical structure — a set of numbers and equations — that becomes useful only after you show it examples and let it adjust itself. That process of showing examples and adjusting is called training.

Why does this matter to you? Because every AI tool you have ever used — from the autocomplete in your email to ChatGPT, from Google Photos' face recognition to the spam filter in your inbox — works only because someone trained a model on a massive amount of data. Understanding how training works is the single most important step to understanding what AI can and cannot do. It explains why AI sometimes fails, why it sometimes succeeds brilliantly, and why the quality of the data matters more than the cleverness of the algorithm.

In this chapter, you will learn the complete training pipeline — the exact sequence of steps that turns raw data into a working model. You will then train your own model using a free, no-code tool called Teachable Machine, and you will see with your own eyes how the data you feed it directly determines what it learns.

The Training Pipeline: A Student Studying for an Exam

Think of a model as a student preparing for a final exam. The training process follows the same logic a good student uses:

Step 1: Collecting Data (The Study Material)

Before the student can study, they need textbooks, lecture notes, and practice problems. For a model, this means gathering examples. If you want a model to recognize handwritten digits, you need thousands of images of handwritten numbers. If you want a model to translate English to French, you need millions of sentence pairs. The data is the raw material — without it, there is nothing to learn from.

Step 2: Cleaning the Data (Removing Distractions)

A good student does not study from a textbook full of typos, missing pages, and irrelevant tangents. Similarly, raw data is almost always messy. Images may be blurry, mislabeled, or duplicated. Text may contain typos, HTML tags, or irrelevant boilerplate. Cleaning the data means removing errors, standardizing formats, and ensuring each example is correctly labeled. This step is unglamorous but absolutely critical — a model trained on dirty data will learn the wrong lessons.

Step 3: Feeding the Data to an Algorithm (The First Attempt)

The student sits down with the textbook and reads it for the first time. The model does something similar: it takes the cleaned data and runs it through its mathematical structure, making an initial guess at the answer for each example. At this stage, the model is essentially random — it has no idea what it is doing. It will guess "cat" for a picture of a dog and "dog" for a picture of a cat, and it will be wrong almost every time.

Step 4: Adjusting Weights (Learning from Mistakes)

Here is where the magic happens. After each guess, the model compares its answer to the correct answer (the label). The difference between the two is called the loss — a number that measures how wrong the model was. The model then uses a mathematical technique called gradient descent to adjust its internal parameters, called weights, in a direction that would have made the guess slightly less wrong. It repeats this process thousands or millions of times, each time nudging the weights a tiny bit. This is the equivalent of the student doing practice problems, checking the answer key, and reviewing the concepts they got wrong.

Step 5: Evaluating (The Practice Test)

After training, the student takes a practice test on questions they have never seen before. The model does the same: you hold back a portion of your data (called the test set) that the model never saw during training. You run the model on this unseen data and measure its accuracy. If it performs well, the model has genuinely learned the underlying pattern rather than just memorizing the training examples. If it performs poorly, you may need more data, cleaner data, or a different algorithm.

A Concrete Worked Example: Training an Image Classifier with Teachable Machine

Let us make this real. You will now train a model that distinguishes between two objects you have around you — for example, a spoon and a fork. You will use Teachable Machine, a free web-based tool from Google that lets you train a model entirely in your browser with no code and no installation.

What You Will Need

  • A computer with a webcam (or a phone with a camera)
  • A spoon and a fork (or any two visually distinct objects)
  • About 10 minutes

Step-by-Step Instructions

Step 1: Open Teachable Machine. Go to teachablemachine.withgoogle.com in your browser. Click the button that says "Get Started". You will see a screen with several project types. Click "Image Project".

Step 2: Understand the interface. You will see two classes labeled "Class 1" and "Class 2". A class is simply a category you want the model to recognize. Rename "Class 1" to Spoon and "Class 2" to Fork by clicking on the text and typing.

Step 3: Collect training data. Click the "Webcam" button under the "Spoon" class. Hold the spoon up to the camera and click "Hold to Record". Move the spoon around — tilt it, rotate it, bring it closer and farther away. Record about 50 samples. Repeat the same process for the "Fork" class. If you do not have a webcam, you can click "Upload" and upload images from your computer instead.

Step 4: Train the model. Scroll down and click the big green button that says "Train Model". The training will take about 10 to 30 seconds. You will see a progress bar. While it trains, the browser is literally running the gradient descent algorithm we discussed — adjusting thousands of weights to minimize the loss.

Step 5: Test the model. When training finishes, you will see a "Preview" panel on the right. Hold the spoon up to the camera. The model should show a high confidence percentage (like 95%) for "Spoon" and a low percentage for "Fork." Now hold up the fork. The percentages should flip. This is the evaluation step — you are testing the model on inputs it has never seen before.

Step 6: Export the model (optional). If you want to use this model elsewhere, click "Export Model" and then the "Tensorflow.js" tab. You will see a download button and a code snippet that you could embed in a website. You do not need to understand the code right now — just know that this is how a trained model gets packaged for real-world use.

What Just Happened, Technically

Here is what was happening under the hood. Each image from your webcam was resized to a small grid of pixels (typically 224×224). Each pixel has three color values (red, green, blue), so the model received 224 × 224 × 3 = 150,528 numbers as input. The model multiplied these numbers by its weights, added them up in layers, and produced two output numbers — one for "Spoon" and one for "Fork." The higher number is the model's prediction.

During training, the model compared its output to the correct label. If you showed a spoon image and the model output 0.3 for "Spoon" and 0.7 for "Fork," the loss was high. The gradient descent algorithm then adjusted the weights so that next time, the "Spoon" output would be slightly higher. After 50 spoon images and 50 fork images, repeated over many iterations, the weights converged to a configuration that reliably separates spoons from forks.

Here is a simplified version of what the training loop looks like in code (this is for illustration — you do not need to run it):

# Simplified training loop (pseudocode)
for epoch in range(10):  # Repeat 10 times
    for image, label in training_data:
        prediction = model.forward(image)      # Step 3: make a guess
        loss = calculate_loss(prediction, label)  # How wrong were we?
        model.backward(loss)                   # Step 4: adjust weights
    accuracy = evaluate(model, test_data)      # Step 5: check progress
    print(f"Epoch {epoch}: accuracy = {accuracy:.2f}")

Each pass through the entire dataset is called an epoch. Teachable Machine runs many epochs automatically — you do not see them, but they are happening.

How Data Affects Performance: The Experiment

Now let us see why data quality matters. Delete all your training samples by clicking the trash icon next to each class. This time, record only 5 samples for each class, and hold the object perfectly still in the same position for all 5. Train the model again. Test it. You will likely find that it performs poorly — it may confuse the spoon and fork, or it may only recognize the exact angle you recorded.

This is not a bug. The model learned a narrow pattern: "Spoon = object at this exact angle with this exact lighting." It did not learn the general concept of "spoon." When you varied the angle, lighting, and position during the first training run, you gave the model the variety it needed to generalize. This is the single most important lesson in all of machine learning: the model learns exactly what your data shows, nothing more and nothing less.

Expert Tip: The most common beginner mistake is collecting too many similar images. A model trained on 100 images of a spoon in the same position will perform worse than a model trained on 20 images of a spoon in varied positions, lighting conditions, and backgrounds. When collecting data, deliberately introduce variation: rotate the object, change the lighting, move it to different backgrounds, and include some partially occluded views. This is called data augmentation when done programmatically, and it is one of the highest-leverage techniques in the field. A professional data scientist spends more time thinking about data diversity than about which algorithm to use — because the algorithm is fixed, but the data is what actually teaches the model.

Common Mistakes

Common Mistakes Beginners Make:
  • Too few samples. With fewer than 10 samples per class, the model has almost nothing to learn from. Aim for at least 30–50 per class for a simple two-class problem.
  • Imbalanced classes. If you have 100 spoon images and 10 fork images, the model will become biased toward predicting "spoon" because it sees spoons more often. Keep class sizes roughly equal.
  • Testing on the training data. If you test the model on the exact same images you trained it on, you will get artificially high accuracy. Always test on new, unseen examples — this is why Teachable Machine's preview panel uses your live webcam feed.
  • Ignoring the confidence score. The percentages in the preview panel are not just decoration. If the model says 55% spoon and 45% fork, it is genuinely uncertain. A well-trained model should give 90%+ confidence for clear examples.
  • Assuming more data is always better. More data helps only if it adds variety. Adding 100 more images of the same spoon at the same angle will not improve the model — it will just make training slower.

Your Practice Task

Spend 15 minutes on this exercise:

  1. Open Teachable Machine and create a new Image Project.
  2. Create three classes: Pen, Phone, and Empty (where "Empty" means your hand is not holding anything).
  3. Record 30 samples for each class, deliberately varying the angle, distance, and lighting for each object.
  4. Train the model.
  5. Test it with your live webcam. Hold up the pen — does it say "Pen" with high confidence? Hold up the phone — does it say "Phone"? Now hold up an object you did not train on, like a book. What does the model predict? It should be uncertain or lean toward one of the classes — this is expected, because the model has never seen a book.
  6. Now delete all your data and retrain with only 5 samples per class, holding each object perfectly still. Compare the confidence scores. Write down the difference.

Self-verification: You have succeeded if your model with 30 varied samples gives confidence scores above 85% for the pen and phone, and if your model with 5 static samples gives noticeably lower confidence or outright wrong predictions. If you see this difference, you have just experienced firsthand the most important principle in machine learning: the data is the model.

In the next chapter, we will explore what happens when this training process goes wrong — why models sometimes produce confident but completely false answers, a phenomenon known as hallucination.

Loading ratings...

    The Training Journey: From Data to Knowledge | AI Tutorials Academy | AI Tools Oasis