Saying that a machine “learns” sounds like science fiction, but it describes something quite concrete. A traditional program does exactly what someone wrote, line by line. A Machine Learning model, on the other hand, receives examples and adjusts its behavior until its answers look like the correct ones. Nobody dictates the rules: it deduces them from the data.
The most common way to do this is called supervised learning, and it powers many systems you use without noticing: spam filters, card fraud detection or product recommendations. In this article you’ll see what a machine needs to learn this way, what actually happens during training and how you check that the model learned something useful instead of memorizing. To keep it from staying theoretical, everything is built on a real exercise: a model I trained to tell benign tumors from malignant ones using cell measurements.
Learning from examples with a known answer
Supervised learning is a Machine Learning training method that requires labeled data: each example includes its input data and, alongside it, the correct answer. That answer is the label. The model uses thousands of “input → answer” pairs to discover the relationship between them, and then applies that relationship to new data that comes without an answer.
That’s where the name comes from. Labels act as a supervisor that, during training, tells the model what the expected answer was in each case. Without them, the model could still find groups or structures in the data, but it wouldn’t know what they mean.
In the previous lesson you saw the difference between writing rules by hand and letting them come from the data. Supervised learning is the most direct version of that second idea: you provide the examples and the answers; the model provides the rules.
What a labeled example contains
The exercise uses a public dataset that is well known in Machine Learning, Breast Cancer Wisconsin (Diagnostic). It has 569 records. Each one comes from the digitized image of a fine needle aspirate biopsy, and its columns describe the cell nuclei that appear in that image.

The features describe the case; the label says what it is. The model learns to go from one to the other.
Each record has two parts:
- Features: 30 numeric measurements. They come from ten properties of the cell nucleus, such as radius, texture, perimeter, area or the smoothness of its contour, and from three statistics for each one: the mean, the standard error and the worst value found in the image. Texture, for example, isn’t a visual impression: it’s the standard deviation of the gray-scale values inside the nucleus.
- Label: the confirmed diagnosis, benign or malignant.
The model never sees the image and doesn’t know what a cell is. It only sees numbers and the label that comes with them. Its job is to find which combinations of those numbers tend to appear with each diagnosis.
What happens during training
Training a model isn’t loading data into it all at once. It’s a process that repeats many times, and on each pass the model improves a little.

The model doesn’t receive the rules: it keeps adjusting them based on its own mistakes.
In each round, the model makes a prediction for the training examples, compares it with the real labels and calculates how wrong it was. That error is summarized in a number the algorithm tries to reduce. Then it adjusts its internal parameters in the direction that reduces the error the most, and starts again.
In my exercise I used XGBoost, a widely used algorithm for tabular data. XGBoost builds its model as a sum of small decision trees. Each round adds a new tree, and that tree focuses on correcting the mistakes the previous ones still make. I trained the model for 100 rounds in Amazon SageMaker AI, the AWS service for building, training and deploying Machine Learning models.
It’s similar to studying with practice exams: you answer, review what you got wrong and focus on that next time. The difference is that the model does it hundreds of times in seconds and with a numeric precision we don’t have.
Learning isn’t memorizing
Here comes the most important trap in supervised learning. A model with enough capacity can end up getting every training example right without having learned anything that generalizes: it simply memorized them. This is called overfitting, and an overfitted model fails as soon as it receives a case it didn’t know.
The only honest way to know whether it really learned is to evaluate it with data it has never seen. That’s why, before training, the 569 records were split into three groups:

The test group is the final exam: it takes no part in any training decision.
- Training (398 records): the examples the model learns from.
- Validation (85 records): used to monitor training. In each round, the model’s performance on them is measured, without using them to adjust it directly.
- Test (86 records): kept aside and used only once, at the end.
On those 86 new cases, the model got 84 right. It’s a good sign that it found real patterns in the measurements and didn’t just remember the examples it already knew.
Why 84 out of 86 doesn’t tell the whole story
97.7% accuracy sounds excellent, but it doesn’t say where the mistakes are. And in this problem, that matters a lot. The two cases it missed were malignant tumors that the model classified as benign. On the other hand, it didn’t flag any benign case as malignant.
Those two kinds of error don’t cost the same. A false alarm leads to more tests. A missed malignant case can mean someone doesn’t get care in time. That’s why, when evaluating a model, besides the accuracy you check what kind of mistakes it makes. In the full lab article I explain how to read those mistakes with a confusion matrix and how to tune the model according to the cost of each one.
For the same reason, this model is an educational exercise, not a medical diagnosis tool. A clinical system requires much more data, validation with real patients, specialist oversight and regulatory compliance that a learning lab doesn’t cover.
Classifying or predicting a number
The exercise is a classification problem: the answer is a category. But supervised learning also solves problems where the answer is a numeric value. Those are called regression problems.

Both tasks learn from examples with a known answer; only the type of answer changes.
The mechanics are the same in both cases: examples with their answer, training in rounds and evaluation with new data. What changes is how the error is measured. In classification you count how often it got the category right and what kind of mistakes it made. In regression you measure how far the predicted number landed from the real value.
What supervised learning needs
This method works very well when you have good labeled data, and that is also its main limitation. Labeling costs effort: someone has to confirm each diagnosis, review each transaction or classify each email. That’s why tools like Amazon SageMaker Ground Truth exist, to help organize labeling jobs with people and create datasets for training.
The other limitation is that the model learns the world as it appears in its data. If the data changes over time, for example because different imaging equipment is used or the population changes, the model can lose accuracy and need to be retrained.
What to take away from this lesson
A machine learns, in the sense of supervised learning, when it adjusts its behavior based on examples with known answers. The features describe each case, the label says which answer is correct and training repeats a simple cycle: predict, compare, measure the error and adjust. What proves it learned isn’t how well it does with the examples it already saw, but how it responds to new cases.
But not all machines learn with labels. Some models group data without anyone telling them what it means, and others learn by trying actions and receiving rewards. Those types of learning are the next step on the AI from Zero path.
References
- What is Supervised Learning? — AWS
- What’s the Difference Between Supervised and Unsupervised Learning? — AWS
- Breast Cancer Wisconsin (Diagnostic) — UCI Machine Learning Repository
- XGBoost algorithm with Amazon SageMaker AI — AWS Documentation
- Amazon SageMaker Ground Truth — AWS
Keep learning:
- Previous lesson: AI, Machine Learning and Deep Learning
- The full lab on Amazon SageMaker AI (level 200)
- Code on GitHub: sagemaker-clasificacion-lab
- Next lesson: types of learning (coming soon to the blog)
If this article helped you, share it with someone who is just getting started with the cloud. See you in the next AWS Unmapped article.
