Skip to content

Week 1 Lecture 2

Christian Igel
@christian_igel

The Learning Problem

Christian’s slides are “pretty self-contained”. They should work as course notes

Supervised Learning Scenario

Learning is goal-directed changingof behaviour based on experience

Binary Classification

Two classes: {apples, pears}, {-1, 1}

Supervised learning is to uncover an unknown relation between the input and output space

Based on sample input-output data

S = {(x_1, y_1),…,(x_N,y_N)}

l.i.d.: identically independently distributed

assumtion: Each pattern in the distribution is drawn independently from a stable distribution 𝑝 over (𝒳︀,𝒴︀)

𝑝((𝑥,𝑦))=𝑝(𝑥)·𝑝(𝑦|𝑥)

for example:

  • The probability of a (red, 8cm, round) fruit is always the same for each sample
  • Probability of being an apple is the same for each fruit that is (red, 8cm, round)

A hypothesis ℎ:𝒳︀→𝒴︀ maps inputs to outputs. A hypothesis class ℋ︀ is a set of such functions

Applying a learning algorithm means finding a hypothesis given sample data. i.e. it maps from 𝒳︀×𝒴︀ to ℋ︀

Loss/risk function: numberically show how bad a certain output is. 𝓁︀:𝒴︀×𝒴︀→[0,∞[, where 𝓁︀(𝑦,𝑦)=0

Given sample data, we want to find hypothesis showing good average performance

I.e. we want to minimize the risk:

ℛ︀𝑝(ℎ)=𝔼(𝑥,𝑦)∼𝑝{𝓁︀(𝑦,ℎ(𝑥))}

Empirical risk of ℎ on a sample data 𝑆 (𝑁≔|𝑆|) is:

ℛ︀𝑝(ℎ)=1𝑁∑𝑖=1𝑁𝓁︀(𝑦𝑖,ℎ(𝑥𝑖))

If we define the loss function to be: 𝓁︀(𝑦,ℎ(𝑥))=𝕀(ℎ(𝑥)≠𝑦), then the empirical risk is:

ℛ︀𝑠(ℎ)=1𝑁∑𝑖=1𝑁𝕀{ℎ(𝑥𝑖)≠𝑦𝑖}

(Indicator function 𝕀{·} is 1 if it’s argument is true, otherwise 0)

Regression: Under the squared error 𝓁︀(𝑦,𝑦̂)=(𝑦−𝑦̂)2 the empirical risk corresesponds to the sum-of-squares error

Minimum risk over all measrable functions is the Bayes risk

ℛ︀𝑝Bayes=ℛ︀𝑝(ℎBayes)=infℎℛ︀𝑝(ℎ)

usually differs from ℛ︀𝑝∗=ℛ︀𝑝(ℎ∗)=infℎ∈ℋ︀ℛ︀𝑝(ℎ)

For 𝒴︀={−1,1}, the bayes risk is: ℎBayes(𝑥)=sgn[𝔼𝑝(𝑌|𝑋=𝑥)]. This can be done just by choosing the most likely one.

Algorithm 𝑎 is consistent if lim𝑁→∞ℛ︀𝑆(𝑎(𝑆))=𝑅𝑝Bayes

In many cases, ℛ︀(ℎBayes)=0 can’t be reached

“No free lunch”

Prior knowledge can be incorporated by:

  • restriction of the hypothesis space (inductive bias)
  • a proper definition of neighbourhood/similarity (i.e. by defining some metric)
  • penalising the “complexity” of classifiers (i.e. preferring simpler solutions)

Nearest Neighbor Classification

Every point is classified as the sample that’s nearest to it

Idea:

  • given training data 𝑆={(𝑥1,𝑦1),…,}

“nearest” requires some understanding of “similarity”; a metric.

Metric or distance function on 𝒳︀ is a function 𝑑:𝒳︀×𝒳︀→ℝ with the following properties (∀𝑥,𝑦∈𝒳︀):

  • 𝑑(𝑥,𝑦)≥0
  • 𝑑(𝑥,𝑦)=0⇔𝑥=𝑦
  • 𝑑(𝑥,𝑧)≤𝑑(𝑥,𝑦)+𝑑(𝑦,𝑧) (triangle inequality)

1-Nearest neighbor (1-NN): just finding the nearest item from the training data K-Nearest neighbor (K-NN): just finding the nearest 𝑘 items from the training data, and use the result that’s the most common from them.

Generalization and Regularization

1-NN will be (by definition) errorless on the training data

Minimizing empirical risk does not imply good generalization → overfitting

We can see, that training data is not good for evaluating a hypothesis. We need some test data.

𝔼𝑆∼iid𝑝[ℛ︀𝑆(ℎ)]=𝔼(𝑥,𝑦)∼𝑝{ℓ(𝑦,ℎ(𝑥))}=ℛ︀𝑝(ℎ)

I.e. ℛ︀𝑆(ℎ) (empirical risk over the test data) is an unbiased estimator of ℛ︀(ℎ) (risk of the hypothesis)

law of large numbers mentioned (larger testing set will improve risk estimate)

Selection of hypothesis (lecture note):

  • Choosing the archer with the most bullseyes probably chooses the best archery player
  • BUT if a room of 100 were to flip 1000 coins, and we choose the person who had the most tails, the expected number of tails is obviously over 0.5.
  • if we were to apply this to finding minimum risk over some hypotheses, we’d find a good hypothesis, but an overoptimistic estimate of its risk
  • 𝔼[max(𝑋1,…,𝑋𝑀)]≥max(𝔼[𝑋1],…,𝔼[𝑋𝑀]) (Jensen’s inequality)

Cross-validation for Hyperparameter Selection

How to chose 𝐾 for K-NN

Algorithm parameters like 𝐾 are called hyperparameters

Model selection: finding hyperparameters

Standard method for selecting from a few hyperparameters: 𝜅-fold cross-validation

  • Select a value for the hyperparameter
  • Split 𝑆 into 𝜅 parts (hopefully even parts)
  • Train 𝜅 times on 𝜅−1 parts and test the held-out part (test set)
  • The estimate for that specific hyperparameter setting, is the mean of all 𝜅 empirical risks
  • Take hyperparameters maximising mean performance on the test set