No history yet

Machine Learning Mechanics

How Machines Actually Learn

When we say a machine 'learns,' we're not talking about consciousness or understanding. Machine learning is fundamentally about pattern recognition and optimisation. A model is given data, makes a prediction, and then checks how wrong its prediction was. The 'learning' part is the process of systematically reducing that error over and over again, until its predictions are consistently useful. This process is driven by algorithms that fine-tune the model's internal parameters.

The strategy for this error reduction process depends on the type of data available and the goal of the task. The two most common approaches are supervised and unsupervised learning, which we can think of as learning with an answer key versus learning without one.

Learning with a Teacher

Supervised learning is like studying for a test with a complete set of practice questions and their corresponding answers. The model is trained on a dataset where every input comes with the correct output label. For example, to train a model to identify cats in images, you'd feed it thousands of pictures, each explicitly labelled 'cat' or 'not cat'.

The model's job is to figure out the relationship, or mapping, between the input (the image pixels) and the output (the label). It starts by making a guess. Initially, these guesses are random and likely wrong. To improve, the model needs to know how wrong it is. This is measured by a loss function, a mathematical formula that calculates the difference between the model's prediction and the actual correct label. A high loss value means a big error; a low value means the model is close to the right answer.

Lesson image

The goal is to minimise this loss. The most common method for doing this is an optimisation algorithm called . Imagine the loss function as a vast, hilly landscape, where the lowest point, or valley, represents the minimum possible error. Gradient Descent is like a hiker trying to get to the bottom of this valley in a thick fog. They can't see the whole landscape, so they check the slope of the ground right where they're standing and take a small step in the steepest downhill direction. By repeating this process, they gradually make their way to the bottom.

In machine learning, the 'steps' are adjustments to the model's internal parameters. Each step is calculated to reduce the loss, making the model's next prediction slightly more accurate. This iterative process of predict, measure loss, and adjust is repeated thousands or even millions of times, until the model's performance stops improving.

Learning Without an Answer Key

Unsupervised learning tackles a different problem: finding hidden structure in unlabelled data. Here, the model receives only inputs, with no corresponding correct outputs. The goal isn't to predict a specific label, but to discover interesting patterns or groupings within the data itself.

Think of it like being given a huge box of mixed Lego bricks and being asked to sort them. You don't have instructions, but you can start grouping them by colour, shape, or size. This is called clustering. An unsupervised model might cluster customers into different purchasing behaviour groups or group news articles by topic without being told what the topics are.

Another key unsupervised task is dimensionality reduction, which simplifies complex data by finding a more efficient way to represent it. It identifies the most important features and discards the less relevant ones, making the data easier to process and visualise without losing crucial information.

The Balancing Act of Generalisation

The ultimate goal for any model is to generalise, meaning it should perform well on new, unseen data, not just the data it was trained on. Two common pitfalls get in the way of this: underfitting and overfitting.

Underfitting occurs when a model is too simple to capture the underlying patterns in the data. It performs poorly on both the training data and new data. It’s like trying to summarise a complex novel in a single sentence; you lose all the important details.

Overfitting is the opposite problem. The model becomes too complex and essentially memorises the training data, including its random noise and quirks. It performs exceptionally well on the training set but fails miserably when it encounters new data. It's like a student who memorises the answers to a practice exam but can't solve slightly different problems on the real test.

Achieving the right balance requires careful data preparation and model selection. One of the most critical steps before training is . This is the art and science of selecting, transforming, and creating the input variables (features) that a model uses to make predictions. Good features make the underlying patterns in the data more apparent, helping the model learn effectively and avoid both underfitting and overfitting. This could involve combining two columns of data, removing irrelevant information, or scaling numerical values so they fall within a similar range.

Finally, a third major type is reinforcement learning, where a model learns by trial and error in an interactive environment. It receives rewards for good actions and penalties for bad ones, gradually learning a strategy to maximise its cumulative reward. This is the approach used to train AIs to play games like Chess or Go.

Understanding these core mechanics—how a model measures error, how it corrects itself, and the pitfalls it must avoid—is the key to seeing machine learning not as magic, but as a powerful, data-driven engineering process.

Let's check your understanding of these core concepts.

Quiz Questions 1/6

In the context of machine learning, what does the term 'learning' fundamentally refer to?

Quiz Questions 2/6

A data scientist is given a dataset of customer information without any predefined groups or labels. Their task is to identify distinct segments of customers with similar purchasing habits. Which type of machine learning is most appropriate for this task?

With these fundamentals in place, you're ready to explore how these different learning methods are applied to solve real-world problems.