Chapter 2 — Unit 1 — Machine Learning Notes for Gate Da
Chapter 2 — Unit 1 — Machine Learning notes for GATE DA: 0 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questions.
Try a question
Answer it here to see how it works. Nothing is recorded until you sign in.
Question 1
Level 4: Challenger
Consider the ridge regression objective
L(w)=(y−wx)2+λw2
with n=1, x1=1, y1=3, and λ=1. Starting from w0=1, perform one step of gradient descent with learning rate α=0.1. What is the value of w1?
Question 2
Level 4: Challenger
Consider a binary classification dataset with support vectors x+=(1,0)T with label y=+1 and x−=(−1,0)T with label y=−1. The optimal separating hyperplane for a hard-margin SVM has weight vector w=(1,1)T and bias b=0.
Find the margin width of this SVM classifier.
Question 3
Level 4: Challenger
Consider a ridge regression model with regularization parameter λ>0 fitted on a centered dataset with n observations and p predictors. The effective degrees of freedom is defined as
df(λ)=Tr(X(XTX+λIp)−1XT)
Let d1,d2,…,dp be the singular values of the design matrix X.
Which of the following expressions correctly evaluate to df(λ)?
Question 4
Level 4: Challenger
Consider a dataset with p features and covariance matrix Σ. Let λ1≥λ2≥⋯≥λp>0 be the eigenvalues of Σ. The total variance captured by the first k principal components can be expressed in multiple equivalent forms.
Which of the following expressions correctly evaluate to the total variance captured by the first k principal components?
Question 5
Level 4: Challenger
Consider the polynomial kernel K(x,y)=(xTy+1)2 defined on R2. Let ϕ(x) be the implicit feature map into a higher-dimensional space corresponding to this kernel. Given the points x=(1,1)T and y=(2,−1)T, find the squared Euclidean distance ∥ϕ(x)−ϕ(y)∥2 between their mapped representations.
Question 6
Level 4: Challenger
Consider a binary classification dataset with 6 points in R1:
x=[−3,−1,0,1,2,4],y=[−1,−1,+1,+1,+1,−1]
A linear classifier predicts +1 if wx+b>0 and −1 otherwise, where w=0. The F1 score is
Find the maximum possible F1 score over all (w,b)∈R2 with w=0.
Question 7
Level 4: Challenger
A dataset contains four points with a single feature x and binary label y:
(−3,0),(−1,1),(2,0),(4,1)
Consider decision stumps that split at threshold t∈{−2,0.5,3}, predicting y=1 if x>t and y=0 otherwise. The Gini impurity of a node with class proportions p0 and p1 is G=1−p02−p12. For a split, the overall impurity is the weighted average of the Gini impurities of the two child nodes, weighted by the number of points in each.
Find the number of thresholds t in {−2,0.5,3} for which the overall Gini impurity of the split is strictly less than $0.5$.
Question 8
Level 4: Challenger
Consider a binary classification dataset in R2 with labels y∈{+1,−1}:
A=(0,0),yA=+1
B=(2,0),yB=+1
C=(0,2),yC=+1
D=(3,0),yD=−1
E=(0,3),yE=−1
A k-nearest neighbors classifier with k=3 uses Euclidean distance. For each point, the classifier finds the 3 nearest neighbors from the remaining points and predicts the majority label among them.
Find the total number of misclassified points in this dataset.
Question 9
Level 4: Challenger
Consider a dataset with 3 points in R1: x1=−2 with label y1=+1, x2=1 with label y2=−1, and x3=3 with label y3=+1. A linear classifier predicts y^=sign(wx) where sign(z)=+1 if z>0 and −1 if z≤0.
Which of the following statements about the number of misclassified points are correct?
Question 10
Level 4: Challenger
Consider a binary classification dataset with 6 points in R1:
x=[0,1,2,3,4,5],y=[+1,−1,+1,−1,+1,−1].
A linear classifier predicts +1 if wx+b>0 and −1 otherwise, where w=0.
Find the minimum possible number of misclassified points over all (w,b)∈R2 with w=0.
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.
Chapter 2 — Unit 1 — Machine Learning Notes for GATE DA
Chapter 2 — Unit 1 — Machine Learning notes for GATE DA: 0 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questions.
Chapter 2 — Unit 1 — Machine Learning: Solved Questions with Step-by-Step Explanations (10 Problems)
Question 1 · Machine LearningMCQ
Consider the ridge regression objective
L(w)=(y−wx)2+λw2
with n=1, x1=1, y1=3, and λ=1. Starting from w0=1, perform one step of gradient descent with learning rate α=0.1. What is the value of w1?
A.
1.10
B.
1.20
C.
1.40
D.
1.60
Correct Answer:
B
Step-by-Step Solution
Key idea: This is a gradient descent update on a ridge regression objective. The gradient has two components: the data-fitting term and the regularization term. Both must be included with correct coefficients.
Step 1: Write the objective clearly.
L(w)=(y−wx)2+λw2
Step 2: Compute the gradient with respect to w.
∂w∂L=2(y−wx)(−x)+2λw=−2x(y−wx)+2λw
Step 3: Substitute the given values x=1, y=3, λ=1.
∂w∂L=−2(1)(3−w)+2(1)w=−6+2w+2w=4w−6
Step 4: Evaluate the gradient at w0=1.
∂w∂Lw=1=4(1)−6=−2
Step 5: Perform the gradient descent update.
w1=w0−α⋅∂w∂L=1−0.1(−2)=1+0.2=1.2
Answer: 1.20
Question 2 · Machine LearningMCQ
Consider a binary classification dataset with support vectors x+=(1,0)T with label y=+1 and x−=(−1,0)T with label y=−1. The optimal separating hyperplane for a hard-margin SVM has weight vector w=(1,1)T and bias b=0.
Find the margin width of this SVM classifier.
A.
rac12
B.
2
C.
22
D.
$2$
Correct Answer:
B
Step-by-Step Solution
Key idea: This is a direct application of the SVM margin formula. The margin width is the distance between the two supporting hyperplanes, which equals ∥w∥2.
Step 1: Recall the margin formula for a hard-margin SVM.
The margin width is the distance between the hyperplanes wTx+b=1 and wTx+b=−1.
Margin=∥w∥2
Step 2: Compute ∥w∥.
Given w=(1,1)T:
∥w∥=12+12=2
Step 3: Calculate the margin.
Margin=22=222=2
Step 4: Verify with support vectors.
For x+=(1,0)T: wTx++b=(1)(1)+(1)(0)+0=1 ✓
For x−=(−1,0)T: wTx−+b=(1)(−1)+(1)(0)+0=−1 ✓
Both support vectors lie on their respective supporting hyperplanes.
Answer: 2
Question 3 · Machine LearningMSQ
Consider a ridge regression model with regularization parameter λ>0 fitted on a centered dataset with n observations and p predictors. The effective degrees of freedom is defined as
df(λ)=Tr(X(XTX+λIp)−1XT)
Let d1,d2,…,dp be the singular values of the design matrix X.
Which of the following expressions correctly evaluate to df(λ)?
A.
\sum_{j=1}^p rac{d_j^2}{d_j^2 + \lambda}
B.
ext{Tr}\left( (X^T X + \lambda I_p)^{-1} X^T X ight)
C.
p - \lambda \sum_{j=1}^p rac{1}{d_j^2 + \lambda}
D.
ext{Tr}\left( (X^T X - \lambda I_p)^{-1} X^T X ight)
Correct Answer:
["A","B","C"]
Step-by-Step Solution
Key idea: This is a direct application of matrix trace properties and the spectral decomposition of XTX to simplify the effective degrees of freedom formula for ridge regression. The cyclic property of the trace and the relationship between singular values and eigenvalues allow us to rewrite the expression in multiple equivalent forms.
Step 1: Apply the cyclic property of the trace, Tr(ABC)=Tr(CAB).
Let A=X, B=(XTX+λIp)−1, and C=XT.
df(λ)=Tr(X(XTX+λIp)−1XT)=Tr((XTX+λIp)−1XTX)
This confirms Option B.
Step 2: Use the eigen-decomposition of XTX.
Since XTX is symmetric positive semi-definite, it can be decomposed as XTX=VΛVT, where V is orthogonal and Λ=diag(d12,d22,…,dp2) contains the eigenvalues (squares of the singular values of X).
The trace is invariant under orthogonal transformations, so:
Tr(V(Λ+λIp)−1ΛVT)=Tr((Λ+λIp)−1Λ)
Since (Λ+λIp)−1Λ is a diagonal matrix with entries dj2+λdj2, the trace is the sum of these diagonal entries:
df(λ)=j=1∑pdj2+λdj2
This confirms Option A.
Step 4: Algebraic manipulation.
Rewrite each term in the sum from Option A:
dj2+λdj2=dj2+λdj2+λ−λ=1−dj2+λλ
Summing over all p terms:
j=1∑p(1−dj2+λλ)=p−λj=1∑pdj2+λ1
This confirms Option C.
Step 5: Evaluate Option D.
Option D uses −λ in the inverse, which corresponds to a negative regularization parameter. This is incorrect for ridge regression and would lead to an ill-posed problem if λ>dj2.
Answer: A, B, C
Question 4 · Machine LearningMSQ
Consider a dataset with p features and covariance matrix Σ. Let λ1≥λ2≥⋯≥λp>0 be the eigenvalues of Σ. The total variance captured by the first k principal components can be expressed in multiple equivalent forms.
Which of the following expressions correctly evaluate to the total variance captured by the first k principal components?
A.
∑i=1kλi
B.
extTr(Σ)−∑i=k+1pλi
C.
rac∑i=1kλi∑i=1pλi
D.
∑i=1kλi2
Correct Answer:
["A","B"]
Step-by-Step Solution
Key idea: This is a direct application of PCA variance decomposition. The total variance in the dataset equals the trace of the covariance matrix, which equals the sum of all eigenvalues. The variance captured by the first k principal components is the sum of the first k eigenvalues.
Step 1: Recall the total variance.
The total variance in the dataset is Tr(Σ)=∑i=1pλi.
Step 2: Variance captured by first k PCs.
The i-th principal component has variance λi. Therefore, the total variance captured by the first k PCs is:
Vark=i=1∑kλi
This confirms Option A.
Step 3: Alternative form using the trace.
Since Tr(Σ)=∑i=1pλi, we can write:
i=1∑kλi=Tr(Σ)−i=k+1∑pλi
This confirms Option B.
Step 4: Evaluate Option C.
Option C gives ∑i=1pλi∑i=1kλi, which is the fraction of variance explained, not the absolute variance. This is a different quantity (always between 0 and 1).
Step 5: Evaluate Option D.
Option D gives ∑i=1kλi2, which squares each eigenvalue. This is incorrect because the variance of each PC is λi, not λi2.
Answer: A, B
Question 5 · Machine LearningNAT
Consider the polynomial kernel K(x,y)=(xTy+1)2 defined on R2. Let ϕ(x) be the implicit feature map into a higher-dimensional space corresponding to this kernel. Given the points x=(1,1)T and y=(2,−1)T, find the squared Euclidean distance ∥ϕ(x)−ϕ(y)∥2 between their mapped representations.
Correct Answer:
37.00
Step-by-Step Solution
Key idea: This is a kernel trick application. The squared distance in the feature space can be computed entirely in the input space using the kernel function, without explicitly constructing the feature map ϕ. The formula is ∥ϕ(x)−ϕ(y)∥2=K(x,x)−2K(x,y)+K(y,y).
Step 1: Compute the dot products in the input space.
xTx=12+12=2
yTy=22+(−1)2=5
xTy=(1)(2)+(1)(−1)=1
Step 2: Evaluate the kernel for each pair.
K(x,x)=(xTx+1)2=(2+1)2=9
K(y,y)=(yTy+1)2=(5+1)2=36
K(x,y)=(xTy+1)2=(1+1)2=4
Step 3: Apply the distance formula in the feature space.
∥ϕ(x)−ϕ(y)∥2=K(x,x)−2K(x,y)+K(y,y)
=9−2(4)+36=9−8+36=37
Answer: 37.00
Question 6 · Machine LearningNAT
Consider a binary classification dataset with 6 points in R1:
x=[−3,−1,0,1,2,4],y=[−1,−1,+1,+1,+1,−1]
A linear classifier predicts +1 if wx+b>0 and −1 otherwise, where w=0. The F1 score is
Find the maximum possible F1 score over all (w,b)∈R2 with w=0.
Correct Answer:
0.86
Step-by-Step Solution
Key idea: in R1, a linear classifier wx+b has a single decision boundary at t=−b/w. The sign of w decides whether we predict +1 on the right (w>0) or on the left (w<0) of t. Only the ordering of the xi matters, so there are finitely many distinct classifiers — one per gap between consecutive sorted x-values, plus the two outer rays.
Exam route:
Sort the data by x: (−3,−1),(−1,−1),(0,+1),(1,+1),(2,+1),(4,−1). There are 7 intervals for t:
(−∞,−3),(−3,−1),(−1,0),(0,1),(1,2),(2,4),(4,∞).
For each interval, try both w>0 (predict +1 to the right of t) and w<0 (predict +1 to the left of t), compute (TP,FP,FN) and hence F1.
Case w>0 (predict +1 for x>t):
t∈(−1,0): predicted +1 on {0,1,2,4}, predicted −1 on {−3,−1}.
Case w<0 (predict +1 for x<t): by symmetry the best is F1=4/7≈0.57 at t∈(1,2).
The global maximum is F1=6/7≈0.8571, achieved at any t∈(−1,0) with w>0.
Answer: 0.86
Question 7 · Machine LearningMCQ
A dataset contains four points with a single feature x and binary label y:
(−3,0),(−1,1),(2,0),(4,1)
Consider decision stumps that split at threshold t∈{−2,0.5,3}, predicting y=1 if x>t and y=0 otherwise. The Gini impurity of a node with class proportions p0 and p1 is G=1−p02−p12. For a split, the overall impurity is the weighted average of the Gini impurities of the two child nodes, weighted by the number of points in each.
Find the number of thresholds t in {−2,0.5,3} for which the overall Gini impurity of the split is strictly less than $0.5$.
A.
0
B.
1
C.
2
D.
3
Correct Answer:
C
Step-by-Step Solution
Key idea: This is a decision tree split evaluation problem. For each threshold, partition the data into left (x≤t) and right (x>t) child nodes, compute the Gini impurity of each child, then take the weighted average. Count how many splits have weighted Gini <0.5.
Step 1: Recall Gini impurity G=1−p02−p12.
Step 2: Evaluate each split.
<b>Split at t=−2:</b>
Left (x≤−2): {(−3,0)}. nL=1, p0=1, p1=0. GL=1−1−0=0.
Right (x>−2): {(−1,1),(2,0),(4,1)}. nR=3, p0=1/3, p1=2/3. GR=1−1/9−4/9=4/9.
Left (x≤0.5): {(−3,0),(−1,1)}. nL=2, p0=1/2, p1=1/2. GL=1−1/4−1/4=1/2.
Right (x>0.5): {(2,0),(4,1)}. nR=2, p0=1/2, p1=1/2. GR=1/2.
Weighted Gini: 42(21)+42(21)=21. Not <0.5. ✗
<b>Split at t=3:</b>
Left (x≤3): {(−3,0),(−1,1),(2,0)}. nL=3, p0=2/3, p1=1/3. GL=1−4/9−1/9=4/9.
Right (x>3): {(4,1)}. nR=1, p0=0, p1=1. GR=0.
Weighted Gini: 43(94)+41(0)=3612=31<0.5. ✓
Step 3: Count the splits with weighted Gini <0.5. Two splits (t=−2 and t=3) qualify.
Answer: 2
Question 8 · Machine LearningMCQ
Consider a binary classification dataset in R2 with labels y∈{+1,−1}:
A=(0,0),yA=+1
B=(2,0),yB=+1
C=(0,2),yC=+1
D=(3,0),yD=−1
E=(0,3),yE=−1
A k-nearest neighbors classifier with k=3 uses Euclidean distance. For each point, the classifier finds the 3 nearest neighbors from the remaining points and predicts the majority label among them.
Find the total number of misclassified points in this dataset.
A.
0
B.
1
C.
2
D.
3
Correct Answer:
C
Step-by-Step Solution
Key idea: This is a casework problem tracing the k-NN algorithm. For each point, compute distances to all other points, identify the k=3 nearest neighbors, and determine the majority vote. Count how many predictions disagree with the true labels.
Step 1: Process point A=(0,0), yA=+1.
Distances to other points:
To B: (2−0)2+(0−0)2=2
To C: (0−0)2+(2−0)2=2
To D: (3−0)2+(0−0)2=3
To E: (0−0)2+(3−0)2=3
3 nearest neighbors: B(+1), C(+1), D(−1) (tie broken arbitrarily, but majority is +1).
Consider a dataset with 3 points in R1: x1=−2 with label y1=+1, x2=1 with label y2=−1, and x3=3 with label y3=+1. A linear classifier predicts y^=sign(wx) where sign(z)=+1 if z>0 and −1 if z≤0.
Which of the following statements about the number of misclassified points are correct?
A.
With w=1, exactly 2 points are misclassified
B.
With w=−1, exactly 1 point is misclassified
C.
With w=1, exactly 1 point is misclassified
D.
With w=−1, exactly 2 points are misclassified
Correct Answer:
["A","B"]
Step-by-Step Solution
Key idea: This is a casework problem evaluating a linear classifier. For each value of w, compute the prediction y^=sign(wx) for each point and compare with the true label y. Count mismatches.
Total misclassified with w=−1: 1 point (x3). This confirms Option B.
Step 3: Evaluate Options C and D.
Option C claims 1 misclassified with w=1, but we found 2. Incorrect.
Option D claims 2 misclassified with w=−1, but we found 1. Incorrect.
Answer: A, B
Question 10 · Machine LearningNAT
Consider a binary classification dataset with 6 points in R1:
x=[0,1,2,3,4,5],y=[+1,−1,+1,−1,+1,−1].
A linear classifier predicts +1 if wx+b>0 and −1 otherwise, where w=0.
Find the minimum possible number of misclassified points over all (w,b)∈R2 with w=0.
Correct Answer:
2.00
Step-by-Step Solution
Key idea: the labels alternate +,−,+,−,+,− along the line, so no single threshold can separate the two classes. We must prove 0 is impossible and then find the true minimum by a threshold sweep.
Why 0 is impossible (contradiction): suppose some (w,b) classifies all 6 points correctly. The decision boundary t=−b/w splits R into two half-lines, each assigned a single label. But the sequence +,−,+,−,+,− has no contiguous block of one label that contains all +1's and excludes all −1's — whichever side of t you call '+1', it either misses a +1 or includes a −1. Contradiction. So the minimum is ≥1.
Exam route: sweep the 7 intervals for t and both signs of w. Count misclassifications directly.
Case w>0 (predict +1 for x>t):
t<0: all +1⇒ errors at x=1,3,5⇒3.
t∈(0,1): predict +1 on {1,2,3,4,5}⇒ errors at 0,1,3,5⇒4.
t∈(1,2): predict +1 on {2,3,4,5}⇒ errors at 0,3,5⇒3.
t∈(2,3): predict +1 on {3,4,5}⇒ errors at 0,2,3,5⇒4.
t∈(3,4): predict +1 on {4,5}⇒ errors at 0,2,5⇒3.
t∈(4,5): predict +1 on {5}⇒ errors at 0,2,4,5⇒4.
t>5: all −1⇒ errors at 0,2,4⇒3.
Case w<0 (predict +1 for x<t):
t<0: all −1⇒3.
t∈(0,1): predict +1 on {0}, −1 on {1,2,3,4,5}⇒ errors at 2,4⇒2.
t∈(1,2): predict +1 on {0,1}⇒ errors at 1,2,4⇒3.
t∈(2,3): predict +1 on {0,1,2}⇒ errors at 1,4⇒2.
t∈(3,4): predict +1 on {0,1,2,3}⇒ errors at 1,3,4⇒3.
t∈(4,5): predict +1 on {0,1,2,3,4}⇒ errors at 1,3⇒2.
t>5: all +1⇒3.
The global minimum is $2$, achieved (for example) at t∈(0,1) with w<0.