2025 question paper
MACHINE LEARNING
28 questions
Q1a. Which of the following is an example of supervised learning? (i) K-means clustering (ii) Linear regression (iii) PCA (iv) DBSCAN20252m
Unit 1: Introduction
View this question on its own page →Which of the following is an example of supervised learning?
(i) K-means clustering
(ii) Linear regression
(iii) PCA
(iv) DBSCANWorked SolutionAnswer: (ii) Linear regression
Explanation:
- Supervised learning requires labelled data .
- Linear regression — learns from pairs to predict continuous target — supervised (regression).
- K-means clustering (i), DBSCAN (iv) — clustering algorithms that find groups without labels — unsupervised.
- PCA (iii) — Principal Component Analysis, dimensionality reduction without labels — unsupervised.
Therefore only (ii) Linear regression is supervised among options.
- Supervised learning requires labelled data .
Q1b. The training dataset has 5 samples with predicted outputs [2,3,5,4,6] and actual outputs [3,3,4,5,6]. What is the Mean Squared Error (MSE)? (i) 0.2 (ii) 0.4 (iii) 0.5 (iv) 0.620252m
Unit 1: Introduction
View this question on its own page →The training dataset has 5 samples with predicted outputs [2,3,5,4,6] and actual outputs [3,3,4,5,6]. What is the Mean Squared Error (MSE)?
(i) 0.2
(ii) 0.4
(iii) 0.5
(iv) 0.6Worked SolutionAnswer: (iv) 0.6
Calculation:
Mean Squared Error:
Given:
Predicted , Actual ,i 1 3 2 1 1 2 3 3 0 0 3 4 5 -1 1 4 5 4 1 1 5 6 6 0 0 Sum squared error Hence (iv) 0.6 is correct. (0.2 would be MAE, not MSE).
Q1c. Ridge regression adds which term to the loss function? (i) L1 norm (ii) Entropy (iii) L2 norm (iv) Cross-entropy20252m
Unit 2: Statistical Decision Theory
View this question on its own page →Ridge regression adds which term to the loss function?
(i) L1 norm
(ii) Entropy
(iii) L2 norm
(iv) Cross-entropyWorked SolutionAnswer: (iii) L2 norm
Explanation:
Ridge Regression (Tikhonov regularization) adds L2 penalty to OLS loss:
where ,
- Shrinks coefficients toward zero, handles multicollinearity, reduces variance / overfitting.
- Closed form:
Contrast:
- L1 norm (i) → Lasso regression, induces sparsity/feature selection.
- Entropy (ii) / Cross-entropy (iv) → used in logistic regression / decision trees, not ridge.
So ridge = L2.
Q1d. Maximum Likelihood estimation finds (i) Prior probabilities (ii) Parameters that maximize data likelihood (iii) Decision boundaries (iv) Cluster centroids20252m
Unit 2: Statistical Decision Theory
View this question on its own page →Maximum Likelihood estimation finds
(i) Prior probabilities
(ii) Parameters that maximize data likelihood
(iii) Decision boundaries
(iv) Cluster centroidsWorked SolutionAnswer: (ii) Parameters that maximize data likelihood
Explanation:
Maximum Likelihood Estimation (MLE):
- Finds parameter values that make observed data most probable under assumed model.
- Example: For Gaussian, MLE gives sample mean and sample variance (biased) .
- Contrast MAP: includes prior.
It does NOT find priors (i), decision boundaries (iii) directly, or cluster centroids (iv) — those are consequences after estimation.
So (ii) is correct.
Q1e. Logistic regression uses which loss function? (i) Mean Squared Error (ii) Euclidean Distance (iii) Cross-Entropy (iv) Hinge Loss20252m
Unit 3: Classification & Regression
View this question on its own page →Logistic regression uses which loss function?
(i) Mean Squared Error
(ii) Euclidean Distance
(iii) Cross-Entropy
(iv) Hinge LossWorked SolutionAnswer: (iii) Cross-Entropy (Log Loss / Binary Cross-Entropy)
Explanation:
Logistic regression models where and maximizes likelihood, equivalent to minimizing:
— Cross-Entropy / Log Loss
- MSE (i) is for linear regression; using it with sigmoid makes optimization non-convex and slow.
- Euclidean Distance (ii) not a classification loss.
- Hinge Loss (iv) is for SVM: .
Thus (iii) Cross-Entropy is correct. It heavily penalizes confident wrong predictions and yields convex optimization.
Q1f. A perceptron has weights w=[0.5, -0.5] and bias b=0. For input x=[1,1] with label y=1, the weight update with learning rate η=0.1 is (i) w=[0.6, -0.4], b=0.1 (ii) w=[0.4, -0.6], b=-0.1 (iii) w=[0.5, -0.5], b=0 (iv) w=[0.7, -0.3], b=0.220252m
Unit 3: Classification & Regression
View this question on its own page →A perceptron has weights w=[0.5, -0.5] and bias b=0. For input x=[1,1] with label y=1, the weight update with learning rate η=0.1 is
(i) w=[0.6, -0.4], b=0.1
(ii) w=[0.4, -0.6], b=-0.1
(iii) w=[0.5, -0.5], b=0
(iv) w=[0.7, -0.3], b=0.2Worked SolutionAnswer: (i) w=[0.6, -0.4], b=0.1
Solution:
Perceptron update rule: ,
Given
- Compute activation:
- Prediction: if else (or ). Here → (misclassified, since true ). Some texts use with as negative, same result.
- Error
- ,
If model predicted correctly (), no update → (iii). But with threshold at , is treated as incorrect, so update occurs → (i) is expected exam answer.
Note: If using with and counted as error, same. If using for , answer would be (iii) no update. Most exam keys expect (i).
Q1g. The kernel trick in SVM is used to (i) Map data to higher-dimensional space for linear separation (ii) Compute probabilities (iii) Reduce feature dimensions (iv) Normalize input features20252m
Unit 3: Classification & Regression
View this question on its own page →The kernel trick in SVM is used to
(i) Map data to higher-dimensional space for linear separation
(ii) Compute probabilities
(iii) Reduce feature dimensions
(iv) Normalize input featuresWorked SolutionAnswer: (i) Map data to higher-dimensional space for linear separation
Explanation:
SVM finds optimal linear hyperplane maximizing margin. Data not linearly separable in original space can be made separable by mapping to higher dimension where linear separation is possible (Cover's theorem).
Kernel trick: Avoids explicit computation; computes inner products in via kernel . Examples: Polynomial , RBF .
(ii) Compute probabilities — not kernel purpose (Platt scaling does, but not trick)
(iii) Reduce dimensions — opposite; it increases dimension implicitly (PCA reduces, kernel doesn't)
(iv) Normalize features — preprocessing, unrelated.
Thus (i) correct.
Q1h. Naive Bayes assumes (i) Features are dependent (ii) Features are independent given the class (iii) Class probabilities are equal (iv) No prior knowledge is required20252m
Unit 3: Classification & Regression
View this question on its own page →Naive Bayes assumes
(i) Features are dependent
(ii) Features are independent given the class
(iii) Class probabilities are equal
(iv) No prior knowledge is requiredWorked SolutionAnswer: (ii) Features are independent given the class
Explanation:
Naive Bayes uses:
Naive assumption: , i.e., features conditionally independent given class label. This drastically reduces parameters from to .
- (i) dependent — opposite of assumption
- (iii) class probabilities equal () — not assumed; priors estimated from data
- (iv) no prior — false; needs (estimated or uniform)
Therefore (ii) is correct. The independence is "naive" because in reality features often correlate, but model still works well in practice.
Q1i. Type I error in hypothesis testing is (i) Accepting null when false (ii) Rejecting null when true (iii) Rejecting alternative when false (iv) Accepting alternative when true20252m
Unit 4: Advanced Topics & Clustering
View this question on its own page →Type I error in hypothesis testing is
(i) Accepting null when false
(ii) Rejecting null when true
(iii) Rejecting alternative when false
(iv) Accepting alternative when trueWorked SolutionAnswer: (ii) Rejecting null when true
Explanation — Hypothesis Testing Errors:
Let = null hypothesis.
- Type I Error (): False Positive — reject when is actually true. (significance level, e.g., 0.05). Example: Convicting an innocent person.
- Type II Error (): False Negative — accept / fail to reject when is true (i.e., false). , Power . Example: Acquitting a guilty person.
- (i) Accepting null when false → Type II
- (ii) Rejecting null when true → Type I ✓
- Confusion matrix mapping: Type I = FP, Type II = FN.
Hence (ii) correct.
Q1j. In Bagging, multiple models are trained on (i) The same dataset (ii) Only test data (iii) Random subsets of the training data (iv) Feature-reduced data only20252m
Unit 4: Advanced Topics & Clustering
View this question on its own page →In Bagging, multiple models are trained on
(i) The same dataset
(ii) Only test data
(iii) Random subsets of the training data
(iv) Feature-reduced data onlyWorked SolutionAnswer: (iii) Random subsets of the training data
Explanation — Bagging (Bootstrap Aggregating):
- Given training set of size , Bagging creates bootstrap samples : each by sampling points with replacement → random subset (≈63.2% unique per bag, rest out-of-bag).
- Train one base learner on each (e.g., decision trees in Random Forest).
- Aggregate: classification by majority vote, regression by averaging: .
- Purpose: reduces variance, avoids overfitting, parallelizable.
Contrast:
- (i) same dataset — no diversity, defeats ensemble purpose
- (ii) only test data — would be leakage, never train on test
- (iv) feature-reduced only — that is feature bagging / Random Subspace part of Random Forest (both row + column sampling), but primary definition is row bootstrap.
So (iii) is core.
- Install PocketlyBudget App•POCKETLY
Pocketly on Android
Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.
Q2a. Define machine learning. Compare and contrast the different types of learning. Include examples and explain the scenarios where each is best applied.20257m
Unit 1: Introduction
View this question on its own page →Define machine learning. Compare and contrast the different types of learning. Include examples and explain the scenarios where each is best applied.
Worked SolutionDefine Machine Learning:
Arthur Samuel (1959): Field that gives computers ability to learn without being explicitly programmed. Tom Mitchell: A program learns from experience w.r.t task and performance if on improves with .Types of Learning:
Supervised Learning — Labelled data . Learn .
- Regression: predict continuous (house price from features). Algorithms: Linear Regression, SVR, NN.
- Classification: discrete (spam/ham). Algorithms: Logistic Regression, SVM, Random Forest, k-NN.
- Best when: labels available, need predictive accuracy, loss well-defined.
Unsupervised Learning — No labels, find structure .
- Clustering: group similar points (customer segmentation) — K-means, DBSCAN.
- Dimensionality Reduction: (PCA, t-SNE) visualize/compress.
- Association: (Apriori) market basket.
- Best when: exploring data, no labels, need hidden patterns.
Semi-supervised: Small labeled + large unlabeled (e.g., medical images, labeling expensive). Uses consistency regularization / pseudo-labeling. Best when labeling costly.
Reinforcement Learning — Agent interacts with environment, learns policy via reward . No correct output, only reward signal. Examples: game playing (AlphaGo), robotics, autonomous driving. Algorithms: Q-learning, Policy Gradient, Actor-Critic. Best when sequential decisions, delayed reward.
Self-supervised (modern): Labels created from data itself (predict masked words — BERT). Between supervised/unsupervised.
Comparison Table:
Aspect Supervised Unsupervised RL Data only Feedback direct error none reward Goal Predict Find structure Maximize cumulative reward Eval Accuracy/MSE Silhouette, reconstruction Cumulative reward Example Scenarios:
- Supervised: Email spam filter (many labeled emails).
- Unsupervised: Gene clustering for disease subtypes.
- RL: Warehouse robot navigation.
Q2b. Describe the evaluation metrics used in machine learning, such as accuracy, precision, recall, and F1-score, with a numerical example. Explain the importance of cross-validation in estimating a model's generalization performance.20257m
Unit 1: Introduction
View this question on its own page →Describe the evaluation metrics used in machine learning, such as accuracy, precision, recall, and F1-score, with a numerical example. Explain the importance of cross-validation in estimating a model's generalization performance.
Worked SolutionEvaluation Metrics (Classification):
Let TP, TN, FP, FN from confusion matrix.
- Accuracy — fraction correct. Fails on imbalanced data.
- Precision — of predicted positives, how many truly positive. Important when FP costly (spam filter).
- Recall / Sensitivity / TPR — of actual positives, how many found. Important when FN costly (cancer detection).
- F1-score — harmonic mean, balances P & R.
- Others: Specificity , ROC-AUC.
Numerical Example:
Suppose 100 patients: TP=40, FP=10, FN=20, TN=30- Accuracy
- Precision
- Recall
- F1
Regression metrics: MSE , RMSE, MAE, .
Importance of Cross-Validation:
Hold-out single split is noisy. k-Fold CV (usually ) partitions data into folds, trains on , validates on remaining, rotates, averages error: .
Benefits:
- Unbiased estimate of generalization: Uses all data for both training and validation, reduces variance vs single split.
- Model selection / hyperparameter tuning: Choose without touching test set.
- Detects overfitting: Large gap train vs CV error signals overfit.
- Stratified CV: preserves class proportions for imbalance.
After CV, retrain on full training data, report final performance on held-out test set never used in CV. LOOCV () unbiased but expensive; is good bias-variance trade-off.
Q3(a). A company wants to predict the sales (y) of a product based on its advertising expenditure (x). The observed data for 5 months is: | x (Advertising) | y (Sales) | |-----------------|-----------| | 1 | 3 | | 2 | 4 | | 3 | 2 | | 4 | 5 | | 5 | 7 | Calculate the regression coefficients for the linear regression model: y = w_0 + w_1 x Then, predict the value of y when x = 6.20257m
Unit 2: Statistical Decision Theory
View this question on its own page →A company wants to predict the sales (y) of a product based on its advertising expenditure (x).
The observed data for 5 months is:x (Advertising) y (Sales) 1 3 2 4 3 2 4 5 5 7 Calculate the regression coefficients for the linear regression model:
Then, predict the value of y when x = 6.
Worked SolutionGiven: , ,
Compute (intercept), (slope) for via OLS.
Formulas: ,
1 3 -2 -1.2 2.4 4 2 4 -1 -0.2 0.2 1 3 2 0 -2.2 0 0 4 5 1 0.8 0.8 1 5 7 2 2.8 5.6 4 Sum numer , denom Model:
Prediction at :
Residuals check: , SSE small.
If using normal equations directly: gives same.
Q3b. Given a dataset with two features: X = [[2, 0], [0, 1], [0, 2]]. Compute the covariance matrix, eigenvalues, and the principal components.20257m
Unit 2: Statistical Decision Theory
View this question on its own page →Given a dataset with two features: X = [[2, 0], [0, 1], [0, 2]]. Compute the covariance matrix, eigenvalues, and the principal components.
Worked SolutionData: , ,
Step 1: Mean center.
Centered
Step 2: Covariance (unbiased; if divide by 3, mention both).
Hence:
- Unbiased ():
- Biased (): (scale by )
Step 3: Eigenvalues solve :
, (Unbiased)
For biased version: , (2/3 times).Explained variance: by PC1, by PC2.
Step 4: Eigenvectors (PCs):
For : normalized
For : orthogonal.Normalized PCs (unit): direction of max variance (roughly along diagonal), orthogonal.
Projection gives reduced 1D representation capturing variance. First PC is the principal component.
Q4a. Explain the concept of linear classifiers. How do they separate classes in feature space? Give examples of linearly separable and non-separable datasets.20257m
Unit 3: Classification & Regression
View this question on its own page →Explain the concept of linear classifiers. How do they separate classes in feature space? Give examples of linearly separable and non-separable datasets.
Worked SolutionLinear Classifiers:
Classifier where decision boundary is linear function . Prediction: (binary), or for multi-class. Hypothesis space: half-spaces.
How they separate in feature space:
- In , hyperplane splits space into two half-spaces. Distance from point to hyperplane .
- Learning finds minimizing loss (perceptron, logistic, SVM hinge). Geometrically, orientation and offset adjusted to separate classes.
- For , boundary is line; plane; higher hyperplane.
- Margin intuition (SVM): maximize distance between boundary and nearest points.
Linearly Separable example:
AND gate data: can be separated by . Points on opposite sides perfectly separable. Iris dataset (setosa vs versicolor with sepal length/width) approx linear.Non-separable example:
XOR: — no single line separates. Need non-linear boundary. Concentric circles, interleaving moons. Solution: map to higher dim via features or use kernel/nonlinear model (MLP with hidden layer).Limitation: Linear classifiers cannot capture XOR, curved boundaries without feature engineering/kernel trick. Advantage: simple, fast, interpretable, works when data approx linear or high-dim sparse (text).
Q4b. Explain the Perceptron learning algorithm. How does it update weights? Discuss its convergence properties.20257m
Unit 3: Classification & Regression
View this question on its own page →Explain the Perceptron learning algorithm. How does it update weights? Discuss its convergence properties.
Worked SolutionPerceptron Learning Algorithm (Rosenblatt 1957):
Linear binary classifier , (or ).
Algorithm:
Initialize
Repeat until convergence:
For each in training (random order):
Compute
Predict
If (misclassified):
else no update
learning rate (often 1).Weight Update Intuition: Move weight vector toward misclassified positive example () and away from negative, increasing score for correct class.
With labels: ,
Convergence Properties:
- Perceptron Convergence Theorem: If data is linearly separable with margin and radius , perceptron makes at most mistakes and converges to a separating hyperplane in finite steps, regardless of initialization or order. Does not guarantee maximum margin (unlike SVM).
- If data not separable, algorithm never converges, cycles — use Pocket algorithm (keep best weights) or averaging.
- Not sensitive to when separable (scaling).
- Online algorithm, mistake-driven, per epoch, fast.
Limitations: Cannot solve XOR, needs separable data; output is hard threshold, no probabilities. Extensions: kernel perceptron, voted perceptron, averaged perceptron for stability.
Example: AND gate converges in few steps; XOR never converges without hidden layer.Q5a. Explain the concept of SVM for linear classification. Define margin, support vectors, and how the optimal hyperplane is determined.20257m
Unit 3: Classification & Regression
View this question on its own page →Explain the concept of SVM for linear classification. Define margin, support vectors, and how the optimal hyperplane is determined.
Worked SolutionSVM for Linear Classification:
Goal: Find hyperplane that maximally separates classes .
Margin: Distance from hyperplane to closest training point. For canonical hyperplane , geometric margin , total margin width . SVM maximizes this.
Support Vectors: Training points lying exactly on margin boundaries . They are critical — removing non-support vectors doesn't change solution. Solution depends only on SVs where .
Optimal Hyperplane Determination:
Primal (hard margin):
s.t.For non-separable, soft margin with slack :
s.t. ,trades margin vs errors.
Solving:
Lagrangian dual: s.t. , . Quadratic programming. Then , from SV (average). Decision: .Geometric intuition: Push two parallel supporting hyperplanes as far apart as possible without violating, supports touch boundaries. Largest margin gives best generalization (VC dimension). Kernel trick extends to non-linear by .
Q5b. Explain the backpropagation algorithm. How are weights updated in a neural network using gradient descent?20257m
Unit 3: Classification & Regression
View this question on its own page →Explain the backpropagation algorithm. How are weights updated in a neural network using gradient descent?
Worked SolutionBackpropagation Algorithm — Weight Update via Gradient Descent:
For MLP with layers, loss or cross-entropy.
Steps:
Forward: , where is sigmoid/ReLU. Propagate to output.
Backward (output layer ): Error term (for MSE) or generally $ \delta^{(L)} =
abla E \odot f'(net)$.Hidden layers: — error weighted by downstream weights.
Gradients: ,
Update (SGD): ,
For batch: average over examples, momentum $\Delta w(t)= -\eta
abla E + \alpha\Delta w(t-1)\eta$.Role of Gradient Descent: Iteratively moves weights opposite gradient $w:=w-\eta
abla E\etaO(W)$ via chain rule, enabling deep learning.Variants: Vanilla SGD (per sample), mini-batch SGD, batch GD. Improvements: momentum, RMSProp, Adam, weight decay (L2).
Q6a. Why is clustering important in machine learning? Show the steps of the k-means algorithm by taking a suitable example. Give the time complexity analysis of k-means.20257m
Unit 4: Advanced Topics & Clustering
View this question on its own page →Why is clustering important in machine learning? Show the steps of the k-means algorithm by taking a suitable example. Give the time complexity analysis of k-means.
Worked SolutionWhy Clustering Important:
Unsupervised, discovers hidden structure without labels. Uses: customer segmentation, gene grouping, image segmentation, anomaly detection, document clustering, feature engineering, data compression.K-means Algorithm Steps:
Input: Data , , distance (Euclidean)
Goal: minimize- Initialize: Choose centroids randomly (k-means++ better).
- Assignment: Assign each to nearest centroid:
- Update: Recompute
- Repeat 2-3 until centroids stop moving or change < threshold (convergence to local optimum).
Suitable Example:
Data points: A(1,1), B(1.5,2), C(3,4), D(5,7), D(3.5,5), E(4.5,5),
Init ,
Iter1 assignments: cluster1 {A,B}, cluster2 {C,D}... recompute etc. After few iterations converges to two clusters.Time Complexity Analysis:
Per iteration: distance computations ( points, centroids, dims). For iterations: . Space . If constants, linear in . Compared to hierarchical . Elkan/Hamerly accelerations reduce but worst still . Typically fast, converges quickly (10-100 iterations). Mention Lloyd's algorithm.Limitations: need pre-specify (elbow/silhouette), sensitive to init & outliers, assumes spherical clusters, Euclidean biased.
Q6b. Compare bagging, AdaBoost, and gradient boosting. Discuss how each method reduces bias and variance and improves model performance.20257m
Unit 4: Advanced Topics & Clustering
View this question on its own page →Compare bagging, AdaBoost, and gradient boosting. Discuss how each method reduces bias and variance and improves model performance.
Worked SolutionBagging vs AdaBoost vs Gradient Boosting:
Bagging (Bootstrap Aggregating):
- Parallel, bootstrap samples, full trees, reduces variance by averaging (Random Forest). Each model independent, weight equal. Robust to overfit, handles noisy data well. Example: trees vote.
AdaBoost (Adaptive Boosting — Freund & Schapire):
- Sequential, adaptively reweights samples: increase weight for misclassified, decrease for correct. Weak learners typically stumps (). Final: , . Minimizes exponential loss .
- Reduces bias (and some variance), very effective but sensitive to noise/outliers (weights blow up).
Gradient Boosting (Friedman — GBM, XGBoost):
- Sequential, fits new learner to residual / negative gradient of loss: . For squared loss , for logistic gradient. Update $F_m=F_{m-1}+
u \gamma_m h_m(x)
u$ shrinkage). - Reduces bias, flexible (any differentiable loss), often strongest accuracy, needs careful tuning ( , learning rate, depth, regularization) to avoid overfit. XGBoost adds second-order Taylor, leaf weight regularization .
Bias-Variance:
- Bagging — primarily variance reduction (averaging decorrelated trees); slight bias increase if bootstrap.
- Boosting — primarily bias reduction (sequentially correcting errors); variance can increase if too many iterations, controlled by shrinkage/early stopping.
Choosing: Noisy, limited tuning time → Bagging/RF. Max accuracy, structured data → Gradient Boosting/XGBoost/LightGBM. Very weak stumps + exponential loss → AdaBoost (now largely superseded by GBM).
- Install PocketlyBudget App•POCKETLY
Pocketly on Android
Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.
Q7a. Explain the EM algorithm. Describe the E-step and M-step with an example of parameter estimation in a mixture model.20257m
Unit 5: Specialized Learning Theories
View this question on its own page →Explain the EM algorithm. Describe the E-step and M-step with an example of parameter estimation in a mixture model.
Worked SolutionEM Algorithm (Expectation-Maximization):
Iterative method for MLE in presence of latent variables (e.g., mixture components, missing data). Maximizes intractable directly.
Idea: Iteratively construct lower bound via Jensen, maximize it.
Steps:
Given data , latent , parameters .E-step (Expectation): Compute posterior and expected complete log-likelihood
Equivalent to computing responsibilities .M-step (Maximization):
Iterate until . Guaranteed monotonic increase, converges to local optimum (not necessarily global; restart needed).
Example — Gaussian Mixture Model (GMM) with components:
Model: , latent indicates component.
E-step:
M-step: , , ,
Example numbers: Data {1,2,10}, init → E-step assigns 1,2 to component1 (), 10 to component2 → M-step updates , → iterates.
EM also used in HMM (Baum-Welch), k-means is hard-assignment limit of GMM-EM with spherical .
Q7b. Define the main components of reinforcement learning. Explain the exploration-exploitation tradeoff with an example.20257m
Unit 5: Specialized Learning Theories
View this question on its own page →Define the main components of reinforcement learning. Explain the exploration-exploitation tradeoff with an example.
Worked SolutionMain Components of Reinforcement Learning (RL):
Agent learns policy interacting with environment via trial-reward.
- Agent: Learner/decision maker (robot, game player).
- Environment: External system agent interacts with (maze, market).
- State : Snapshot of environment (position, sensor readings).
- Action : Moves agent can take (up/down, buy/sell).
- Reward : Scalar feedback after action (positive for goal, negative for penalty).
- Policy : Agent's strategy mapping states → actions (deterministic or stochastic), goal to learn optimal .
- Value Function: , — expected cumulative discounted return. Optimal satisfy Bellman equations.
- Model (optional): Transition dynamics and reward model; model-based vs model-free.
- Discount : Balances immediate vs future reward.
Loop: Goal: maximize .
Exploration-Exploitation Trade-off:
- Exploitation: Use best-known action (max ) to maximize immediate reward.
- Exploration: Try random/new actions to discover potentially better long-term rewards.
Too much exploitation → stuck in suboptimal policy (local optimum). Too much exploration → never converges, low reward.
Example: Multi-Armed Bandit / Maze.
- Robot in maze knows one path gives reward 10 (exploitation), but unexplored path may give 100. -greedy: with prob explore random action, else exploit best. Anneal over time. UCB and Thompson Sampling also balance via uncertainty.
In AlphaGo, exploitation = play best known move from , exploration = try novel moves during self-play to improve.
Solution: decay from 1 → 0.1, optimistic initialization, intrinsic motivation.
Q8(b). Apply the ID3 algorithm on the following data to draw a decision tree. Show the Information Gain at each split. ### Dataset | Outlook | Temperature | Humidity | Windy | PlayTennis | |-----------|-------------|----------|-------|-------------| | Sunny | Hot | High | False | No | | Sunny | Hot | High | True | No | | Overcast | Hot | High | False | Yes | | Rainy | Mild | High | False | Yes | | Rainy | Cool | Normal | False | Yes | | Rainy | Cool | Normal | True | No | | Overcast | Cool | Normal | True | Yes | | Sunny | Mild | High | False | No | | Sunny | Cool | Normal | False | Yes | | Rainy | Mild | Normal | False | Yes | | Sunny | Mild | Normal | True | Yes | | Overcast | Mild | High | True | Yes | | Overcast | Hot | Normal | False | Yes | | Rainy | Mild | High | True | No |202510m
Unit 3: Classification & Regression
View this question on its own page →Apply the ID3 algorithm on the following data to draw a decision tree. Show the Information Gain at each split.
Dataset
Outlook Temperature Humidity Windy PlayTennis Sunny Hot High False No Sunny Hot High True No Overcast Hot High False Yes Rainy Mild High False Yes Rainy Cool Normal False Yes Rainy Cool Normal True No Overcast Cool Normal True Yes Sunny Mild High False No Sunny Cool Normal False Yes Rainy Mild Normal False Yes Sunny Mild Normal True Yes Overcast Mild High True Yes Overcast Hot Normal False Yes Rainy Mild High True No Worked SolutionID3 on PlayTennis (14 examples: 9 Yes, 5 No, )
Calculate
Outlook: Sunny (5:2Y3N, ), Overcast (4:4Y0N ), Rainy (5:3Y2N ) → Weighted → Gain=0.246
Temperature: Hot 4:2Y2N , Mild 6:4Y2N , Cool 4:3Y1N → Weighted → Gain
Humidity: High 7:3Y4N , Normal 7:6Y1N → Weighted → Gain
Windy: False 8:6Y2N , True 6:3Y3N → Weighted → Gain
Root = Outlook (max gain).
Outlook=Overcast → Leaf Yes (4/4 pure)
Outlook=Sunny (5 ex: 2Y3N, ): Evaluate remaining (Temp,Humidity,Windy):
- Gain(Humidity)=0.971 (High 3:0Y3N , Normal 2:2Y0N → weighted 0) → Best = Humidity
- Humidity=High → Leaf No, Humidity=Normal → Leaf Yes
Outlook=Rainy (5 ex: 3Y2N): Evaluate:
- Windy: False 3:3Y0N , True 2:0Y2N → Weighted 0 → Gain → Best=Windy
- Humidity gain , Temp
- Windy=False → Leaf Yes, Windy=True → Leaf No
Final Tree:
Outlook? ├─ Sunny → Humidity? │ ├─ High → No (3) │ └─ Normal → Yes (2) ├─ Overcast → Yes (4) └─ Rainy → Windy? ├─ False → Yes (3) └─ True → No (2)This tree achieves 100% training accuracy (14/14). Equivalent textbook result; order of Humidity/Windy nodes may swap if tie but this is standard ID3 outcome. Information Gains shown above at each split.
Q8a. Suppose 10000 patients are tested for flu; out of them, 9000 are actually healthy and 1000 are actually sick. For the sick people, a test was positive for 620 and negative for 380. For the healthy people, the same test was positive for 180 and negative for 8820. Construct a confusion matrix.20254m
Unit 1: Introduction
View this question on its own page →Suppose 10000 patients are tested for flu; out of them, 9000 are actually healthy and 1000 are actually sick. For the sick people, a test was positive for 620 and negative for 380. For the healthy people, the same test was positive for 180 and negative for 8820. Construct a confusion matrix.
Worked SolutionConfusion Matrix Construction (Actual vs Predicted):
Given 10,000 patients: 1,000 actually Sick (Positive class), 9,000 Healthy (Negative).
Test results:
- Sick: 620 Positive (TP), 380 Negative (FN)
- Healthy: 180 Positive (FP), 8820 Negative (TN)
Matrix (rows=Actual, cols=Predicted):
Predicted Positive Predicted Negative Row Total Actually Sick (P) 620 (TP) 380 (FN) 1,000 Actually Healthy (N) 180 (FP) 8820 (TN) 9,000 Col Total 800 9200 10,000 Alternatively Predicted as rows — equivalent transpose; specify.
Derived metrics (optional):
- Accuracy (misleading due imbalance)
- Precision
- Recall/Sensitivity
- Specificity
- False Positive Rate
Note: Despite high accuracy, recall only 62% — 38% sick missed, critical for medical test. Confusion matrix reveals class imbalance impact better than accuracy alone.
Q9a. Write short note on: Logistic Regression and Sigmoid Function20257m
Unit 3: Classification & Regression
View this question on its own page →Write short note on: Logistic Regression and Sigmoid Function
Worked SolutionLogistic Regression and Sigmoid Function:
Logistic Regression:
Discriminative linear classifier for binary classification. Despite name, it's classification, not regression. Models posterior where is sigmoid.- Hypothesis:
- Decision: predict 1 if () else 0 — linear boundary.
- Loss: Binary cross-entropy (log loss) — convex MLE under Bernoulli.
- Gradient: $
abla J = \frac1m X^T (h-y)$, solved via SGD, Newton. - Regularization: prevents overfit.
- Multi-class extends via softmax (Multinomial Logistic).
- Interpretable: coefficients as log-odds ratio, = odds multiplier for unit feature increase.
- Use when need probabilities, linear separable, baseline for text, medical.
Sigmoid Function:
, shape S-curve , derivative .Properties: squashes real to (0,1), smooth, differentiable, but suffers vanishing gradient for large (near 0 or 1) — replaced by ReLU in deep hidden layers but still core for logistic output, gating (LSTM).
Example: , , .
Together, sigmoid makes linear score interpretable as probability, optimized via cross-entropy, yielding calibrated classifier.
Q9b. Write short note on: Hierarchical Clustering20257m
Unit 4: Advanced Topics & Clustering
View this question on its own page →Write short note on: Hierarchical Clustering
Worked SolutionHierarchical Clustering:
Unsupervised method building hierarchy / dendrogram of clusters — tree where leaves = points, internal nodes = merges/splits at certain distance.
Two approaches:
Agglomerative (Bottom-Up) — most common:
- Start each point as cluster.
- Repeat: find two closest clusters via linkage, merge, update distances.
- Stop at or desired (cut dendrogram).
- Linkages:
- Single linkage: — produces elongated chains, sensitive to noise
- Complete: distance — compact spherical clusters
- Average: mean distance
- Ward: minimizes increase in within-cluster SSE — often best, prefers equal-sized.
- Complexity naive, with heap, memory.
Divisive (Top-Down):
- Start one cluster, recursively split (e.g., via K-means), rarer due to exponential.
Dendrogram: Height = distance at merge; cut at height gives clustering. Can inspect for natural .
Advantages: No preset needed (choose after), shows structure at multiple resolutions, deterministic, visualization.
Disadvantages: Greedy (once merged cannot undo), sensitive to outliers/noise (single linkage), memory limits large data, difficult to handle large (>10k).
Example: Data points (1,2),(2,2),(8,8): single linkage merges first two at dist 1, then merges with (8,8) at ~8.5 distance dendrogram.
Use: Gene expression phylogeny, document taxonomy, small-medium datasets where hierarchy insightful. Often combined with K-means for scale.
Q9c. Write short note on: Bayesian Networks20257m
Unit 5: Specialized Learning Theories
View this question on its own page →Write short note on: Bayesian Networks
Worked SolutionBayesian Networks:
Directed Acyclic Graph (DAG) representation of joint distribution .
Structure: Nodes = random variables, directed edges = direct dependencies (parent → child conditional). Each node has Conditional Probability Table (CPT): for discrete, or density for continuous.
Joint factorization: (chain rule with d-separation conditional independencies). Example: , .
Inference: Compute via enumeration, Variable Elimination, Belief Propagation, Junction Tree (exact exponential), or approximate MCMC/Likelihood Weighting. Bayes rule propagates evidence.
Learning:
- Parameter learning: MLE/MAP estimate CPTs from data ().
- Structure learning: Search over DAGs scoring via BIC/MDL, NP-hard.
Advantages: Compact, interpretable causal model, handles missing data, combines prior knowledge, supports both causal and diagnostic reasoning (e.g., ).
Uses: Medical diagnosis (ALARM network), fault detection, speech recognition (HMM is dynamic BN), decision support (Influence Diagrams).
Example: , , CPT, — can query via Bayes net inference.
Limitations: DAG cannot have cycles, eliciting CPTs expensive, inference NP-hard for dense nets. For undirected cyclic dependencies use Markov Random Fields.
Q9d. Write short note on: Hypothesis Space and Inductive Bias20257m
Unit 1: Introduction
View this question on its own page →Write short note on: Hypothesis Space and Inductive Bias
Worked SolutionHypothesis Space and Inductive Bias:
Hypothesis Space : Set of all hypotheses learner can potentially output. Defines representational capacity.
- Example Boolean attributes: all functions, but conjunctive class size (each attribute +/−/don't care).
- For linear models: .
- Larger → higher variance, needs more data, may overfit; smaller → may underfit if true concept outside .
Inductive Bias: Assumptions learner uses to generalize beyond training data and prefer one consistent hypothesis over others. Without bias, no generalization.
Mitchell: "any basis for choosing one generalization over another, other than strict consistency with observed training instances."
Types:
- Restriction bias: Restrict (e.g., only linear separators) — strong, excludes some concepts.
- Preference bias: Order search (e.g., Occam's razor — prefer simpler hypothesis, shorter decision tree, smaller , regularization). contains all but search prefers simpler.
Example: Candidate Elimination with conjunctions: bias = target is conjunction → cannot learn . Decision Tree preference for shorter trees with high information gain.
Why needed: No bias → all hypotheses consistent with data equally valid, learner cannot classify unseen instance (No Free Lunch). Bias enables generalization but if wrong → inductive bias mismatch causes error.
Relation: Hypothesis space + bias determine learnability; PAC bounds show sample complexity or . Good bias (e.g., smoothness for images) reduces sample needs.
Coursify Android App
Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.