IIT Madras Zanzibar · Teaching

← Course Overview

Question Bank

Graded conceptual, numerical, PySpark, LSH, and streaming-sketch problems spanning Part 1 (Dr. Nyalala) and Part 2 (Dr. Mahendran V). Work through each step before expanding the solution.

Reference Sheet: Pair these problems with the compiled 2-page PDF formula summary before inspecting solutions.Data Mining Formula Cheat Sheet (PDF) · PySpark Lab 1
Weeks 1–2

Bayesian Decision Theory, MLE, Feature Selection, PCA & LDA


Q1EasyQuiz 1

Given positive-class prior P(Y=1) = 0.2, false-negative cost 10, and false-positive cost 1, at what posterior probability P(Y=1 | x) should a Bayes-optimal classifier predict class 1?

Reveal Worked Solution
Predicting class 1 incurs expected cost 1 * (1 - p), whereas predicting class 0 incurs 10 * p. Predict class 1 when 1 - p < 10p, which yields threshold p > 1/11 = 0.0909.
Q1IntermediateTutorial 2

Contrast Principal Component Analysis (PCA) and Fisher's Linear Discriminant Analysis (LDA) in objective function, supervision requirement, and maximum output dimensions for C classes.

Reveal Worked Solution
PCA is unsupervised and maximizes total projected variance via top eigenvectors of the covariance matrix Sigma, producing up to d components. Fisher LDA is supervised and maximizes between-class scatter over within-class scatter J(w) = (w^T S_B w)/(w^T S_W w) via S_W^{-1} S_B, yielding at most C - 1 non-zero discriminant axes.
Q1AdvancedExam

Explain why standardizing features and fitting PCA inside each cross-validation fold prevents data leakage, and write the exact MLE variance bias correction for Gaussian estimation.

Reveal Worked Solution
Computing global means, variances, or eigenvectors before splitting leaks validation distribution statistics into training features and inflates held-out accuracy. Wrap scalers and PCA inside a fold-scoped Pipeline fit solely on training folds. For Gaussian MLE, sigma_hat^2 = (1/n) * sum (x_i - mu_hat)^2 underestimates population variance by factor (n - 1)/n; Bessel's correction divides by n - 1.
Week 3

Class Imbalance, SMOTE, Decision Trees & Boosting Ensembles


Q1EasyQuiz 1

In a dataset with 99% negative and 1% positive examples, why is accuracy misleading and why is Precision-Recall AUC preferred over ROC AUC?

Reveal Worked Solution
A trivial all-negative classifier achieves 99% accuracy with zero recall. ROC false-positive rate divides by the huge negative count, masking large absolute false-positive volume, whereas Precision-Recall directly measures true positives among predicted positives.
Q1IntermediateTutorial 3

Compute the first AdaBoost learner weight alpha_1 when weighted training error is epsilon_1 = 0.20, and explain how sample weights change for misclassified points.

Reveal Worked Solution
alpha_1 = 0.5 * ln((1 - 0.20) / 0.20) = 0.5 * ln(4) = 0.693. Misclassified points have their weights multiplied by exp(+alpha_1) = 2 before normalization, focusing the next weak learner on hard boundary examples.
Q1AdvancedExam

Compare Bagging (Random Forests) and Gradient Boosting along bias-variance reduction, tree depth, and parallelizability.

Reveal Worked Solution
Random Forests average deep, low-bias, high-variance trees trained independently on bootstrap samples and random feature subsets, reducing variance cleanly in parallel. Gradient Boosting grows shallow trees sequentially on pseudo-residuals -dL/dF, cutting bias iteratively while requiring sequential stage updates and shrinkage learning rates to control overfitting.
Weeks 4–5

Data Cubes, MapReduce, PySpark RDDs & Locality-Sensitive Hashing


Q1EasyQuiz 1

Why does PySpark's reduceByKey outperform groupByKey followed by mapValues(sum) on skewed datasets?

Reveal Worked Solution
reduceByKey runs map-side combining locally within each partition before shuffling over the network, reducing shuffle bytes to at most one key-value pair per partition. groupByKey ships all unaggregated values across the cluster, risking out-of-memory spills.
Q1IntermediateTutorial 5

An LSH index uses n = 100 MinHash rows partitioned into b = 20 bands of r = 5 rows. Calculate the candidate probability for two documents with Jaccard similarity s = 0.5.

Reveal Worked Solution
Probability all r = 5 rows match in one band is s^r = 0.5^5 = 1/32 = 0.03125. Probability of sharing at least one band across b = 20 bands is 1 - (1 - 0.03125)^20 = 1 - 0.530 = 0.470 (about 47%).
Q1AdvancedExam

Given documents D1 = {a, b, c} and D2 = {b, c, d, e}, compute their exact Jaccard similarity and verify how MinHash random permutations preserve that value in expectation.

Reveal Worked Solution
Intersection {b, c} has size 2; union {a, b, c, d, e} has size 5, so J(D1, D2) = 2/5 = 0.40. Under a uniformly random permutation of the 5 elements, the first element hitting D1 union D2 lies in D1 intersect D2 with probability 2/5 = 0.40, so Pr[h(D1) = h(D2)] = J(D1, D2).
Weeks 6–9

Frequent Pattern Mining, Bloom Filters & Scalable Clustering


Q1EasyTutorial 6

Can a Bloom filter ever produce a false negative, and how do you compute its optimal number of hash functions k* for m bits and n inserted keys?

Reveal Worked Solution
No: a Bloom filter never produces false negatives if no deletions occur, because every hash bit of an inserted key is set to 1. Optimal hash count minimizing false-positive probability is k* = (m / n) * ln(2).
Q1IntermediateQuiz 2

In 10,000 market baskets, milk appears in 6,000 baskets, coffee in 2,000, and both in 1,800. Compute Support, Confidence, Lift, and Kulczynski for {coffee} -> {milk}.

Reveal Worked Solution
supp = 1800/10000 = 0.18; conf(coffee -> milk) = 1800/2000 = 0.90; Lift = 0.18 / (0.20 * 0.60) = 1.50; Kulczynski = 0.5 * (P(milk|coffee) + P(coffee|milk)) = 0.5 * (0.90 + 0.30) = 0.60.
Q1AdvancedExam

Explain how BIRCH maintains cluster summaries in a single scan using Clustering Feature (CF) tuples and why those tuples allow exact merging without raw data points.

Reveal Worked Solution
A CF tuple stores (N, LS, SS) where N is point count, LS is the vector sum, and SS is the sum of squared norms. Because sums are additive, merging two clusters adds their tuples component-wise: CF_1 + CF_2 = (N_1 + N_2, LS_1 + LS_2, SS_1 + SS_2), yielding exact merged centroid LS/N and radius in O(d) memory.
Weeks 10–15

Recommender Systems, Web Link Analysis & Streaming Sketches


Q1EasyQuiz 2

In PageRank r = beta * M * r + (1 - beta)/N * 1, what two graph pathologies does teleportation factor (1 - beta) resolve?

Reveal Worked Solution
Teleportation resolves dead ends (nodes with zero out-links that leak total rank mass) and spider traps (closed strongly connected subgraphs that absorb all random-walk mass).
Q1IntermediateExam

Using biased matrix factorization r_hat_ui = mu + b_u + b_i + q_i^T p_u with mu = 3.5, b_u = 0.4, b_i = -0.2, p_u = [0.6, 0.2], q_i = [0.5, -0.5], compute the predicted rating and SGD error against true rating 4.2.

Reveal Worked Solution
Dot product q_i^T p_u = 0.6*0.5 + 0.2*(-0.5) = 0.30 - 0.10 = 0.20. Predicted rating r_hat = 3.5 + 0.4 - 0.2 + 0.20 = 3.90. Residual error e_ui = 4.2 - 3.90 = +0.30.
Q1AdvancedExam

Explain how the DGIM algorithm bounds space to O(log^2 N) bits for counting 1s in the last N bits of a stream and guarantees relative error at most 50%.

Reveal Worked Solution
DGIM groups 1-bits into buckets of power-of-two sizes 1, 2, 4, ..., 2^k <= N, keeping at most two buckets of each size and storing each bucket's timestamp in O(log N) bits. With O(log N) distinct bucket sizes, total memory is O(log^2 N) bits. When answering a window query, only the oldest overlapping bucket of size 2^j is uncertain; because all newer buckets sum to at least 2^j - 1, estimating half of the oldest bucket bounds absolute error below 50%.