Docsity

Linear Regression With Multiple Variables-Machine Learning and Artificial Intelligence-Lecture Slides, Slides of Machine Learning

Partial preview of the text

Download Linear Regression With Multiple Variables-Machine Learning and Artificial Intelligence-Lecture Slides and more Slides Machine Learning in PDF only on Docsity!

Linear Regression with

multiple variables

Multiple features

Machine Learning

Andrew Ng

Size (feet^2 ) Price ($1000)

Multiple features (variables).

Andrew Ng

Hypothesis:

Previously:

Andrew Ng

For convenience of notation, define.

Multivariate linear regression.

Linear Regression with multiple variables

Gradient descent for multiple variables

Machine Learning

Andrew Ng

Hypothesis:

Cost function:

Parameters:

(simultaneously update for every )

Repeat

Gradient descent:

Linear Regression with multiple variables

Gradient descent in practice I: Feature Scaling

Machine Learning

Andrew Ng

Feature Scaling

Get every feature into approximately a range.

Andrew Ng

Replace with to make features have approximately zero mean (Do not apply to ).

Mean normalization

E.g.

Linear Regression with multiple variables

Gradient descent in practice II: Learning rate

Machine Learning

Andrew Ng

Gradient descent

  • “Debugging”: How to make sure gradient descent is working correctly.
  • How to choose learning rate.

Andrew Ng

Making sure gradient descent is working correctly.

Gradient descent not working. Use smaller.

No. of iterations

No. of iterations No. of iterations

  • For sufficiently small , should decrease on every iteration.
  • But if is too small, gradient descent can be slow to converge.

Andrew Ng

Summary:

  • If is too small: slow convergence.
  • If is too large: may not decrease on every iteration; may not converge.

To choose , try