Skip main navigation

How do Machines Learn?

As we journey into the inner workings of machine learning, we are going to explore the process used to create extremely specialised AI programs. This is the process of Machine Learning.

As we journey into the inner workings of machine learning, we are going to explore the process used to create extremely specialised AI programs. This is the process of Machine Learning.

What is Machine Learning?

A set of tools and practices that use data to train an AI algorithm to produce a better, more accurate, output.

Rather than programming the rules for a task directly, you can think of machine learning as a process that enables a program to create its own rules for completing a task.

The end product is called a model. When the learning has finished, you deploy the model into an AI program that knows how to interpret the results.

The Machine Learning Process

Whilst every machine learning project is different, they all follow the same cycle.

A flowchart showing the process of a machine learning project. Input is on the left with an arrow leading to Train. Another arrow goes from Train to the third stage, Test. At this point, the algorithm is either deployed, or returns to the input stage for another round.


The very first step is to gather the relevant data and cleanse it using data science. You can then split the data into training and test sets.


The model will repeatedly analyse the training data and attempt to produce the desired output, adjusting as it goes to become more accurate.


During testing, the model is exposed to test data, which it has not seen before. If your model is accurate for the training data but fails the tests, your model has been overfitted. When the model has not been trained enough, it will be inaccurate on both the training and test data – this is called underfitting.

Machine learning models will usually include a confidence score with their predictions. You can use these to gauge how well your model was trained and to identify data points that it is unsure about.

If you are not happy with the results, you can put the model back through training. When you do this, you will often include new examples in the training set to correct errors found during testing.

How to Train Your Machine

The training processes for machine learning can differ widely depending on the type of problem, but almost all of them will follow this same pattern.

A flowchart showing the training process, with predict flowing into error/loss, and then moving on to adjustment, before looping back around to predict again.


The model will consist of rules for how to treat the different features within your data. The initial rules are often random, to give the algorithm somewhere to start.

The model will then use these rules to make a prediction about the outcome for each data point. To use an earlier example, your rock, paper, scissors model, it would look at each training image and make a prediction about whether it was rock, paper or scissors.

It might not use all the data at once, instead breaking it into batches and you can control the batch size in most machine learning systems. The training process would be much slower if the model had to check every error and adjust after every single data point, so instead the model is updated after each batch. When your model has looked at all of the data points – it is called an epoch. In a typical training process, there are multiple epochs, as the process is repeated until the error is as small as possible.


After the model has made its predictions, the algorithm will then check how accurate the model was. This process is called error/loss. The model needs some way of scoring itself; typically, this is generated by using a error or loss function that returns a single value showing how different the model’s predictions were to the actual outcome.

In the earlier example of plotting a line on the graph of AirBnB rentals, the error function sums the error values (the vertical distance from the line) for every point.


Before the next iteration, the algorithm will adjust the model’s rules. The size of that change will be determined by the amount of error and the learning rate you set before training starts. The learning rate determines the step size the algorithm uses to change the model’s rules; the higher the error in the iteration, the more steps the algorithm will use to adjust the model.

A large learning rate will make the training process quicker, as large steps quickly lead to plateaus in the amount of error. However, finding the perfect sweet spot requires fine adjustments, so although it may take longer, a lower learning rate tends to lead to a more accurate model.

Knowing when to stop

There are two factors that will determine when you stop the training process;

  1. The model’s accuracy
  2. The number of epochs

Eventually, your model will reach a point where a round of adjustment only leads to a negligible change in the error. You might also set a maximum number of iterations (or epochs) after which you will stop training.

Key terms

Here is a recap of the terms in machine learning:

Term Definiton
Model An algorithm trained by machine learning
Deployment Importing a model into another program, which can interpret its results
Confidence score A percentage accompanying a prediction; it shows how confident the model is in its output
Batch The number of data points examined before the model is adjusted
Epoch A full pass over the training set, so every data point has been examined once
Learning rate The size of adjustment steps made to a model to fix the error
This article is from the free online

Introduction to Machine Learning and AI

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education