Linear Regression Introduction
- 42Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
What is supervised learning?
A learning problem where you are given input-output pairs (X, Y) and the algorithm learns a mapping from X to Y.
Or swipe the card
42 cards
What is supervised learning?
A learning problem where you are given input-output pairs (X, Y) and the algorithm learns a mapping from X to Y.
What is the difference between a regression problem and a classification problem?
Regression predicts a continuous-valued output (e.g., price). Classification predicts a discrete output (e.g., speed category).
In the ALVINN self-driving car example, what type of supervised learning problem was it?
It was a regression problem, because the output Y (steering direction) is a continuous value.
What is the hypothesis in the context of supervised learning?
The hypothesis h is a function that maps input features X to an estimated output Y, output by the learning algorithm.
What is a training example in supervised learning?
A training example is a pair (x, y) where x is the input features and y is the target value.
In linear regression with one input feature, what is the form of the hypothesis?
h(x)=θ0+θ1x
How is the hypothesis written for multiple features?
h(x)=θ0+θ1x1+θ2x2+⋯+θnxn
What is the purpose of introducing x0=1?
To write the hypothesis compactly as h(x)=∑j=0nθjxj.
Define the parameters Θ in linear regression.
The parameters Θ are the coefficients θ0,θ1,…,θn that define the hypothesis.
What do M, n, and the superscript (i) denote in notation?
M is the number of training examples. n is the number of features. The superscript (i) indexes the i-th training example (e.g., x(i)).
What is a feature in the context of linear regression?
A feature is an input attribute used to predict the output; e.g., size of house or number of bedrooms.
Write the hypothesis in vector form for multiple features.
h(x)=θTx where θ and x are (n+1)-dimensional vectors (including x0=1).
What is the design matrix X in linear regression?
The design matrix X has rows corresponding to training examples: each row is (x(i))T, an (n+1)-dimensional vector. It is of size m×(n+1).
What is the cost function J(θ) for linear regression (ordinary least squares)?
J(θ)=2m1∑i=1m(h(x(i))−y(i))2
Why is the 1/2 term included in the cost function?
To simplify the derivative calculation; the 1/2 cancels the factor 2 that appears when differentiating the square.
What is the goal of the cost function in linear regression?
To choose parameters θ that minimize J(θ), making predictions close to the actual values.
Why is squared error often used instead of absolute error?
The lecture mentions that a probabilistic justification (Gaussian noise assumption) underlies squared error, which will be covered later (GLMs).
What is gradient descent?
An iterative optimization algorithm that updates parameters in the direction of the negative gradient to minimize a cost function.
Write the gradient descent update rule for a single parameter θj in linear regression.
θj:=θj−α∂θj∂J(θ)
What is the gradient descent update for linear regression using all training examples (batch)?
θj:=θj−αm1∑i=1m(h(x(i))−y(i))xj(i)
What is the role of the learning rate α in gradient descent?
It controls the step size: too large may overshoot the minimum, too small slows convergence.
Why does gradient descent for linear regression not suffer from local minima?
Because the cost function J(θ) for linear regression is convex (a quadratic bowl shape), so any local minimum is global.
What is batch gradient descent?
A version of gradient descent that uses the entire training set to compute the gradient at each iteration.
What is a disadvantage of batch gradient descent?
It is computationally expensive for large datasets because each update requires scanning all m examples.
What is stochastic gradient descent (SGD)?
An iterative algorithm that updates parameters using one training example at a time, looping through examples randomly.
Write the SGD update rule for linear regression.
For each training example i: θj:=θj−α(h(x(i))−y(i))xj(i) for all j.
How does the convergence behavior of SGD differ from batch gradient descent?
SGD is noisy and oscillates; it never exactly converges but typically reaches a good solution faster for large datasets.
When is stochastic gradient descent preferred over batch gradient descent?
When the dataset is very large (e.g., millions of examples) because SGD makes faster progress per iteration.
How can the performance of SGD be improved?
By gradually decreasing the learning rate over time, which reduces oscillations and helps converge closer to the minimum.
What is mini-batch gradient descent?
A compromise between batch and stochastic: uses a small batch of training examples (e.g., 100) per update instead of 1 or all.
What is the normal equation?
A closed-form solution for θ that minimizes J(θ): θ=(XTX)−1XTy.
Write the normal equation.
θ=(XTX)−1XTy
What does the normal equation achieve?
It finds the global minimum of the cost function J(θ) in one step, without iterative updates.
What is the vector y in the normal equation?
An m-dimensional column vector containing all target values y(i) from the training set.
When might XTX be non-invertible, and what is the remedy?
Non-invertibility occurs when features are linearly dependent (redundant). The pseudo-inverse can be used, but it's better to identify and remove redundant features.
What is an advantage of the normal equation over gradient descent?
It does not require choosing a learning rate or iterating; it directly gives the optimal θ.
State the trace of a matrix A.
tr(A)=∑iAii (sum of diagonal entries).
What is the derivative of tr(AB) with respect to A?
∂A∂tr(AB)=BT
State the cyclic property of trace: tr(ABC)=?
tr(ABC)=tr(CAB)=tr(BCA)
How is the cost function J(θ) expressed in matrix form?
J(θ)=21(Xθ−y)T(Xθ−y)
What is the derivative of J(θ)=21(Xθ−y)T(Xθ−y) with respect to θ?
∂θ∂J=XTXθ−XTy
Derive the normal equation from setting the derivative to zero.
Set XTXθ−XTy=0, then XTXθ=XTy, so θ=(XTX)−1XTy.

Ask anything
We've read this whole study set, so questions about it get the best answers.