MACHINE LEARNING
106403Unit 1: Introduction
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).
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.
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.
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.