MIT 6.790 — Lecture 1

Introduction to Machine Learning

§ Setting Up

Here's the classic machine learning setup.

Remark. The loss function may be asymmetric; consider, say, email spam detection.

§ The Optimal Hypothesis (Given the Distribution!)

Definition (Risk). A decision rule hh has risk defined by risk(h):=E[L(Y,h(X))]\mathrm{risk}(h) := \mathbb{E}[L(Y, h(X))].

Assume that all data (x(n),y(n))(x^{(n)}, y^{(n)}) (training or not) is drawn i.i.d. from the same distribution. Unsurprisingly, if we know this distribution p(x,y)p(x, y) exactly, finding the best hh is not hard.

Theorem. (Optimal Hypothesis) Suppose X\mathcal{X} is discrete and Y={1,,K}\mathcal{Y} = \{1, \dots, K\}. Then the following minimizes risk:

h(x)=arg minkj=1KL(j,k)costp(y=jx)probability.h(x) = \argmin_k \sum_{j = 1}^K \underbrace{L(j, k)}_{\text{cost}} \cdot \underbrace{p(y = j \mid x)}_{\text{probability}}.

Proof: Immediate from the definition of risk. You can generalize this to the continuous case if you'd like, too.   \blacksquare

The optimal hh takes a pretty nice form when we consider regression problems with a particular choice of loss. (Refer to Lecture 24 from 18.650 for additional context on why the loss function is what it is.)

Theorem. (Optimal Regression Hypothesis) Assume X=RD\mathcal{X} = \mathbb{R}^D, Y=R\mathcal{Y} = \mathbb{R}, and L(a,g)=(ag)2L(a, g) = (a - g)^2. Then an optimal decision rule is h(x)=E[YX=x]h(x) = \mathbb{E}[Y \mid X = x].

Proof: For a particular xx, we seek to find the kRk \in \mathbb{R} that minimizes the following “expected cost”:

C(k):=yR(yk)2p(yx)dy.C(k) := \int_{y \in \mathbb{R}} (y - k)^2 \cdot p(y \mid x) \, \mathrm{d}y.

Any minimizing kk must satisfy C(k)=0C'(k) = 0, or:

C(k)=yR2(yk)p(yx)dy=0      (yRyp(yx)dy)E[YX=x]=(yRkp(yx)dy)kC'(k) = \int_{y \in \mathbb{R}} -2(y - k) \cdot p(y \mid x) \, \mathrm{d}y = 0 ~ \implies ~ \underbrace{\left(\int_{y \in \mathbb{R}} y \cdot p(y \mid x) \, \mathrm{d}y\right)}_{\mathbb{E}[Y \mid X = x]} = \underbrace{\left(\int_{y \in \mathbb{R}} k \cdot p(y \mid x) \, \mathrm{d}y\right)}_{k}

Thus k=E[YX=x]k = \mathbb{E}[Y \mid X = x] is a critical point. Furthermore, C(k)>0C''(k) > 0 for all kRk \in \mathbb{R}, as shown below.

C(k)=yR2p(yx)dy=2C''(k) = \int_{y \in \mathbb{R}} 2 \cdot p(y \mid x) \, \mathrm{d}y = 2

Thus k=E[YX=x]k = \mathbb{E}[Y \mid X = x] must be the unique minimizing value.   \blacksquare

Of course, the challenge of ML is that we don't know what pp is…