Regression, Regularization and Gradient-based Learning Notes for Gate Da
Regression, Regularization and Gradient-based Learning notes for GATE DA: 48 study cards covering concepts, formulas, shortcuts and exam traps, plus solved pr
Regression Regularization and Gradient Based Learning notes
Chapter Roadmap: Regression, Regularization and Gradient-Based Learning
Chapter Journey
1. Linear Least-Squares Regression
The foundation. Minimizing the sum of squared residuals to find the best-fit line. Closed-form solution and its geometric interpretation.
2. Ridge Regression and Regularization
The problem with OLS: overfitting and ill-conditioned matrices. Introducing the L2 penalty to shrink weights. The bias-variance tradeoff.
3. Gradient-Based Parameter Updates
Moving beyond closed-form solutions. Batch, Stochastic, and Mini-batch Gradient Descent. Learning rates and convergence.
By the end of this chapter, you will be able to analytically solve linear models, regularize them to prevent overfitting, and optimize them iteratively.
The Core Idea of Ridge Regression
The Intuition Behind Regularization
Ordinary Least Squares (OLS) finds weights that minimize the training error. However, when data is noisy or features are highly correlated, OLS assigns excessively large weights to fit the noise. This leads to overfitting.
Ridge Regression modifies the objective by adding a penalty term proportional to the square of the magnitude of the weights.
Goal: Minimize training error while keeping the weights as small as possible.
Effect: Shrinks the coefficients towards zero, reducing model complexity and variance.
Result: A model that generalizes much better to unseen data, even if it slightly underfits the training data.
Why Ridge Solves the Singular Matrix Problem
The Algebraic Rescue
In OLS, we need to invert XTX. If n<d or if features are highly collinear, XTX is singular or ill-conditioned.
The Eigenvalue Shift
Let the eigenvalues of XTX be σ12,σ22,…,σd2. The eigenvalues of (XTX+λI) are simply (σ12+λ),…,(σd2+λ).
Since λ>0, every eigenvalue is strictly greater than zero.
The matrix (XTX+λI) is guaranteed to be strictly positive definite.
It is always invertible, providing a unique, stable solution.
45 more cards in this chapter
Try a question
Answer it here to see how it works. Nothing is recorded until you sign in.
Question 1
Level 1: Warm-up
Match the following matrix expressions with their roles in the Ridge Regression closed-form solution w=(XTX+λI)−1XTy:
<b>List I</b>
P. XTX+λI
Q. XTy
R. (XTX+λI)−1
<b>List II</b>
Regularized Gram matrix inverse
Regularized Gram matrix
Cross-covariance vector
Choose the correct matching:
Question 2
Level 1: Warm-up
Match the mathematical operation in the Ridge Regression closed-form solution with its corresponding descriptive step.
List I
(I) XTX
(II) XTX+λI
(III) XTy
(IV) (XTX+λI)−1XTy
List II
(P) Compute the regularized Gram matrix
(Q) Compute the final weight vector w
(R) Compute the unregularized Gram matrix
(S) Compute the cross-covariance vector
Question 3
Level 1: Warm-up
Match the following intermediate values in the Ridge Regression calculation for fitting y=wx (no bias) to the points (1,2) and (2,4) with λ=2:
<b>List I</b>
P. XTX
Q. XTX+λ
R. XTy
<b>List II</b>
$10$
$5$
$7$
Choose the correct matching:
Question 4
Level 1: Warm-up
Observe the gradient of the Ridge cost function: ∇wJ(w)=−2XTy+2XTXw+2λw. Which of the following correctly match the terms with their properties when setting the gradient to zero?
Question 5
Level 1: Warm-up
In the derivation of the Ridge Regression closed-form solution for a 1D model without bias, the gradient of the objective function is set to zero. If XTy=6, XTX=2, and λ=1, what is the optimal weight w?
Question 6
Level 1: Warm-up
Which of the following statements is true regarding feature scaling in Ridge Regression?
Question 7
Level 1: Warm-up
Which of the following statements is true regarding the application of the L2 penalty in Ridge Regression?
Question 8
Level 1: Warm-up
Which of the following statements correctly describes how the L2 penalty bounds the weights when features are not standardized?
Question 9
Level 1: Warm-up
A Ridge Regression model is trained on a dataset with 12 features. Assuming λ>0 and the design matrix X has full column rank, how many features will have weights exactly equal to zero in the trained model?
Question 10
Level 1: Warm-up
A student states that adding λI to XTX makes all eigenvalues strictly greater than λ. Given XTX has eigenvalues 0,2,4, and λ=1, how many of the new eigenvalues actually contradict this student's statement?
Free preview ends here
Login to view the complete notes
Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.
Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.
Built around you, not around a syllabus PDF
Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.
Revision that hits your weak spots
We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.
Questions calibrated to the real exam
Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.
Notes written for recall, not for volume
Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.
One place for everything
Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.
Honest progress
No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.
Unlock the whole course
Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.
Regression, Regularization and Gradient-based Learning Notes for GATE DA
Regression, Regularization and Gradient-based Learning notes for GATE DA: 48 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questions.
Chapter Roadmap: Regression, Regularization and Gradient-Based Learning
Chapter Journey
1. Linear Least-Squares Regression
The foundation. Minimizing the sum of squared residuals to find the best-fit line. Closed-form solution and its geometric interpretation.
2. Ridge Regression and Regularization
The problem with OLS: overfitting and ill-conditioned matrices. Introducing the L2 penalty to shrink weights. The bias-variance tradeoff.
3. Gradient-Based Parameter Updates
Moving beyond closed-form solutions. Batch, Stochastic, and Mini-batch Gradient Descent. Learning rates and convergence.
By the end of this chapter, you will be able to analytically solve linear models, regularize them to prevent overfitting, and optimize them iteratively.
The Core Idea of Ridge Regression
The Intuition Behind Regularization
Ordinary Least Squares (OLS) finds weights that minimize the training error. However, when data is noisy or features are highly correlated, OLS assigns excessively large weights to fit the noise. This leads to overfitting.
Ridge Regression modifies the objective by adding a penalty term proportional to the square of the magnitude of the weights.
Goal: Minimize training error while keeping the weights as small as possible.
Effect: Shrinks the coefficients towards zero, reducing model complexity and variance.
Result: A model that generalizes much better to unseen data, even if it slightly underfits the training data.
Why Ridge Solves the Singular Matrix Problem
The Algebraic Rescue
In OLS, we need to invert XTX. If n<d or if features are highly collinear, XTX is singular or ill-conditioned.
The Eigenvalue Shift
Let the eigenvalues of XTX be σ12,σ22,…,σd2. The eigenvalues of (XTX+λI) are simply (σ12+λ),…,(σd2+λ).
Since λ>0, every eigenvalue is strictly greater than zero.
The matrix (XTX+λI) is guaranteed to be strictly positive definite.
It is always invertible, providing a unique, stable solution.
The Bias-Variance Tradeoff in Ridge
Tuning the Regularization Strength
The hyperparameter λ directly controls the model's complexity.
λ=0: Reduces to OLS. Low bias, but high variance (overfitting).
λ→∞: Forces all weights to zero. High bias, but low variance (underfitting).
The total expected test error is the sum of Bias2, Variance, and irreducible noise. This creates a U-shaped curve. The optimal λ is found at the minimum of this curve, typically selected via cross-validation.
Regression, Regularization and Gradient-based Learning: Solved Questions with Step-by-Step Explanations (10 Problems)
Question 1 · Machine LearningMCQ
Match the following matrix expressions with their roles in the Ridge Regression closed-form solution w=(XTX+λI)−1XTy:
<b>List I</b>
P. XTX+λI
Q. XTy
R. (XTX+λI)−1
<b>List II</b>
Regularized Gram matrix inverse
Regularized Gram matrix
Cross-covariance vector
Choose the correct matching:
A.
P-2, Q-3, R-1
B.
P-1, Q-3, R-2
C.
P-2, Q-1, R-3
D.
P-3, Q-2, R-1
Correct Answer:
A
Step-by-Step Solution
Key idea: This is a matching question identifying the components of the Ridge closed-form solution.
Step 1: XTX is the Gram matrix. Adding λI makes it the regularized Gram matrix. So P matches 2.
Step 2: XTy represents the dot products of features with the target, which is the cross-covariance vector. So Q matches 3.
Step 3: The inverse of the regularized Gram matrix is (XTX+λI)−1. So R matches 1.
Answer: P-2, Q-3, R-1
Question 2 · Machine LearningMCQ
Match the mathematical operation in the Ridge Regression closed-form solution with its corresponding descriptive step.
List I
(I) XTX
(II) XTX+λI
(III) XTy
(IV) (XTX+λI)−1XTy
List II
(P) Compute the regularized Gram matrix
(Q) Compute the final weight vector w
(R) Compute the unregularized Gram matrix
(S) Compute the cross-covariance vector
A.
(I)-R, (II)-P, (III)-S, (IV)-Q
B.
(I)-P, (II)-R, (III)-Q, (IV)-S
C.
(I)-R, (II)-S, (III)-P, (IV)-Q
D.
(I)-S, (II)-P, (III)-R, (IV)-Q
Correct Answer:
A
Step-by-Step Solution
Key idea: This is a direct matching question testing the standard sequence of matrix operations for the Ridge closed-form solution.
Step 1: XTX is the standard Gram matrix (unregularized). Matches (R).
Step 2: XTX+λI is the Gram matrix with the Ridge penalty added (regularized). Matches (P).
Step 3: XTy represents the dot product of features and targets, often called the cross-covariance vector. Matches (S).
Step 4: (XTX+λI)−1XTy is the final formula for the weight vector w. Matches (Q).
Step 5: The correct sequence is (I)-R, (II)-P, (III)-S, (IV)-Q.
Answer: (I)-R, (II)-P, (III)-S, (IV)-Q
Question 3 · Machine LearningMCQ
Match the following intermediate values in the Ridge Regression calculation for fitting y=wx (no bias) to the points (1,2) and (2,4) with λ=2:
<b>List I</b>
P. XTX
Q. XTX+λ
R. XTy
<b>List II</b>
$10$
$5$
$7$
Choose the correct matching:
A.
P-2, Q-3, R-1
B.
P-1, Q-3, R-2
C.
P-2, Q-1, R-3
D.
P-3, Q-2, R-1
Correct Answer:
A
Step-by-Step Solution
Key idea: This is a matching question testing the step-by-step numerical calculation of Ridge Regression.
Step 1: Construct X and y. X=[1,2]T, y=[2,4]T.
Step 2: Calculate XTX=12+22=1+4=5. So P matches 2.
Step 3: Calculate XTX+λ=5+2=7. So Q matches 3.
Step 4: Calculate XTy=1(2)+2(4)=2+8=10. So R matches 1.
Answer: P-2, Q-3, R-1
Question 4 · Machine LearningMSQ
Observe the gradient of the Ridge cost function: ∇wJ(w)=−2XTy+2XTXw+2λw. Which of the following correctly match the terms with their properties when setting the gradient to zero?
A.
The term −2XTy matches with the data-dependent component that pulls weights towards the data.
B.
The term 2XTXw matches with a positive sign arising from the expansion of the squared error.
C.
The term 2λw matches with a negative sign to counteract the data fit.
D.
Setting the gradient to zero matches with the normal equation (XTX+λI)w=XTy.
Correct Answer:
["A","B","D"]
Step-by-Step Solution
Key idea: This is an observation question testing the algebraic derivation and sign precision of the Ridge gradient.
Step 1: Evaluate the term −2XTy. This term comes from the derivative of the cross-product −2wTXTy in the squared error expansion. It depends directly on the target vector y and pulls the weights towards fitting the data. Statement A is true.
Step 2: Evaluate the term 2XTXw. This term comes from the derivative of the quadratic form wTXTXw. The derivative of a quadratic form wTAw is 2Aw (for symmetric A), yielding a positive sign. Statement B is true.
Step 3: Evaluate the term 2λw. This term comes from the derivative of the penalty λ∣∣w∣∣22. The derivative is 2λw, which has a positive sign, not a negative one. Statement C is false.
Step 4: Evaluate the normal equation. Setting ∇wJ(w)=0 gives −2XTy+2XTXw+2λw=0. Dividing by 2 and rearranging yields (XTX+λI)w=XTy. Statement D is true.
Answer: A, B, D
Question 5 · Machine LearningNAT
In the derivation of the Ridge Regression closed-form solution for a 1D model without bias, the gradient of the objective function is set to zero. If XTy=6, XTX=2, and λ=1, what is the optimal weight w?
Correct Answer:
2.00
Step-by-Step Solution
Key idea: This is a direct substitution question using the normal equation for Ridge Regression.
Step 1: The normal equation for 1D Ridge is (XTX+λ)w=XTy.
Step 2: Substitute the given values: (2+1)w=6.
Step 3: Solve for w: 3w=6⟹w=2.
Answer: 2.00
Question 6 · Machine LearningMCQ
Which of the following statements is true regarding feature scaling in Ridge Regression?
A.
It is optional if the features are already positive.
B.
It ensures the L2 penalty treats all weights equally.
C.
It changes the optimal unregularized OLS weights.
D.
It is only required when λ=0.
Correct Answer:
B
Step-by-Step Solution
Key idea: This is a statement truth question testing the necessity of feature scaling for the L2 penalty.
Step 1: The L2 penalty is λ∑wj2. It penalizes all weights equally based on their magnitude.
Step 2: If features have different scales, their weights will naturally have different magnitudes just to compensate for the scale.
Step 3: Without scaling, the penalty unfairly shrinks the weights of larger-scale features.
Step 4: Standardizing features ensures the penalty treats all weights on a comparable scale.
Answer: It ensures the L2 penalty treats all weights equally.
Question 7 · Machine LearningMCQ
Which of the following statements is true regarding the application of the L2 penalty in Ridge Regression?
A.
The penalty term treats all weights equally, regardless of the original scale of the features.
B.
Features must be standardized to prevent the penalty from unfairly shrinking the weights of larger-scale features.
C.
The L2 penalty automatically scales the features during the optimization process to ensure fairness.
D.
The penalty is applied only to features that exhibit negative correlations with the target variable.
Correct Answer:
B
Step-by-Step Solution
Key idea: This is a fundamental property of regularization; the L2 penalty is sensitive to the magnitude of the weights, which in turn depends on the scale of the features.
Step 1: The Ridge penalty term is λ∑wj2. It penalizes large weights.
Step 2: If a feature has a large scale (e.g., ranges from 0 to 1000), its corresponding weight wj will naturally be small to compensate. Conversely, a feature with a small scale (e.g., 0 to 1) will have a large weight.
Step 3: Without scaling, the penalty would unfairly shrink the weight of the small-scale feature much more than the large-scale feature.
Step 4: Therefore, features must be standardized (zero mean, unit variance) before applying Ridge Regression so that all weights are on a comparable scale and penalized fairly.
Answer: Features must be standardized...
Question 8 · Machine LearningMCQ
Which of the following statements correctly describes how the L2 penalty bounds the weights when features are not standardized?
A.
It bounds the weights of larger-scale features more tightly.
B.
It bounds the weights of smaller-scale features more tightly.
C.
It bounds all weights by the same absolute margin regardless of scale.
D.
It bounds the sum of the features rather than the weights.
Correct Answer:
B
Step-by-Step Solution
Key idea: This is a statement truth question about the bounding effect of the L2 penalty on unscaled features.
Step 1: The L2 penalty is λ∑wj2. It penalizes large weights.
Step 2: If a feature has a large numerical range, its corresponding weight wj will naturally be very small to compensate for the large input values.
Step 3: Because wj is small, wj2 is extremely small, meaning the penalty has very little effect on it.
Step 4: Conversely, features with a small numerical range will have larger weights, which are penalized much more heavily.
Step 5: Therefore, the penalty bounds the weights of smaller-scale features more tightly.
Answer: It bounds the weights of smaller-scale features more tightly.
Question 9 · Machine LearningNAT
A Ridge Regression model is trained on a dataset with 12 features. Assuming λ>0 and the design matrix X has full column rank, how many features will have weights exactly equal to zero in the trained model?
Correct Answer:
0
Step-by-Step Solution
Key idea: Ridge Regression does not produce sparse solutions; weights are shrunk but never exactly zero.
Step 1: Recall the sparsity property of Ridge Regression from the cheat sheet: "Sparsity: No (weights ≠ 0)".
Step 2: Unlike Lasso (L1 regularization), Ridge (L2 regularization) shrinks weights toward zero but does not set them exactly to zero.
Step 3: Therefore, with λ>0 and full column rank, all 12 features will have non-zero weights.
Answer: 0
Question 10 · Machine LearningMCQ
A student states that adding λI to XTX makes all eigenvalues strictly greater than λ. Given XTX has eigenvalues 0,2,4, and λ=1, how many of the new eigenvalues actually contradict this student's statement?
A.
0
B.
1
C.
2
D.
3
Correct Answer:
B
Step-by-Step Solution
Key idea: This is a contradiction question testing the exact eigenvalue shift property of Ridge Regression.
Step 1: The original eigenvalues of XTX are μi∈{0,2,4}.
Step 2: The new eigenvalues of XTX+λI are μi+λ. For λ=1, they are 1,3,5.
Step 3: The student's statement: all new eigenvalues are strictly greater than λ (i.e., >1).
Step 4: Check the new eigenvalues: 1 is not >1 (it is equal to 1). 3 and 5 are >1.
Step 5: Only the eigenvalue 1 contradicts the statement. Count = 1.