Machine Learning GATE Practice Set

Mixed GATE DA style questions on regression, classification, k-NN, naive Bayes, SVM, decision trees, evaluation, neural networks, clustering and PCA, with answers and explanations.

These questions mix every topic in this track, in the three GATE formats: MCQ (one correct option), MSQ (one or more correct options) and NAT (type a number). Each answer is recomputed by a program when the site is built. Try each question before opening the explanation.

Regression

GATE-styleNAT · numerical answer

[Linear regression] A least-squares line ŷ = w₀ + w₁x is fitted to data with x̄ = 5, ȳ = 20, Sxy = 60 and Sxx = 15. What is the predicted value at x = 8?

Show answer and explanationAnswer: 32

w₁ = 60/15 = 4 and w₀ = 20 − 4 × 5 = 0, so ŷ(8) = 0 + 4 × 8 = 32.

GATE-styleNAT · numerical answer

[Ridge regression] For one centred feature with Sxy = 30 and Sxx = 10, which value of λ makes the ridge slope exactly half of the least-squares slope?

Show answer and explanationAnswer: 10

The least-squares slope is 30/10 = 3. Ridge gives 30/(10 + λ) = 1.5 when 10 + λ = 20, so λ = 10.

GATE-styleNAT · numerical answer

[R²] For a simple linear regression, the correlation between x and y is r = −0.8. What is R²?

Show answer and explanationAnswer: 0.64

For simple linear regression, R² = r² = 0.64. The sign of r only gives the direction of the slope.

Classification

GATE-styleNAT · numerical answer

[Logistic regression] A logistic regression model gives log-odds z = −2 + 0.5x₁ + x₂. What is P(y = 1) for x₁ = 2, x₂ = 1? Give the answer to three decimal places.

Show answer and explanationAnswer: 0.5

z = −2 + 1 + 1 = 0, and σ(0) = 0.5. The point lies on the decision boundary.

GATE-styleMCQ · one correct answer

[k-NN] Training points: (0, 0) class P, (1, 0) class P, (0, 1) class Q, (2, 1) class Q, (3, 1) class Q. Using 3-NN with Manhattan distance, what is the predicted class for (1, 1)?

Show answer and explanationAnswer: B

Manhattan distances from (1, 1): (0, 0) → 2, (1, 0) → 1, (0, 1) → 1, (2, 1) → 1, (3, 1) → 2. The three nearest are (1, 0) P, (0, 1) Q and (2, 1) Q, all at distance 1, so the vote is 2 Q to 1 P and the prediction is Q.

GATE-styleNAT · numerical answer

[Naive Bayes] In a spam filter, P(spam) = 0.4. The word "offer" appears in 50% of spam and 5% of non-spam emails, and the word "meeting" appears in 10% of spam and 40% of non-spam emails. Assuming the words are conditionally independent given the class, what is P(spam | both words appear)? Give the answer to three decimal places.

Show answer and explanationAnswer: 0.625

Spam score = 0.4 × 0.5 × 0.1 = 0.02. Non-spam score = 0.6 × 0.05 × 0.4 = 0.012. P(spam | words) = 0.02 / (0.02 + 0.012) = 0.02 / 0.032 = 0.625.

GATE-styleMCQ · one correct answer

[SVM] The maximum-margin hyperplane of a linear SVM is 2x₁ + x₂ − 4 = 0, scaled so that support vectors satisfy |2x₁ + x₂ − 4| = 1. Which of these training points can be a support vector?

Show answer and explanationAnswer: B

The values of 2x₁ + x₂ − 4 are 2, −1, −4 and 2. Only (1, 1) gives ±1, so only it lies on the margin.

Trees and evaluation

GATE-styleNAT · numerical answer

[Decision trees] A node with 8 positive and 8 negative samples is split into a left child with 6 positive and 2 negative and a right child with 2 positive and 6 negative. What is the decrease in Gini impurity?

Show answer and explanationAnswer: 0.125

Gini(root) = 0.5. Each child has proportions 0.75 and 0.25, so Gini = 1 − 0.5625 − 0.0625 = 0.375. Weighted child Gini = 0.375, so the decrease is 0.5 − 0.375 = 0.125.

GATE-styleNAT · numerical answer

[Evaluation] A test for a condition has recall 0.9 and the classifier made 45 true positives and 15 false positives. How many false negatives did it make?

Show answer and explanationAnswer: 5

Recall = TP / (TP + FN) = 0.9, so TP + FN = 45 / 0.9 = 50, and FN = 5. The false positives do not affect recall.

GATE-styleMSQ · one or more correct answers

[Bias and variance] Which of the following typically increase bias? (Select all that apply.)

Show answer and explanationAnswer: A, B, D

A shallower tree, more neighbours and a smaller C all make the model simpler or smoother, which raises bias. Adding higher-degree features makes the model more flexible, lowering bias and raising variance.

Neural networks and unsupervised learning

GATE-styleNAT · numerical answer

[Neural networks] A network has 784 inputs, one hidden layer of 128 neurons and 10 outputs, fully connected with biases. How many parameters does it have?

Show answer and explanationAnswer: 101770

(784 × 128 + 128) + (128 × 10 + 10) = 100480 + 1290 = 101770.

GATE-styleNAT · numerical answer

[k-means] k-means with k = 2 on the points 0, 2, 4, 10, 12 starts with centroids 0 and 12. What is the WCSS after convergence?

Show answer and explanationAnswer: 10

The first assignment gives {0, 2, 4} and {10, 12} (4 is closer to 0 than to 12), with centroids 2 and 11. Nothing changes after that. WCSS = (4 + 0 + 4) + (1 + 1) = 10.

GATE-styleNAT · numerical answer

[PCA] A covariance matrix has eigenvalues 8, 4, 2, 1 and 1. What fraction of the variance is lost when the data is projected onto the first two principal components? Give the answer to three decimal places.

Show answer and explanationAnswer: 0.25

The total variance is 16, and the first two components keep 12 of it. The lost fraction is (2 + 1 + 1) / 16 = 0.25.