# What is a machine learning model?

In this article, we will explain what machine learning models are, and how they are developed and evaluated.

## What is a machine learning model?

A machine learning model is a program or a file that applies statistical/mathematical techniques in order to recognise certain types of patterns present in the data.

The model learns and improves by experience using data to train and also learns from its mistakes. After the training phase, the resulting model can be used on data similar to the ones used for training but never seen by the model.

For example, a model trained to recognise brain cancer can be trained on a set of data and then used in a hospital to recognise breast cancer on new images because the structures of cancer cells are quite similar.

### Playing a crucial role

The machine learning model plays a crucial role in many of the key features of autonomous systems, like self-driving cars. For example, a machine learning model could be used to identify pedestrians at a crossing when they are approaching or are crossing the street.

Obviously, accurately identifying pedestrians has a big impact on assuring the safety behaviour of the whole self-driving cars. So it is crucial that the system has an accurate model, on which to base this identification.

## Classification and Regression

The mechanism by which the model learns is similar to the way in which humans learn and the techniques used to simulate how the human brain works.

Machine learning models can solve a large variety of problems which can be divided into two broader categories: classification and regression.

### Classification

In a classification problem, the model predicts what class an image is likely to belong to, applying a label recognising different classes of objects – such as different types of pedestrians approaching the crossing (e.g. child, adult, cyclist).

### Regression

In a regression problem, the model predicts numeric values, for example, possible selling prices for houses in different parts of London.

## Supervised and Unsupervised Learning

These types of problems can be solved by adopting different learning paradigms like supervised and unsupervised learning.

### Supervised learning

In supervised learning, during the training phase, the model learns from a set of data that consists of pairs of inputs/outputs (e.g image of pedestrian/type of pedestrian). Based on what it has learned, it can then predict outputs on new data.

### Unsupervised learning

In unsupervised learning, the data considered in the training phase consists only of inputs, and the model learns similar patterns in the inputs. A popular use of unsupervised learning is clustering where the model groups the data samples in different classes.

## Training Data and Test Data

Whatever problem the model is trying to solve and whatever learning paradigm we decide to use, the most crucial choice is the set of the data from which the model will learn.

During the development of the model two sets of data are usually used: the training data and the test data.

### Training data

The training data set is used to learn patterns and solve specific problems.

### Test data

The test data set is then used to evaluate the model’s ability to generalise from what it has learned, evaluating its performance on data never seen during the training phase.

The generalisation ability of the model is very important because it gives a sense of how well the model is likely to perform on real-world data.

## Verification Data

After the model is created and its performance on the test set is considered satisfactory, we need to verify the model using a third data set called verification data.

The verification data comprises data samples consisting of edge cases and cases that are known to be difficult for the model, designed in order to induce errors in the model and test its robustness.

The verification of the model is very important, to ensure that the model will also perform well in difficult situations when it is deployed in the real world. This aspect is crucial to ensure that the model behaves safely and detects objects correctly when it encounters rare situations, like a person wearing a duck suit.

### Formal verification

The verification of the model, in some cases, can be done also in a formal way, translating determined properties with mathematical formulas which can be formally proved.

Formal verification is preferred because it provides a means of mathematically proving the model but, unfortunately, it can be difficult to translate real-world properties into mathematical formulae.

Even when this is possible, it can be challenging to map the results to relevant contextual information: for example, it can be difficult to see the connection between a change in a pixel value and the change in an environmental condition it represents.