Вы находитесь на странице: 1из 49

# Linear

## regression with one variable

Model representa6on
Machine Learning

Andrew Ng

## Price 200 (in 1000s 100 of dollars) 0

0 500 1000 1500 2000 2500 3000

## Size (feet2) Supervised Learning

Regression Problem

Andrew Ng

## Price (\$) in 1000's (y) 460 232 315 178

Nota6on: m = Number of training examples xs = input variable / features ys = output variable / target variable

Andrew Ng

Training Set

How do we represent h ?

## Learning Algorithm Size of house Es6mated price

Linear regression with one variable. Univariate linear regression.

Andrew Ng

Cost func6on
Machine Learning

Andrew Ng

Training Set

Andrew Ng

3 2 1 0 0 1 2 3

3 2 1 0 0 1 2 3

3 2 1 0 0 1 2 3

Andrew Ng

Andrew Ng

Machine Learning

Andrew Ng

Simplied

Goal:

Andrew Ng

2 1 0 0 1

Andrew Ng

2 1 0 0 1

Andrew Ng

2 1 0 0 1

Andrew Ng

Machine Learning

Andrew Ng

Andrew Ng

500 400

## Price (\$) 300 in 1000s

200 100 0 0 1000 2000 3000

Andrew Ng

Andrew Ng

Andrew Ng

Andrew Ng

Andrew Ng

Andrew Ng

## Linear regression with one variable

Machine Learning

Andrew Ng

Have some func6on Want Outline: Start with some Keep changing to reduce un6l we hopefully end up at a minimum

Andrew Ng

J(0,1)

1
0

Andrew Ng

J(0,1)

1
0

Andrew Ng

Incorrect:

Andrew Ng

Machine Learning

Andrew Ng

Andrew Ng

Andrew Ng

## If is too small, gradient descent can be slow.

If is too large, gradient descent can overshoot the minimum. It may fail to converge, or even diverge.

Andrew Ng

## at local op6ma Current value of

Andrew Ng

Gradient descent can converge to a local minimum, even with the learning rate xed.

As we approach a local minimum, gradient descent will automa6cally take smaller steps. So, no need to decrease over 6me.

Andrew Ng

Machine Learning

Andrew Ng

## Linear Regression Model

Andrew Ng

Andrew Ng

update and simultaneously

Andrew Ng

J(0,1)

1
0

Andrew Ng

J(0,1)

1
0

Andrew Ng

Andrew Ng

Andrew Ng

Andrew Ng

Andrew Ng

Andrew Ng

Andrew Ng

Andrew Ng

Andrew Ng

Andrew Ng

Andrew Ng