Classification predicts discrete categorical class labels, whereas Numeric Prediction models continuous valued functions. Decision tree induction builds a flowchart-like tree structure where each internal node denotes an attribute test, each branch denotes a test outcome, and each leaf node holds a class label.
| Algorithm | Splitting Criterion | Attribute Types | Pruning & Missing Values |
|---|---|---|---|
| ID3 (Quinlan 1986) | Information Gain: $\text{Gain}(S, A) = H(S) - \sum \frac{|S_v|}{|S|} H(S_v)$ | Categorical only (No numeric support). | No pruning (prone to severe overfitting); cannot handle missing values. |
| C4.5 (Quinlan 1993) | Gain Ratio: $\text{GainRatio}(S, A) = \frac{\text{Gain}(S, A)}{\text{SplitInfo}(S, A)}$ | Categorical & Continuous (dynamic threshold splitting). | Post-pruning via Pessimistic Error Pruning (PEP); native fractional missing value imputation. |
| CART (Breiman 1984) | Gini Impurity: $\text{Gini}(S) = 1 - \sum_{i=1}^m p_i^2 \implies \text{Strictly Binary Trees}$ | Categorical & Continuous. | Cost-Complexity Pruning with cross-validation; surrogate splits for missing data. |
A dataset $S$ has 14 instances: 9 "Yes" and 5 "No". Attribute Wind has values $\{\text{Weak: } [6\text{ Yes}, 2\text{ No}], \text{Strong: } [3\text{ Yes}, 3\text{ No}]\}$.
1. Base Entropy $H(S)$ and Information Gain (ID3):
$$H(S) = - \left( \frac{9}{14}\log_2\frac{9}{14} + \frac{5}{14}\log_2\frac{5}{14} \right) = - [0.6429(-0.6374) + 0.3571(-1.4854)] = 0.4098 + 0.5305 = \mathbf{0.9403 \text{ bits}}$$ $$H(S_{\text{Weak}}) = - \left( \frac{6}{8}\log_2\frac{6}{8} + \frac{2}{8}\log_2\frac{2}{8} \right) = - [0.75(-0.415) + 0.25(-2.0)] = 0.3113 + 0.5000 = \mathbf{0.8113 \text{ bits}}$$ $$H(S_{\text{Strong}}) = - \left( \frac{3}{6}\log_2\frac{3}{6} + \frac{3}{6}\log_2\frac{3}{6} \right) = \mathbf{1.0000 \text{ bits}}$$ $$\mathbf{\text{Gain}(S, \text{Wind}) = 0.9403 - \left[ \frac{8}{14}(0.8113) + \frac{6}{14}(1.0000) \right] = 0.9403 - [0.4636 + 0.4286] = \mathbf{0.0481 \text{ bits}}}$$2. Gini Impurity (CART):
$$\text{Gini}(S) = 1 - \left[ \left(\frac{9}{14}\right)^2 + \left(\frac{5}{14}\right)^2 \right] = 1 - [0.4133 + 0.1276] = 1 - 0.5409 = \mathbf{0.4591}$$ $$\text{Gini}(S_{\text{Weak}}) = 1 - \left[ \left(\frac{6}{8}\right)^2 + \left(\frac{2}{8}\right)^2 \right] = 1 - [0.5625 + 0.0625] = \mathbf{0.3750}$$ $$\text{Gini}(S_{\text{Strong}}) = 1 - \left[ \left(\frac{3}{6}\right)^2 + \left(\frac{3}{6}\right)^2 \right] = 1 - [0.25 + 0.25] = \mathbf{0.5000}$$ $$\mathbf{\Delta\text{Gini}(S, \text{Wind}) = 0.4591 - \left[ \frac{8}{14}(0.3750) + \frac{6}{14}(0.5000) \right] = 0.4591 - [0.2143 + 0.2143] = \mathbf{0.0305}}$$| Evaluation Metric | Mathematical Formulation | Key Focus |
|---|---|---|
| Accuracy | $$\text{Accuracy} = \frac{TP + TN}{TP + TN + FP + FN}$$ | Overall correctness; misleading in imbalanced datasets! |
| Sensitivity / Recall (TPR) | $$\text{Sensitivity} = \frac{TP}{TP + FN} = \frac{\text{Positives Correctly Identified}}{\text{Actual Positives}}$$ | Critical in disease diagnosis (minimizing False Negatives). |
| Specificity (TNR) | $$\text{Specificity} = \frac{TN}{TN + FP} = \frac{\text{Negatives Correctly Identified}}{\text{Actual Negatives}}$$ | True negative rate (FPR = $1 - \text{Specificity}$). |
| Precision (PPV) | $$\text{Precision} = \frac{TP}{TP + FP} = \frac{\text{True Positives}}{\text{Predicted Positives}}$$ | Critical in fraud detection & search ranking. |
| $F_1$-Score | $$F_1 = 2 \times \frac{\text{Precision} \times \text{Recall}}{\text{Precision} + \text{Recall}} = \frac{2 TP}{2 TP + FP + FN}$$ | Harmonic mean balancing precision and recall. |
| Clustering Paradigm | Core Algorithm | Key Strengths & Cluster Shapes |
|---|---|---|
| Partitioning Methods | k-Means: Minimizes Sum of Squared Errors (SSE); k-Medoids (PAM): Uses actual medoid points (robust to outliers). | Fast ($O(t k N)$); restricted strictly to spherical, convex clusters of equal density. |
| Hierarchical Methods | AGNES (Agglomerative): Bottom-up tree; DIANA (Divisive): Top-down; BIRCH: CF-Tree for massive datasets. | Produces dendrogram hierarchy; no need to specify $k$ upfront; irreversible merges $O(N^2)$. |
| Density-Based Methods | DBSCAN: Clusters are continuous dense regions separated by low-density noise regions ($\epsilon, \text{MinPts}$). | Discovers arbitrary non-convex shapes; automatically detects and filters noise outliers! |
Consider 4 points: $C_1 = \{P_1(0, 0), P_2(1, 0)\}$, $C_2 = \{P_3(5, 0), P_4(6, 0)\}$. Calculate Silhouette score for $P_1$:
| Linkage Criterion | Distance Formulation | Cluster Shape & Properties |
|---|---|---|
| Single Link (MIN) | $d(C_i, C_j) = \min_{\mathbf{x} \in C_i, \mathbf{y} \in C_j} d(\mathbf{x}, \mathbf{y})$ | Can handle non-elliptical shapes; highly sensitive to noise and chaining effect (elongated stringy clusters). |
| Complete Link (MAX) | $d(C_i, C_j) = \max_{\mathbf{x} \in C_i, \mathbf{y} \in C_j} d(\mathbf{x}, \mathbf{y})$ | Produces compact, spherical clusters of equal diameter; avoids chaining; sensitive to outliers. |
| Average Link (UPGMA) | $d(C_i, C_j) = \frac{1}{|C_i||C_j|}\sum_{\mathbf{x}} \sum_{\mathbf{y}} d(\mathbf{x}, \mathbf{y})$ | Robust balance between single and complete link; resistant to noise. |
| Ward's Method | Merges pair that minimizes increase in total within-cluster Sum of Squared Errors ($\Delta\text{SSE}$). | Produces exceptionally balanced, dense spherical clusters (most popular in business analytics). |
| Ensemble Method | Core Algorithmic Paradigm | Variance vs. Bias Reduction |
|---|---|---|
| Bagging (Bootstrap Aggregating) | Trains $B$ independent base models (e.g. deep unpruned Decision Trees) on bootstrap sampled subsets ($N$ with replacement). Averages predictions (regression) or takes majority vote (classification). | Dramatically reduces Variance without increasing bias (e.g. Random Forests). |
| Boosting (AdaBoost / GBM / XGBoost) | Trains a sequence of weak learners iteratively. Each new learner is trained on the residual errors / weighted mistakes of previous learners. | Dramatically reduces Bias and variance; prone to overfitting on heavy noise. |
| Stacking (Stacked Generalization) | Trains multiple heterogeneous base models (SVM, Random Forest, k-NN); uses a meta-classifier (e.g. Logistic Regression) to learn optimal combination weights. | Maximizes generalization performance by combining diverse hypothesis spaces. |
Unlike DBSCAN (which requires a single rigid global radius $\epsilon$), OPTICS (Ankerst et al. 1999) creates an ordered list of points storing two dynamic distance attributes:
Reachability Plot: Plotting reachability distances in the OPTICS ordering produces valleys corresponding to dense clusters and peaks corresponding to noise dividers, revealing hierarchical multi-density cluster structures across all $\epsilon$ simultaneously!
A training dataset has 10 samples: 6 Class $C_1$ and 4 Class $C_2$. An attribute Color has values $\{\text{Red, Green, Blue}\}$. In class $C_1$, $\text{count}(\text{Red}) = 0, \text{count}(\text{Green}) = 4, \text{count}(\text{Blue}) = 2$.
1. Zero-Frequency Problem (Without Smoothing):
$$P(\text{Red} \mid C_1) = \frac{0}{6} = 0 \implies \text{Total posterior } P(C_1 \mid \text{Red}, \dots) = 0 \quad (\text{Wipes out all evidence!})$$2. Laplace (Add-1) Smoothing ($k = 3$ attribute values):
$$\mathbf{P(\text{Red} \mid C_1) = \frac{\text{count}(\text{Red}) + 1}{|C_1| + k} = \frac{0 + 1}{6 + 3} = \frac{1}{9} = \mathbf{0.1111}}$$ $$\mathbf{P(\text{Green} \mid C_1) = \frac{4 + 1}{6 + 3} = \frac{5}{9} = \mathbf{0.5556} \qquad P(\text{Blue} \mid C_1) = \frac{2 + 1}{6 + 3} = \frac{3}{9} = \mathbf{0.3333}}$$ $$\mathbf{\text{Sum of Smoothed Probabilities: } \frac{1}{9} + \frac{5}{9} + \frac{3}{9} = \frac{9}{9} = \mathbf{1.0000 \quad (Strictly Valid!)}}}$$A binary classifier produces probabilities for 5 test samples: $(S_1: 0.9, +), (S_2: 0.8, +), (S_3: 0.6, -), (S_4: 0.4, +), (S_5: 0.1, -)$ ($P=3, N=2$):
| Threshold $T$ | Predictions $(\hat{Y})$ | $TP$ | $FP$ | $\text{TPR} = \frac{TP}{3}$ | $\text{FPR} = \frac{FP}{2}$ | ROC Point $(x, y)$ |
|---|---|---|---|---|---|---|
| $> 0.9$ | $[- - - - -]$ | 0 | 0 | $0.00$ | $0.00$ | $(0, 0)$ |
| $0.85$ | $[+ - - - -]$ | 1 | 0 | $0.33$ | $0.00$ | $(0, 0.33)$ |
| $0.70$ | $[+ + - - -]$ | 2 | 0 | $0.67$ | $0.00$ | $(0, 0.67)$ |
| $0.50$ | $[+ + + - -]$ | 2 | 1 | $0.67$ | $0.50$ | $(0.50, 0.67)$ |
| $0.30$ | $[+ + + + -]$ | 3 | 1 | $1.00$ | $0.50$ | $(0.50, 1.00)$ |
| $< 0.1$ | $[+ + + + +]$ | 3 | 2 | $1.00$ | $1.00$ | $(1.00, 1.00)$ |
Area Under the Curve (AUC) by Trapezoidal Rule:
$$\text{AUC} = (0.50 - 0)(0.67) + (1.00 - 0.50)\left(\frac{1.00 + 0.67}{2}\right) = 0.335 + 0.50(0.835) = 0.335 + 0.4175 = \mathbf{0.7525}$$Given 3 support vectors in 2D space: $\mathbf{x}_1 = (1, 1)^T, y_1 = -1$; $\mathbf{x}_2 = (2, 0)^T, y_2 = -1$; $\mathbf{x}_3 = (2, 3)^T, y_3 = +1$:
Given 5 objects with pairwise $L_1$ distances: $P_1(1, 1), P_2(2, 2), P_3(3, 3), P_4(8, 8), P_5(9, 9)$. Initial medoids $M_1 = P_2(2, 2), M_2 = P_4(8, 8)$:
In CART decision trees, the cost-complexity measure for subtree $T$ with parameter $\alpha \ge 0$ is:
$$\mathbf{R_\alpha(T) = R(T) + \alpha |T|}$$Where $R(T)$ is the misclassification error rate and $|T|$ is the number of leaf nodes. By calculating $\alpha = \frac{R(t) - R(T_t)}{|T_t| - 1}$ for each internal node $t$, CART prunes nodes that produce the smallest error increase per leaf saved!
The Radial Basis Function (RBF) kernel is formulated as:
$$\mathbf{K(\mathbf{x}, \mathbf{y}) = \exp\left( - \gamma \|\mathbf{x} - \mathbf{y}\|^2 \right) = \exp\left( - \frac{\|\mathbf{x} - \mathbf{y}\|^2}{2\sigma^2} \right)}$$Maps input points into an infinite-dimensional Hilbert space, allowing linear separation of any arbitrary non-linear dataset!
STING (Statistical Information Grid - Wang et al. 1997) divides spatial area into hierarchical rectangular cells at multiple resolution levels. Stores statistical parameters ($\text{count } n, \text{mean } m, \text{standard deviation } s, \min, \max$, distribution type) in each grid cell. Queries execute in blazing fast $O(K)$ time (where $K$ is number of grid cells at bottom layer), completely independent of total dataset size $N$!
In C4.5, a subtree $T$ with $L$ leaves and $E$ training errors has pessimistic error estimate:
$$\mathbf{E_{\text{pessimistic}}(T) = E + \frac{L}{2} + 1.96 \sqrt{\frac{(E + L/2)(N - E - L/2)}{N}}}$$If the pessimistic error of collapsing the subtree into a single leaf node is lower than keeping the complex subtree, C4.5 prunes the subtree, improving generalization on unseen test data!
Given prior probabilities $P(\text{Play}=\text{Yes}) = \frac{9}{14}, P(\text{Play}=\text{No}) = \frac{5}{14}$, and evidence $X = (\text{Outlook}=\text{Sunny}, \text{Temp}=\text{Cool}, \text{Humidity}=\text{High}, \text{Wind}=\text{Strong})$:
$$P(X \mid \text{Yes}) = \left(\frac{2}{9}\right) \left(\frac{3}{9}\right) \left(\frac{3}{9}\right) \left(\frac{3}{9}\right) = \frac{2 \times 3 \times 3 \times 3}{6561} = \frac{54}{6561} \approx \mathbf{0.00823}$$ $$P(X \mid \text{No}) = \left(\frac{3}{5}\right) \left(\frac{1}{5}\right) \left(\frac{4}{5}\right) \left(\frac{3}{5}\right) = \frac{3 \times 1 \times 4 \times 3}{625} = \frac{36}{625} = \mathbf{0.05760}$$ $$\mathbf{P(X, \text{Yes}) = 0.00823 \times \frac{9}{14} = \mathbf{0.00529} \qquad P(X, \text{No}) = 0.05760 \times \frac{5}{14} = \mathbf{0.02057}}$$ $$\mathbf{\text{Posterior: } P(\text{No} \mid X) = \frac{0.02057}{0.00529 + 0.02057} = \frac{0.02057}{0.02586} = \mathbf{79.54\% \implies \text{Predict: NO PLAY!}}}$$• One-vs-Rest (OvR): Trains $K$ binary classifiers separating class $k$ from all other $K-1$ classes combined. Fast ($K$ models), but sensitive to class imbalance.
• One-vs-One (OvO): Trains $\frac{K(K-1)}{2}$ binary classifiers separating all pairwise combinations. Slower training, but each classifier is trained on balanced subsets!