Docsity

Linear Regression-Introduction to Machine Learning-Lecture 04-Computer Science, Lecture notes of Introduction to Machine Learning

Partial preview of the text

Download Linear Regression-Introduction to Machine Learning-Lecture 04-Computer Science and more Lecture notes Introduction to Machine Learning in PDF only on Docsity!

Lecture 4: Linear regression

TTIC 31020: Introduction to Machine Learning

Instructor: Greg Shakhnarovich

TTI–Chicago

October 4, 2010

Administrivia

TA: Feng Zhao

5 homework assignments (1.5-2 weeks apart)

  • (^) Each HW worth 12% of the grade

Final during finals week

  • (^) 40% of the grade

My office hours: by e-mail appointment

Feng’s office hours: Friday 3-5pm

Regression: setup

An observation consists of an input x paired with label y.

  • (^) yi is sometimes called output or target value.

We are given a set of N observations (xi, yi), i = 1,... , N

Example: measurements (possibly noisy!) of barometric pressure x vs. water boiling point y (^) in.

◦F

Does it make sense to use learning here?

Fitting function to data

Two goals in mind:

1 Explain the data (traditional statistics)

2 Make predictions (emphasized in machine learning)

We will proceed in two steps: 1 Choose a model class of functions

Fitting function to data

Two goals in mind:

1 Explain the data (traditional statistics)

2 Make predictions (emphasized in machine learning)

We will proceed in two steps: 1 Choose a model class of functions 2 Design a fitting criterion, to guide selection of a function from the class. Let’s start with (almost) the simplest model class: linear functions.

Linear fitting to data

We want to fit a linear function to an observed set of points X = [x 1 ,... , xN ] with associated labels Y = [y 1 ,... , yN ].

  • (^) Once we fit the function, we want to use it to predict the y for new x.

(xi, yi)

Linear fitting to data

We want to fit a linear function to an observed set of points X = [x 1 ,... , xN ] with associated labels Y = [y 1 ,... , yN ].

  • (^) Once we fit the function, we want to use it to predict the y for new x. Least squares (LSQ) fitting criterion: find the function that minimizes sum (or average) of square distances between actual ys in the training set and predicted ones.

(xi, yi)

(^2 2 ) min (^2) ++ + + + + +

(^2 )

Linear fitting to data

We want to fit a linear function to an observed set of points X = [x 1 ,... , xN ] with associated labels Y = [y 1 ,... , yN ].

  • (^) Once we fit the function, we want to use it to predict the y for new x. Least squares (LSQ) fitting criterion: find the function that minimizes sum (or average) of square distances between actual ys in the training set and predicted ones.

(xi, yi)

(^2 2 ) min (^2) ++ + + + + +

(^2 )

x 0

Linear functions

General form: f (x; w) = w 0 + w 1 x 1 +... + wdxd

1D case (X = R): a line

X = R^2 : a plane

Hyperplane in general, d-D case.

Notation

We will mostly stick to these throughout the course:

xi the i-th data point in X (column vector)

Often X ≡ Rd, so that [x( 1 i ),... , x( di )]T

yi the label of the i-th data point; yi ∈ Y

x 0 , y 0 a single test point and its (unknown) label

X the N × d data matrix where i-th row is xTi

y the label vector y = [y 1 ,... , yN ]T

Empirical loss

We consider a parametric function f (x; w) Linear function: f (x; w) = wT^ x

The empirical loss of function y = f (x; w) on a set X:

L(w, X) =

N

∑^ N

i=

L (f (xi; w), yi)

LSQ minimizes the empirical loss for squared loss L.

We care about accuracy of predicting labels for new examples. Why/when does empirical loss minimization help us achieve that?

Loss: empirical and expected

Fundamental assumption: example x/label y are drawn from an joint probability distribution p(x, y).

Data are i.i.d.: same (unknown!) distribution for all pairs (x, y) in both training and test data.

We can measure the empirical loss on training set

L(w, X) =

N

∑^ N

i=

L (f (xi; w), yi)

The ultimate goal is to minimize the expected loss, also known as risk:

R(w) = E(x 0 ,y 0 )∼p(x,y) [L (f (x 0 ; w), y 0 )]

Learning via empirical loss minimization

Two steps:

Select a restricted class H of hypotheses f : X → Y

  • Linear functions, parametrized by w: yˆ = f (x; w) = w 0 +

∑d i=1 wixi Select a hypothesis f ∗^ ∈ H based on training set (X, Y ) current approach: minimize empirical loss

  • (^) Least squares regression: f ∗^ ≡ f (x; w∗) where

w∗^ = argmin w

∑^ N

i=

(yi − w 0 −

∑^ d

j=

wj x( ji ))^2

How do we find w∗^ = [w∗ 0 , w 1 ∗,... , w d∗]T^?

Least squares: estimation

We need to minimize w.r.t. w

L(w, X) = L(w) =

N

∑^ N

i=

(yi − f (xi; w))^2