Learning theory basics

Lecture 2 · Machine Learning for ICE · University of Klagenfurt, 2023

Nunzio Alexandro Letizia

This lecture

Lecture 2 of 8

  1. Why and when to use machine learning for an engineering task
  2. Data types, and the four ways of learning from them
  3. Learning theory: Bayes, estimation, information

From Machine Learning for ICE at the University of Klagenfurt, first taught in 2022: this is the 2023 edition, so some of it may be a little dated. All lectures.

Why and when

01

Why machine learning, why now

  • a huge amount of collected data
  • the growth of computing power, and GPUs above all
  • cloud computing, and its integration in everything
  • open-source frameworks and a whole ecosystem of tools around them

None of these was true twenty years ago, all of them are now.

When machine learning

A few guidelines on which engineering tasks can benefit from it.

  • The conventional, model-based engineering flow cannot be applied:
    • model deficit: no physics-based mathematical model is available
    • algorithm deficit: a model exists, but the algorithms are too complex to implement
  • A sufficiently large training dataset is available.
  • No background knowledge or application of logic is required.
  • The task does not require a detailed explanation of how the decision was made.
  • The phenomenon to learn is stationary during the observation period.
  • Performance guarantees can be provided via numerical simulations.

When machine learning: a decision

Model? y=f(x) yes Algorithm? e.g. \hat{\mathbf{x}}=(\mathbf{H}^{H}\mathbf{H})^{-1}\mathbf{H}^{H}\mathbf{y} yes Too complex? e.g. O(n^3) no Model-based design ✓

no model, no algorithm, or too complex Data available? y_i=f(x_i),\ i\in\mathcal{D}, \lvert\mathcal{D}\rvert large yes Go for ML

without enough data, neither route works ✗

Read it from the left: if a model exists, an algorithm exists and it runs fast enough, the classic design flow wins. A model deficit, an algorithm deficit or a complexity that is too high all lead to the same question: is there enough data? Only then does machine learning become an option.

What is machine learning

A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E.

Tom Mitchell, Machine Learning, 1997

Domain knowledge Physics-based mathematical model Algorithm development Performance guarantees

traditional engineering design flow

Data acquisition Data-driven parametric model Learning algorithm Trained model

machine learning design flow

Data and learning

02

Data types

Everything can be represented as data. Four types:

  • Numerical data, not ordered in time, usually measurable quantities
    • continuous, or discrete
  • Categorical data, usually qualitative features, ranks or classes
    • ordinal, with a hierarchy (first, second, third)
    • nominal, with none (eye colour)
  • Sequences, with dependence in time or space
    • streams such as audio, text, video, trends
  • Structured data
    • trees, graphs

Four ways of learning

  • Supervised learning builds a model from pairs of inputs and outputs (x_i,y_i).
  • Unsupervised learning builds a model from the inputs x_i alone.
  • Semi-supervised learning combines a small amount of labelled data with a large amount of unlabelled data.
  • Reinforcement learning learns a sequence of actions that maximizes a reward.

Tree: machine learning splits into supervised (classification, regression), unsupervised (clustering, dimensionality reduction) and reinforcement learning (sequential decisions, control).

Supervised versus unsupervised

Left: points with a fitted regression line. Right: unlabelled points falling into three clusters.

With labels, learn the map from x to y (here, a regression line). Without them, find the structure hidden in the x_i alone (here, three clusters).

Supervised learning

Pairs of samples (x_i,y_i)\sim p(x,y), i=1,\dots,N. In practice, find a parametric model such that

y_i=f(x_i;\theta)

Objective Model
estimate p(y\mid x) discriminative
estimate p(x,y) generative
Output y_i Problem
continuous regression
discrete classification

Unsupervised learning

Samples x_i\sim p(x), i=1,\dots,N, where a latent (hidden) variable z causes the observation x. In practice, find a parametric model such that

z_i=f(x_i;\theta)\quad\text{and/or}\quad x_i=g(z_i;\delta)

Objective Model
estimate p(z\mid x) discriminative
estimate p(x,z) generative
estimate p(z\mid x) and p(x\mid z) autoencoder

Typical problems: clustering (find groups), dimensionality reduction (transform the data), association (recommendations, frequent sequences).

Semi-supervised and reinforcement learning

Semi-supervised learning

  • a large amount of samples x_i\sim p(x), and a small amount of pairs (x_i,y_i)\sim p(x,y)
  • applications: web page ranking, document classification, spam detection

Reinforcement learning

  • an agent learns to act in a dynamic environment, finding the sequence of actions that maximizes a reward
  • the basic setting is modelled as a Markov decision process

The agent sends an action to the environment, which returns the next state and a reward.

Learning theory

03

Bayes’ rule

Channel input x\sim p_X(x) Medium p_{Y\mid X}(y\mid x) Channel output y\sim p_Y(y)

\underbrace{p(x\mid y)}_{\text{posterior}}=\frac{\overbrace{p(y\mid x)}^{\text{likelihood}}\cdot\overbrace{p(x)}^{\text{prior}}}{p(y)}

  • Posterior: how likely the input x is, after observing the output y.
  • Likelihood: how likely the output y is, given the input x.
  • Prior: how likely the input x is, without any knowledge of the output.

Estimation: MAP

In communications we want the maximum a posteriori (MAP) estimate

\hat x=\arg\max_x\,p(x\mid y)

If we do not know the posterior but we know the likelihood and the prior, Bayes gives

\hat x=\arg\max_x\,p(y\mid x)\,p(x)=\arg\min_x\,\big[-\log p(y\mid x)-\log p(x)\big]

If the source is uniform, the prior is a constant. If the channel is AWGN,

p(y\mid x)=p_N(y-x)=\frac{1}{\sqrt{2\pi}\,\sigma_N}\,e^{-\frac12\left(\frac{y-x}{\sigma_N}\right)^2}

and we recover the Euclidean distance: \ \hat x=\arg\min_x\,-\log p(y\mid x)=\arg\min_x\,\lvert y-x\rvert^2.

MAP, in a picture

Two Gaussian likelihoods centred at minus one and plus one, crossing at zero, with the decision threshold at zero.

Two equally likely symbols x=\pm1 through AWGN: the MAP receiver decides for the larger of p(y\mid x)\,p(x), so the threshold sits where the curves cross, at y=0. The shaded tails are the errors.

Estimation: maximum likelihood

What if p(y\mid x) is unknown? Use a parametric model p(y\mid x;\theta) and estimate \theta by maximum likelihood. With N i.i.d. pairs of samples:

\begin{aligned} \hat\theta&=\arg\max_\theta\,\prod_{i=1}^N p(y_i\mid x_i;\theta)=\arg\max_\theta\,\sum_{i=1}^N\log p(y_i\mid x_i;\theta)\\ &=\arg\max_\theta\,\mathbb{E}_{(x,y)\sim\hat p_{\text{data}}}\big[\log p(y\mid x;\theta)\big]\\ &=\arg\min_\theta\,\mathrm{CE}(\hat p_{\text{data}},p_\theta) \end{aligned}

Dividing the sum by N does not move the maximum, and turns it into an expectation over the empirical distribution of the training set. \mathrm{CE}(\cdot,\cdot) is the cross-entropy.

Minimizing a negative log-likelihood is minimizing a cross-entropy: between the empirical distribution of the training set and the model. The mean squared error, for instance, is the cross-entropy with a Gaussian model.

After Goodfellow, Bengio and Courville, Deep Learning, section 5.5.

Information basics

Information theory quantifies how much information a signal carries. We want a measure where

  • likely events carry little information, unlikely events carry more,
  • independent events carry additive information.

The information of an event x is I(x)=-\log p(x), and the entropy of a source is its average information, H(X)=-\mathbb{E}_{x\sim p(x)}\big[\log p(x)\big]

To measure how different two distributions p and q are, we use the Kullback-Leibler divergence

D_{\mathrm{KL}}(p\,\|\,q)=\mathbb{E}_{x\sim p(x)}\left[\log\frac{p(x)}{q(x)}\right]\ge0,\qquad D_{\mathrm{KL}}(p\,\|\,q)=\mathrm{CE}(p,q)-H(X)

KL divergence, in a picture

Two Gaussian densities p and q, shifted and with different widths, with the KL divergence between them printed.

D_{\mathrm{KL}}(p\,\|\,q) is zero only when the two distributions coincide, and it is not symmetric: in general D_{\mathrm{KL}}(p\,\|\,q)\neq D_{\mathrm{KL}}(q\,\|\,p). It comes back in lecture 8, inside the loss of the variational autoencoder.