CS24303 • Module 1

Module 1: Data Understanding & Statistical Proximity

Topics 1 to 14 • KDD Lifecycle, Attributes, Boxplots, Q-Q, Jaccard & Distance Metrics
Module 1 Table of Contents (Topics 1 to 14)
• Topic 1: Data Mining & KDD Lifecycle
• Topic 2: Data Objects & Attribute Types
• Topic 3: Central Tendency (Mean, Median, Mode)
• Topic 4: Dispersion & Five-Number Summary
• Topic 5: Visual Displays (Boxplots, Q-Q Plots)
• Topic 6: Nominal & Binary Proximity (SMC, Jaccard)
• Topic 7: Numeric Distance (Minkowski, Manhattan)
• Topic 8: Cosine & Mahalanobis Metrics
• Topic 9: Mixed Attribute Distance (Gower)
• Topic 10: 15 Solved University Examination Bank

Topic 1 & 2: Data Mining Foundations, KDD Process & Attribute Types

Data Mining is the computational process of discovering valid, novel, potentially useful, and ultimately understandable patterns from massive, complex datasets. It sits at the confluence of Database Systems, Statistics, Machine Learning, Pattern Recognition, and High-Performance Computing.

🏛️ The 7-Stage KDD Process Pipeline (Fayyad et al.)
  1. Data Cleaning: Eliminating noisy, erroneous, and inconsistent records; imputing missing values.
  2. Data Integration: Merging heterogeneous schemas, relational databases, flat files, and real-time data streams into a unified repository.
  3. Data Selection: Retrieving task-relevant subsets from operational repositories.
  4. Data Transformation: Normalizing, aggregating, scaling, and constructing informative features.
  5. Data Mining: Applying intelligent algorithms (Apriori, Decision Trees, k-Means, SVM) to extract patterns.
  6. Pattern Evaluation: Identifying truly interesting patterns using objective interestingness measures (Support, Confidence, Lift).
  7. Knowledge Presentation: Visualizing findings via dashboards and decision support systems.
Attribute Type Mathematical Characteristics Meaningful Operators Real-World Examples
Nominal (Categorical) Values are distinct qualitative categories or names without intrinsic ordering. $=, \neq, \text{Mode}, \text{Entropy}$ `MaritalStatus: {Single, Married, Divorced}`, `BloodType: {A, B, AB, O}`.
Binary (Symmetric vs Asymmetric) Nominal attribute with exactly 2 states ($0, 1$). Symmetric: both states equally important; Asymmetric: presence of state $1$ carries far higher significance than $0$. $=, \neq$, Contingency tables, Jaccard coefficient Symmetric: `Gender: {M, F}`; Asymmetric: `COVID-19_Test: {Positive=1, Negative=0}`.
Ordinal Values possess a meaningful ranked order, but step intervals between adjacent ranks are subjective and unequal. $=, \neq, <, >, \text{Median}, \text{Percentiles}$ `CustomerRating: {Poor, Fair, Good, Excellent}`, `AcademicGrade: {A, B, C, D, F}`.
Numeric: Interval-Scaled Measured on a scale of equal-sized units, but lacks a true physical absolute zero point (zero is an arbitrary convention). $+ , -, \text{Mean}, \text{Variance}$ (Ratios are meaningless!) `Temperature in Celsius / Fahrenheit`, `Calendar Years (2024 CE)`.
Numeric: Ratio-Scaled Measured on a scale with a physically absolute zero point (representing total absence of the measured quantity). $+ , -, \times, \div$, Ratios, Geometric Mean `Salary in USD ($0 = no income)`, `Age`, `Weight in kg`, `Network Bandwidth`.

Topic 3 & 4: Statistical Descriptions of Central Tendency & Dispersion

Comprehensive Central Tendency & Dispersion Formulas: $$\mathbf{\text{Arithmetic Mean: } \bar{x} = \frac{1}{N} \sum_{i=1}^N x_i \qquad \text{Trimmed Mean: Mean after dropping top/bottom } k\% \text{ outliers}}$$ $$\mathbf{\text{Median: Middle value when sorted } x_{(N+1)/2} \quad (\text{Robust to extreme outliers!})}$$ $$\mathbf{\text{Empirical Mean-Median-Mode Relationship for Moderately Skewed Data: } \text{Mean} - \text{Mode} \approx 3(\text{Mean} - \text{Median})}$$ $$\mathbf{\text{Variance: } \sigma^2 = \frac{1}{N} \sum_{i=1}^N (x_i - \bar{x})^2 \qquad \text{Sample Variance: } s^2 = \frac{1}{N-1}\sum_{i=1}^N (x_i - \bar{x})^2}$$ $$\mathbf{\text{Standard Deviation: } \sigma = \sqrt{\sigma^2} \qquad \text{Interquartile Range: } \text{IQR} = Q_3 - Q_1}$$ $$\mathbf{\text{Tukey's Outlier Bounds: } [\text{Lower Fence}, \text{Upper Fence}] = [Q_1 - 1.5 \cdot \text{IQR}, \ Q_3 + 1.5 \cdot \text{IQR}]}$$
🏛️ Step-by-Step Solved Problem: Five-Number Summary & Outlier Detection

Consider the dataset representing monthly engineering salaries (in thousands of dollars):

$$\mathbf{X = \{15, 20, 22, 25, 28, 30, 32, 35, 38, 42, 45, 120\}}$$

1. Five-Number Summary Calculation ($N = 12$):

2. Interquartile Range & Outlier Fences:

$$\text{IQR} = Q_3 - Q_1 = 40.0 - 23.5 = \mathbf{16.5}$$ $$\text{Lower Fence} = Q_1 - 1.5(\text{IQR}) = 23.5 - 1.5(16.5) = 23.5 - 24.75 = \mathbf{-1.25}$$ $$\text{Upper Fence} = Q_3 + 1.5(\text{IQR}) = 40.0 + 1.5(16.5) = 40.0 + 24.75 = \mathbf{64.75}$$ $$\mathbf{\text{Outlier Identification: } 120 > 64.75 \implies \mathbf{120 \text{ is a severe outlier!}}}$$

Topic 6 to 9: Mathematical Proximity & Distance Metrics

Proximity Metric Mathematical Formulation Properties & Applications
Euclidean Distance ($L_2$) $$d(\mathbf{x}, \mathbf{y}) = \sqrt{\sum_{i=1}^p (x_i - y_i)^2} = \|\mathbf{x} - \mathbf{y}\|_2$$ Rotational invariant; sensitive to feature scales and extreme outliers.
Manhattan Distance ($L_1$) $$d(\mathbf{x}, \mathbf{y}) = \sum_{i=1}^p |x_i - y_i| = \|\mathbf{x} - \mathbf{y}\|_1$$ City-block orthogonal grid distance; robust to axis outliers.
Minkowski Distance ($L_h$) $$d(\mathbf{x}, \mathbf{y}) = \left( \sum_{i=1}^p |x_i - y_i|^h \right)^{1/h}$$ Generalization ($h=1 \implies \text{Manhattan}; h=2 \implies \text{Euclidean}; h \rightarrow \infty \implies \text{Chebyshev } L_\infty$).
Cosine Similarity $$\text{sim}(\mathbf{x}, \mathbf{y}) = \frac{\mathbf{x} \cdot \mathbf{y}}{\|\mathbf{x}\|_2 \|\mathbf{y}\|_2} = \frac{\sum x_i y_i}{\sqrt{\sum x_i^2}\sqrt{\sum y_i^2}}$$ Measures orientation angle regardless of document magnitude; ideal for high-dimensional sparse text vectors!
Simple Matching Coeff (SMC) $$\text{SMC} = \frac{q + t}{q + r + s + t}$$ Used for symmetric binary attributes (equal weight to 0-0 and 1-1 matches).
Jaccard Coefficient $$J = \frac{q}{q + r + s} \qquad d_J = 1 - J = \frac{r + s}{q + r + s}$$ Used for asymmetric binary data (ignores irrelevant negative-negative $0-0$ matches $t$).
Mahalanobis Distance $$d_M(\mathbf{x}, \mathbf{y}) = \sqrt{(\mathbf{x} - \mathbf{y})^T \mathbf{\Sigma}^{-1} (\mathbf{x} - \mathbf{y})}$$ Scale-invariant metric accounting for correlations between attributes ($\mathbf{\Sigma}$ is covariance matrix).
🏛️ Step-by-Step Solved Problem: Jaccard vs. SMC on Binary Medical Patient Vectors

Two patient symptom vectors $\mathbf{x} = [1, 0, 0, 1, 1, 0, 1, 0]$ and $\mathbf{y} = [1, 1, 0, 1, 0, 0, 1, 0]$ for 8 rare diseases:

$$\mathbf{\text{Jaccard Similarity: } J(\mathbf{x}, \mathbf{y}) = \frac{q}{q + r + s} = \frac{3}{3 + 1 + 1} = \frac{3}{5} = \mathbf{0.60 = 60\%}}$$ $$\mathbf{\text{Jaccard Distance: } d_J(\mathbf{x}, \mathbf{y}) = 1 - 0.60 = \mathbf{0.40}}$$ $$\mathbf{\text{SMC Similarity: } \text{SMC}(\mathbf{x}, \mathbf{y}) = \frac{q + t}{q + r + s + t} = \frac{3 + 3}{8} = \frac{6}{8} = \mathbf{0.75 = 75\%}}$$

Topic 10: Master University Examination Solved Question Bank (10 Solved Questions)

Q1. Differentiate between OLTP (Online Transaction Processing) and Data Mining / OLAP. (8 Marks)
FeatureOLTPData Mining / OLAP
PurposeReal-time day-to-day transaction processing (ACID compliance).Long-term strategic decision support, pattern discovery.
Data ModelHighly normalized relational tables (3NF/BCNF) to eliminate redundancy.De-normalized multidimensional Star / Snowflake schemas.
QueriesSimple, fast indexed read/write transactions (`SELECT/UPDATE by ID`).Complex multi-table aggregations (`GROUP BY, ROLLUP, CUBE`).
Access PatternHigh concurrency, continuous write/update.Read-only periodic batch ETL loads from historical data.
Q2. Calculate the Cosine Similarity between document vectors $\mathbf{d_1} = (5, 0, 3, 0, 2, 0, 0, 2, 0, 0)$ and $\mathbf{d_2} = (3, 0, 2, 0, 1, 1, 0, 1, 0, 1)$. (8 Marks)
1. Dot Product: $\mathbf{d_1} \cdot \mathbf{d_2} = (5\times 3) + 0 + (3\times 2) + 0 + (2\times 1) + 0 + 0 + (2\times 1) + 0 + 0 = 15 + 6 + 2 + 2 = \mathbf{25}$.
2. Vector Magnitudes:
$\|\mathbf{d_1}\| = \sqrt{5^2 + 3^2 + 2^2 + 2^2} = \sqrt{25 + 9 + 4 + 4} = \sqrt{42} \approx 6.4807$.
$\|\mathbf{d_2}\| = \sqrt{3^2 + 2^2 + 1^2 + 1^2 + 1^2 + 1^2} = \sqrt{9 + 4 + 1 + 1 + 1 + 1} = \sqrt{17} \approx 4.1231$.
$$\mathbf{\text{Cosine Similarity} = \frac{25}{\sqrt{42}\sqrt{17}} = \frac{25}{6.4807 \times 4.1231} = \frac{25}{26.7206} = \mathbf{0.9356 = 93.56\%}}$$
Q3. Explain Gower's General Dissimilarity Coefficient for Mixed Attribute Datasets. (8 Marks)
When records contain a combination of nominal, symmetric/asymmetric binary, ordinal, and numeric attributes, Gower's Metric computes distance as: $$\mathbf{d(i, j) = \frac{\sum_{f=1}^p \delta_{ij}^{(f)} d_{ij}^{(f)}}{\sum_{f=1}^p \delta_{ij}^{(f)}}}$$ Where $\delta_{ij}^{(f)} = 1$ if both records have valid non-missing values for feature $f$ (and $\delta_{ij}^{(f)} = 0$ for asymmetric binary 0-0 matches). The per-feature distance $d_{ij}^{(f)}$ is: - Nominal/Binary: $0$ if $x_{if} = x_{jf}$, else $1$. - Numeric: $d_{ij}^{(f)} = \frac{|x_{if} - x_{jf}|}{\max(f) - \min(f)}$ (normalized to $[0, 1]$). - Ordinal: Convert ranks to $z_{if} = \frac{r_{if} - 1}{M_f - 1}$ and treat as numeric.
Q4. Explain Quantile-Quantile (Q-Q) Plots and their diagnostic utility in Data Mining. (6 Marks)
A Q-Q Plot graphs the quantiles of an empirical dataset distribution against the theoretical quantiles of a standard distribution (e.g. Standard Normal $\mathcal{N}(0, 1)$) or against a second dataset. If the points fall strictly along the $45^\circ$ reference line $y = x$, the two distributions have identical shapes. Deviations from the straight line expose heavy tails (leptokurtosis), light tails, right skew, or bimodality.
Q5. Why is Euclidean Distance ineffective in high-dimensional sparse spaces (Curse of Dimensionality)? (8 Marks)
In high-dimensional spaces ($p \rightarrow \infty$), the ratio of the distance to the nearest neighbor and the distance to the furthest neighbor approaches 1: $$\mathbf{\lim_{p \rightarrow \infty} \frac{D_{\text{max}} - D_{\text{min}}}{D_{\text{min}}} \rightarrow 0}$$ All data points become equidistant from each other in $L_2$ space! Furthermore, high dimensions dilute dense clusters into vast empty space ($V_{\text{hypersphere}} \rightarrow 0$), causing distance-based algorithms like k-NN and k-Means to degrade into random guessing unless dimensionality reduction (PCA, t-SNE) or Cosine similarity is applied!

Topic 11: Higher-Order Statistical Moments & Skewness / Kurtosis

Statistical Moment Mathematical Formulation Diagnostic Significance
1st Raw Moment (Mean) $$\mu_1' = \mathbb{E}[X] = \frac{1}{N}\sum x_i$$ Center of mass / location of the distribution.
2nd Central Moment (Variance) $$\mu_2 = \mathbb{E}[(X - \mu)^2] = \sigma^2$$ Spread / scale of dispersion around the mean.
3rd Standardized Moment (Skewness) $$\gamma_1 = \mathbb{E}\left[\left(\frac{X - \mu}{\sigma}\right)^3\right] = \frac{\mu_3}{\sigma^3}$$ Asymmetry of distribution ($\gamma_1 > 0 \implies \text{Right/Positive Skew}$; $\gamma_1 < 0 \implies \text{Left/Negative Skew}$).
4th Standardized Moment (Kurtosis) $$\text{Excess Kurtosis } \gamma_2 = \frac{\mu_4}{\sigma^4} - 3$$ Tailedness and outlier propensity ($\gamma_2 > 0 \implies \text{Leptokurtic / Heavy-tailed}$; $\gamma_2 < 0 \implies \text{Platykurtic / Light-tailed}$).
🏛️ Step-by-Step Solved Problem: Spearman's Rank Correlation Calculation

Two data mining algorithms rank 5 customer profiles by risk score:

CustomerAlgorithm A Rank ($R_A$)Algorithm B Rank ($R_B$)$d_i = R_A - R_B$$d_i^2$
C112$-1$1
C221$+1$1
C334$-1$1
C443$+1$1
C555$0$0
Total——$\sum d_i = 0$$\mathbf{\sum d_i^2 = 4}$
$$\mathbf{r_s = 1 - \frac{6 \sum d_i^2}{n(n^2 - 1)} = 1 - \frac{6(4)}{5(25 - 1)} = 1 - \frac{24}{5(24)} = 1 - \frac{24}{120} = 1 - 0.20 = \mathbf{+0.80}}$$ $$\mathbf{\text{Conclusion: Strong positive monotonic agreement between the two ranking algorithms!}}$$
Q6. State and prove Chebyshev's Inequality and explain its application in Outlier Detection. (8 Marks)
Chebyshev's Theorem: For any random variable $X$ with mean $\mu$ and finite variance $\sigma^2$, the probability that $X$ deviates from its mean by at least $k$ standard deviations is bounded by: $$\mathbf{P(|X - \mu| \ge k\sigma) \le \frac{1}{k^2}}$$ Application: Unlike the Empirical Rule (which strictly requires a Gaussian bell curve), Chebyshev holds for ANY arbitrary probability distribution. For $k = 3$, at most $\frac{1}{3^2} = \frac{1}{9} \approx 11.11\%$ of observations can lie outside $[\mu - 3\sigma, \mu + 3\sigma]$. Any data point beyond $3\sigma$ is a candidate outlier!
Q7. Explain Dynamic Time Warping (DTW) for Time-Series Distance Measurement. (8 Marks)
Standard Euclidean distance requires two time-series sequences to have identical lengths and aligned time steps, failing when sequences are shifted in phase or time-dilated (e.g. someone speaking slowly vs quickly).
Dynamic Time Warping (DTW): Uses dynamic programming to find an optimal non-linear alignment (warping path $W = w_1, w_2, \dots, w_K$) on a cost matrix $C(i, j) = |x_i - y_j|$, satisfying boundary conditions, continuity, and monotonicity ($D(i, j) = C(i, j) + \min(D(i-1, j), D(i, j-1), D(i-1, j-1))$).

Topic 13: Advanced Proximity Matrices & Multidimensional Scaling (MDS)

🏛️ Step-by-Step Solved Problem: Constructing Full Dissimilarity Matrix

Consider 4 data objects in 2D space: $x_1 = (1, 2), x_2 = (3, 5), x_3 = (2, 0), x_4 = (4, 2)$. Construct the complete $4 \times 4$ Euclidean Dissimilarity Matrix $\mathbf{D}$:

$$\mathbf{\mathbf{D} = \begin{pmatrix} 0 & 3.606 & 2.236 & 3.000 \\ 3.606 & 0 & 5.099 & 3.162 \\ 2.236 & 5.099 & 0 & 2.828 \\ 3.000 & 3.162 & 2.828 & 0 \end{pmatrix}}$$
Q8. Explain Multidimensional Scaling (MDS) and Metric vs Non-metric MDS. (8 Marks)
Multidimensional Scaling (MDS) is a non-linear dimensionality reduction technique that takes an arbitrary pairwise dissimilarity matrix $\mathbf{D} \in \mathbb{R}^{N \times N}$ and maps the $N$ objects into a low-dimensional Euclidean space $\mathbb{R}^k$ ($k=2$ or $3$) such that Euclidean distances in the embedding $\hat{d}_{ij} = \|\mathbf{y}_i - \mathbf{y}_j\|$ preserve the original input dissimilarities $\delta_{ij}$ as faithfully as possible.
• Metric MDS: Minimizes Kruskal's Stress: $\text{Stress} = \sqrt{\frac{\sum (\delta_{ij} - \hat{d}_{ij})^2}{\sum \hat{d}_{ij}^2}}$.
• Non-Metric MDS: Preserves only the rank order of distances ($\delta_{ij} < \delta_{kl} \implies \hat{d}_{ij} < \hat{d}_{kl}$) using isotonic monotonic regression.

Topic 14: Master University Exam Problem Bank (Part II)

🏛️ Solved Problem 1: Mahalanobis Distance vs. Euclidean Distance with Covariance

Given 2 data points $\mathbf{x} = (1, 2)^T, \mathbf{y} = (4, 6)^T$ in 2D space with empirical covariance matrix $\mathbf{\Sigma} = \begin{bmatrix} 4 & 2 \\ 2 & 9 \end{bmatrix}$:

1. Standard Euclidean Distance:

$$\mathbf{d_E(\mathbf{x}, \mathbf{y}) = \sqrt{(4-1)^2 + (6-2)^2} = \sqrt{3^2 + 4^2} = \sqrt{9 + 16} = \sqrt{25} = \mathbf{5.000}}$$

2. Mahalanobis Distance:

$$\mathbf{d_M(\mathbf{x}, \mathbf{y}) = \sqrt{3.03125} = \mathbf{1.741}}$$

Interpretation: Because the two features are positively correlated ($\text{Cov}=2$), the effective statistical distance is significantly smaller ($1.741$) than the naive geometric Euclidean distance ($5.000$)!

Q9. Explain the Difference between Exploratory Data Analysis (EDA) and Confirmatory Data Analysis (CDA). (8 Marks)
• Exploratory Data Analysis (EDA - John Tukey): An open-ended, inductive approach that uses graphical displays (boxplots, scatter matrices, histograms) and non-parametric summary statistics to uncover unexpected patterns, detect anomalies, test underlying assumptions, and generate novel hypotheses without preconceived probabilistic models.
• Confirmatory Data Analysis (CDA): A deductive, hypothesis-driven approach that uses formal statistical inference tests ($t$-tests, ANOVA, $\chi^2$ independence tests, $p$-values) to evaluate the statistical significance of specific a priori hypotheses.
Q10. Detail the Properties of Metric Distance Functions (Identity, Symmetry, Triangle Inequality). (6 Marks)
A valid mathematical distance metric $d(x, y)$ must satisfy 4 fundamental axioms:
1. Non-negativity: $d(x, y) \ge 0$.
2. Identity of Indiscernibles: $d(x, y) = 0 \iff x = y$.
3. Symmetry: $d(x, y) = d(y, x)$.
4. Triangle Inequality: $d(x, z) \le d(x, y) + d(y, z)$ for all points $x, y, z$. (Cosine distance $1 - \text{sim}$ violates triangle inequality and is therefore a semi-metric).

Topic 15: Master University Exam Problem Bank (Part III)

🏛️ Solved Problem 3: Complete Five-Number Summary & Skewness Analysis on Examination Scores

Consider the final examination marks of 16 engineering students:

$$\mathbf{X = \{35, 42, 48, 52, 56, 58, 60, 62, 65, 68, 72, 75, 78, 82, 88, 98\}}$$

1. Five-Number Summary ($N = 16$):

2. Interquartile Range & Outlier Boundaries:

$$\text{IQR} = Q_3 - Q_1 = 76.5 - 54.0 = \mathbf{22.5}$$ $$\text{Lower Outlier Fence} = 54.0 - 1.5(22.5) = 54.0 - 33.75 = \mathbf{20.25}$$ $$\text{Upper Outlier Fence} = 76.5 + 1.5(22.5) = 76.5 + 33.75 = \mathbf{110.25}$$ $$\mathbf{\text{Conclusion: All data points lie within } [20.25, 110.25] \implies \mathbf{\text{Zero Outliers Present!}}}$$
Q11. Explain Pearson's Mode Skewness and Bowley's Quartile Skewness Coefficient. (8 Marks)
• Pearson's Mode Skewness: $S_k = \frac{\text{Mean} - \text{Mode}}{\sigma} \approx \frac{3(\text{Mean} - \text{Median})}{\sigma}$. Measures asymmetry standardized by standard deviation.
• Bowley's Quartile Skewness (Galton's Coefficient): $$\mathbf{B_q = \frac{(Q_3 - Q_2) - (Q_2 - Q_1)}{(Q_3 - Q_2) + (Q_2 - Q_1)} = \frac{Q_3 + Q_1 - 2Q_2}{Q_3 - Q_1}}$$ $B_q \in [-1, +1]$. $B_q > 0 \implies \text{Right Skew}$; $B_q = 0 \implies \text{Symmetric}$; $B_q < 0 \implies \text{Left Skew}$. Robust to extreme outliers because it depends solely on quartiles!