MACHINE LEARNING
106403Unit 4: Advanced Topics & Clustering
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.
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).
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.