Docsity

Expectation - Introduction to Artificial Intelligence - Lecture Slides, Slides of Artificial Intelligence

Partial preview of the text

Download Expectation - Introduction to Artificial Intelligence - Lecture Slides and more Slides Artificial Intelligence in PDF only on Docsity!

CSE 151 Machine Learning

Expectation

For a discrete random variable X, the expectation is defined as: E[X] = ￿ x xfX (x) For a continuous random variable X, the expectation is defined as: E[X] = ￿ ∞ −∞ xfX (x)dx Let Y = r(X). Then E[Y] can be computed as: E[Y ] = ￿ ∞ −∞ r(x)fX (x)dx E[Y ] = ￿ x r(x)fX (x) continuous discrete

Independence of random

variables, Covariance

Random variables X and Y are independent if for any two sets A and B, P (X ∈ A, Y ∈ B) = P (X ∈ A)P (Y ∈ B) For two random variables X,Y, cov(X,Y) = E( (X - E[X]) (Y - E[Y]) ) cov(X,Y) can also be written as: cov(X,Y) = E(XY) - E(X) E(Y) Property: If X and Y are independent, then Var(X + Y) = Var(X) + Var(Y) Cov(X,Y) = 0 Does the converse hold? Docsity.com

Announcements

Homework 1 due on Wed Apr 18

Midterm 1 is on Mon Apr 23

Material for midterm:

Linear algebra review, probability review

k-nearest neighbors

Typical Classification Algorithm

Set of input examples (xi, yi) Classification Algorithm Prediction Rule New example x Label y

Typical Classification Algorithm

Set of input examples (xi, yi) Classification Algorithm Prediction Rule New example x Label y Training Data Test Data Training and test data must be separate!

Classification

where y is discrete , predict y values for unseen x Example 1: Which digit in the image? Label: 0,1,.., What are the features? Vector of pixel colors 0 0 1 0 1 0 1 ... Image x (0 for white, 1 for black) Given labeled data (xi, yi), i=1,..,n,

Performance Measures

Training error: For a classifier f, given training data (x 1 ,y 1 ),..(xm, ym) 1 m m ￿ j= Training error =^1 [f^ (xj )^ ￿=^ yj ]

Performance Measures

Training error: For a classifier f, given training data (x 1 ,y 1 ),..(xm, ym) 1 m m ￿ j= Training error =^1 [f^ (xj )^ ￿=^ yj ] For a classifier f, given test data (x 1 ,y 1 ),..(xm, ym) 1 m m ￿ j= Test error =^1 [f^ (xj )^ ￿=^ yj ] Test error: Both are proxy for the true error of the classifier: True error = where data (both training and test) are drawn from an underlying distribution D E(X,Y )∼D [1[f (X) ￿= Y ]]

Performance Measures

Usually, training error is less than test error. Test error is a better measure than training error. Training error: For a classifier f, given training data (x 1 ,y 1 ),..(xm, ym) 1 m m ￿ j= Training error =^1 [f^ (xj )^ ￿=^ yj ] For a classifier f, given test data (x 1 ,y 1 ),..(xm, ym) 1 m m ￿ j= Test error =^1 [f^ (xj )^ ￿=^ yj ] Test error:

The Nearest Neighbor Classifier

Labelled examples (x 1 , y 1 ), .., (xn, yn), Predict label of a new example x Given: Solution: Return yj j = argmini d(x, xi) d is the distance

Example 1

x=-1 (^) x=0 x= Training Data x=4 x= What does the classifier look like?

The Nearest Neighbor Classifier

Assign to a test example the same label as its closest training example Red: training points Blue cell: region with same label as the training example in it Voronoi diagram

Example 2

Training Data: ( (1, 1), 1 ) ( (-1, -1), 1 ) ( (1, -1), 2 ) ( (-1, 1), 2 )