Machine Learning

Machine learning is the field of study that gives computers the ability to learn without being explicitly programmed (Arthur Samuel, 1959).

Can also be defined as:

  • “Computational methods using experience to improve performance or to make accurate predictions”.
  • “A computer observes some data, builds a model based on the data, and uses the model as both a hypothesis about the world and a piece of software that can solve problems”.
  • “A set of methods that can automatically detect patterns in data, and then use the uncovered patterns to predict future data”.
Link to original

Types of ML

Supervised Learning

Supervised Learning

Supervised Learning: the program is ‘trained’ on a given set of examples (with labels). It learns how to reach an accurate conclusion when given new data.

Link to original

Components of successful machine learning

  1. Representative training data: annotated data the model learns from
  2. Sophisticated methods for extracting features used to represent data Features are easily observable properties of the data based on which the model will try to make predictions
  3. Sophisticated choice of machine learning algorithm

How does supervised learning work?

We use to represent the attributes / features of some data, usually dimensional vectors of numbers. Can be complex objects e.g. coordinates, images, time series. We use to represent the class which some given data belongs to.

Start from a training set that contains the right answers :

The training set is a set of input features (can be a vector of values) and outputs (single elements / classes).

A supervised learning algorithm can study the training set and learn to classify iris flowers into the three different classes based on their features (Goodfellow et al., 2016)

The algorithm must then:

  • Learns a function that maps from features to class
  • Given , says what the correct is
  • Can predict a class using weighted combination of input features

We are particularly interested in such that , i.e. we want a learning model that performs well on new, never-before seen data. (we want the model to generalise well)

Suppose we want to recognise species of flowers

Our training data is iris flower pictures with appropriate annotations

Use to represent type of iris: ‘setosa’, ‘versicolor’, ‘virginica’ We can observe features such as petal area (length x width) and sepal area (length x width) as .

Classification Problem (AI)

Classification (supervised): organise data in classes and determine the class of new data points Where is the number of classes.

Common form is binary classification where , often written as . If then we have multiclass classification.

Link to original

Abstract

We can think of classification as function approximation, that is assuming . We then ‘learn’ by trying to estimate by creating an estimate . After learning, we predict an estimate of using .

Classification is often not very clear at the boundaries, so we instead interpret the problem such that it returns a probability of being in each class given some input and the set of training data:

Probabilistic classifiers give a distribution over classes, so if we have classes, we get a probability for each class.

Sometimes we may want to explicitly consider the model:

We can decide on a single class by choosing the one with the highest probability given the input: This is the most likely class label. (mode of the distribution) We also refer to it as the MAP estimate (maximum a posteriori).

Regression Problem (AI)

Regression (supervised): fit functions to data and determine values of new data points Similar to classification, but the output is instead continuous.

Link to original

Abstract

In linear regression, we assume output is a linear combination of input .

Where make up a weight vector and is the residual error.

‘Learning’ is the process of figuring out what should be to provide a good mapping. With different , we get different functions .

For a one dimensional input , we write Which is the same as saying . Then .

We call the intercept or bias and is the slope.

Here and and the function is a linear mapping from input to output:

Unsupervised Learning

Unsupervised Learning: the program is given a bunch of unlabelled data and must discover patterns and relationships in them.

In unsupervised learning:

  • we are provided with a data set
  • we need to find an understanding of interesting relationships within the data
  • we identify groups / clusters of interesting information within the data
  • can be used to identify where new points ‘fit’ within the data set

We use two common techniques: clustering and association rules.

Link to original

Abstract

We start from a set of examples and look for patterns / interesting structure in the data.

Unsupervised learning is sometimes called knowledge discovery. Our task is to build models of the form:

Clustering

Let be the number of clusters, we estimate the distribution over the number of clusters , often we simplify by approximating it by its mode:

Reinforcement Learning

Reinforcement Learning: the program learns from consequences of its actions (reward or punishment), rather than from being explicitly taught and selects its actions on basis of its past experiences (exploitation) and also by new choices (exploration).

Link to original

Parametric models

An ML technique is parametric if it makes assumptions about the structure of the data, otherwise it is non-parametric. (e.g. there are four Gaussian clusters)

Parametric models can be computationally simpler (linear regression) but the assumptions can lead to inaccuracy. Non-parametric models are more flexible (no assumptions) but intractable for large datasets.

Abstract

k-nearest neighbour (kNN) is a simple non-parametric classifier It looks at points in the training set that are nearest to the test input

More sophisticated version uses nearest points to estimate probability of class membership: Where are the indices of the nearest points to in and is an indicator function such that: Counts how many members of each class are in the nearest set.

kNN classifiers are simple and work well but they scale badly with high dimensional inputs

The scalability of kNN is related to the more general problem of the curse of dimensionality:

  • to better distinguish between examples, we need more features (dimensions)
  • this leads to the need for more examples to determine how features distinguish
  • otherwise, we overfit

This requirement grows exponentially.

One way to address this is to use parametric models, make sure assumption about best way to distinguish between examples. Meaning we assume something about the way examples are distributed / generated.

Overfitting

Overfitting is when the model fits too much to the training data and fails to generalise to unseen data. (see graph for degree 29)

Link to original

Performance measurement

In supervised learning, we look at “can we predict well given ?” We compute the misclassification rate: on the data we have as examples to learn from. Or its converse, proportion of correctly classified examples.

Abstract

This rate gives us some idea about whether we have learnt well from training data. But doesn’t say anything about new data (the generalisation error), that is, the misclassification rate on data we haven’t yet seen. We can estimate this by trying the classifier on test data that we didn’t see in training.

Learning curve

The learning curve is the % correct on test set as a function of training set size.

Link to original

We partition the training set into three subsets:

  • training set (~80%)
  • validation set (development set) (~10%) use for model selection / parameter tuning
  • test set (~10%) always remains unseen and used to evaluate generalisation performance

K-fold cross-validation

If we don’t have enough training examples, we could use K-fold cross-validation (CV):

  • Split data into equal subsets / folds to test on
  • Train on sets and test on remainder fold only
  • Repeat times (test on each fold only once)
  • Computer misclassification error averaged over all test folds

The final performance is the average of the performances for each fold. Average test set score is a better estimate of the error rate than a single score. Common values of are and , both giving error estimates that are very likely to be accurate.

Extreme case is when , the number of data points.

Link to original

Accuracy (AI)

Accuracy: given a classification algorithm and a test set, the accuracy is the proportion of correct predictions done by the algorithm over all predictions in the test set

Link to original

Abstract

In some practical applications, we may be more interested in false negatives than false positives. e.g. breast cancer detection, abusive language detection

Transclude of confusion-matrix

Precision

Precision: proportion of true positives over the true and false positives

Link to original

Sensitivity

Sensitivity (or recall): proportion of true positives over true positives and false negatives

Link to original

F1 Score

F1 Score: harmonic mean between sensitivity and precision

The general weighted form looks like this:

Link to original

ROC Curve

We can plot the ROC Curve (TP against FP as we vary threshold).

Dotted line is performance of random classifier (on average). Area under curve is related to probability that the classifier will correctly classify a randomly chosen example. The closer we are to the top left, the better the model is.

Link to original

Evaluating clusters

If we know what the clusters should be, we can use classification methods above. Otherwise we try:

  • external evaluation: how well the number of clusters serves a downstream task (e.g. market segmentation)
  • internal evaluation: establish how coherent the clusters are and how well separated they are from each other

Abstract

The Davis-Bouldin index for clusters:

Not in syllabus!

1 item under this folder.