Skip to content
Stanford CS229: Machine Learning - Linear Regression and Gradient Descent |  Lecture 2 (Autumn 2018)
This video isn’t embeddableWatch on YouTube →
Stanford OnlineStanford Online

Stanford CS229: Machine Learning - Linear Regression and Gradient Descent | Lecture 2 (Autumn 2018)

For more information about Stanford’s Artificial Intelligence professional and graduate programs, visit: https://stanford.io/ai This lecture covers supervised learning and linear regression. Andrew Ng Adjunct Professor of Computer Science https://www.andrewng.org/ To follow along with the course schedule and syllabus, visit: http://cs229.stanford.edu/syllabus-autumn2018.html #andrewng #machinelearning Chapters: 00:00 Intro 00:45 Motivate Linear Regression 03:01 Supervised Learning 04:44 Designing a Learning Algorithm 08:27 Parameters of the learning algorithm 14:44 Linear Regression Algorithm 18:06 Gradient Descent 33:01 Gradient Descent Algorithm 42:34 Batch Gradient Descent 44:56 Stochastic Gradient Descent

Andrew Nghost
Apr 17, 20201h 18mWatch on YouTube ↗

Summaries, chapters, transcripts, and FAQs on this page are made by uListen, not YouTube.

At a glance

WHAT IT’S REALLY ABOUT

Linear Regression, Gradient Descent Variants, and the Normal Equation Explained by Ng

  1. Ng motivates linear regression with a Portland housing price dataset, defining the hypothesis, parameters theta, training examples, and the notation used throughout the quarter.
  2. The learning goal is to minimize a least-squares cost function J of theta, which Ng optimizes with gradient descent by repeatedly stepping opposite the partial derivatives scaled by a learning rate.
  3. Ng contrasts batch gradient descent, which scans the whole dataset per step, with stochastic gradient descent, which updates on one example at a time, oscillates without converging, but is much faster on large datasets.
  4. For linear regression specifically, Ng derives the normal equation using matrix derivatives and the trace operator, giving the optimal theta in one step as (XᵀX)⁻¹Xᵀy.
  5. Throughout, Ng answers student questions on choosing the learning rate, why the gradient is subtracted, when to stop SGD, and what to do when XᵀX is non-invertible.

IDEAS WORTH REMEMBERING

5 ideas

Learning algorithm design rests on a few key choices.

Ng says the workflow, the dataset, and how to represent the hypothesis are decisions made in nearly every supervised learning algorithm, which is why he spends time on the concepts and notation.

Linear regression minimizes half the sum of squared errors.

The cost J of theta sums squared differences between predictions and true prices over all training examples, with a one-half added to simplify derivatives; Ng defers the justification of squared error to next week's generalized linear models.

Linear regression's cost surface has no bad local optima.

Because J of theta is a sum of squares, it is a quadratic bowl whose only local optimum is the global one, so gradient descent will eventually converge to the global minimum.

The learning rate must be tuned empirically.

Too large a rate overshoots and can make the cost increase, while too small makes training slow; Ng tries values on a roughly doubling scale, often starting near 0.01 with scaled features.

Stochastic gradient descent trades exactness for speed on big data.

It takes noisy steps from single examples and never fully converges, but it makes much faster progress and gives good parameters; Ng notes decreasing the learning rate over time shrinks the oscillations.

WORDS WORTH SAVING

4 quotes

If you have the right notation, you can solve some problems much more easily.

— Andrew Ng

gradient descent and linear regression is definitely still one of the most widely used learning algorithms in the world today.

— Andrew Ng

we just make up names of stuff, and sometimes the names aren't great.

— Andrew Ng

I would almost always just use Batch Gradient Descent because it's one less thing to fiddle with

— Andrew Ng

Supervised learning and regressionHypothesis and notationLeast-squares cost functionGradient descent algorithmLearning rate selectionBatch vs. stochastic gradient descentNormal equation and matrix derivatives

High quality AI-generated summary created from speaker-labeled transcript.

Get more out of YouTube videos.

Read along on your phone, search it beside the video, or ask your favorite AI app what was said.