Skip to main content
Machine Learning

Gaussian Mixture Models and Support Vector Machines

📅 Published: 2026-06-30
🎓 Level: postgraduate
👥 Audience: Postgraduate students in Machine Learning

Prerequisite Knowledge

This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.

Previously Covered in This Subject

  • K-Means Clustering — covered in Lecture 15. GMM is a direct extension of K-means into a probabilistic framework. The E-step/M-step structure carries forward directly from K-means to GMM.
  • Gaussian Mixture Model Preview — covered in Lecture 15. The soft vs. hard clustering distinction and the basic idea of mixture models were introduced.
  • Binary Classification (Logistic Regression) — covered in Lecture 7. SVM solves the same classification task but with a different principle: finding the maximum-margin separator instead of fitting a sigmoid.
  • Optimization Fundamentals — covered in Lectures 3–6. The SVM primal problem is a constrained quadratic optimization; familiarity with gradient-based optimization and Lagrangian multipliers from earlier lectures is assumed.

Gaussian Mixture Models and Support Vector Machines

This lecture covers two major machine learning approaches. The first half introduces Gaussian Mixture Models (GMM) — a soft clustering technique that extends K-means into a probabilistic framework. The second half introduces Support Vector Machines (SVM) — a supervised classification algorithm that finds the hyperplane with the maximum separating margin between classes. Both are foundational tools used across data science, from customer segmentation to medical diagnosis.

16.1 Context — From K-Means to Gaussian Mixture Models

What if your clusters overlap — if a data point could reasonably belong to two groups at once? K-means forces a binary yes/no answer. GMM gives a richer answer: "85% this group, 10% that group, 5% the other." This section builds the bridge from hard clustering to soft, probabilistic clustering.

16.1.1 Recap of K-Means Clustering

K-means is a clustering algorithm. It groups data objects into clusters by allocating every data object to exactly one cluster — "this point belongs to cluster one, that point belongs to cluster two." This assignment may change across iterations, but at every moment the algorithm declares a definite, exclusive cluster membership for each point.

This is called hard clustering. Each point gets a binary label: in or out. There is no middle ground.

The K-means algorithm works by minimizing a distortion measure: the sum of squared distances from each point to its assigned cluster center. It alternates between two steps: (E-step) assign each point to the nearest center, and (M-step) recompute each center as the mean of its assigned points. This two-stage iteration repeats until assignments stop changing. The same E-step/M-step language carries forward to GMM, which is why the professor introduces it: "It is exactly K-means extension. That is why we learned K-means first."

K-means objective (distortion measure): where is a binary indicator — 1 if point is assigned to cluster , 0 otherwise. is the center (prototype) of cluster . This is the standard formulation from the reference text (Bishop §9.1).

16.1.2 Why Remove Duplicates Before Clustering

Pitfall: Running clustering on data with many duplicate records biases the statistical description of the data.

If you have 100 copies of one record and 100 unique records, the mean gets pulled toward the repeated values. That one repeated record gains disproportionately large influence. The statistical description — the mean, the spread — gets warped, and from there it influences everything downstream: cluster centers, variance estimates, and ultimately the cluster assignments themselves. The professor emphasized: "The statistical description itself gets warped, and from there it influences everything downstream."

16.1.3 Introducing Gaussian Mixture Models (GMM)

A Gaussian Mixture Model (GMM) is a probabilistic model for clustering. Unlike K-means, which groups points by distance, GMM assumes that all data points are generated from a mixture of several Gaussian (bell-curve) distributions with unknown parameters.

The professor's central analogy is reverse engineering:

"If I had to recreate this exact dataset using a few bell curves, where would I place those bell curves? How wide would they be?"

If you try to draw a single Gaussian through the entire dataset, it will not capture the underlying structure. But if the data has distinct groups, you can place one Gaussian over each group. The question GMM answers is: where should these Gaussians go, how wide should they be, and how much does each one contribute?

A Gaussian Mixture Model with components has the probability density: where is the mixing coefficient (weight) of component , satisfying , and is the multivariate Gaussian PDF with mean and covariance . This is the standard formulation from Bishop §9.2.

16.1.4 Why Not a Single Gaussian?

Imagine a dataset of adult heights in a city. The data comes from two underlying distributions — men's heights (mean ~175 cm) and women's heights (mean ~162 cm). A person who is 168 cm tall could be a tall woman or an average-height man. A single Gaussian would smear both groups into one blob, losing this structure. You need two overlapping bell curves.

This height example is not just pedagogical — it is a classic real-world use of GMM: discovering latent groups (male/female) from unlabeled data without ever knowing the gender labels. GMM captures this by modeling the data as coming from multiple distributions, each with its own mean, variance, and weight.

K-means asks "which cluster?" with a binary answer. GMM asks "how much of each cluster?" with probabilities. This soft assignment is the fundamental upgrade — and it lets GMM handle overlapping, elliptical clusters that K-means cannot.

16.2 Gaussian Mixture Model — Core Concepts

Think of a dart board with two bullseyes. Some darts cluster around the first bullseye, some around the second, and a few land in between. Hard clustering forces you to assign each dart to exactly one bullseye. Soft clustering (GMM) lets you say: "This dart is 70% from player A, 30% from player B." Now imagine the dart clusters aren't even round — they're oval-shaped because one player throws with a sideways drift. GMM handles that too.

16.2.1 Hard Clustering vs. Soft Clustering

TypeAlgorithmBehaviorAnalogy
Hard clusteringK-meansA point belongs to cluster A OR cluster B — definite, exclusiveA passport: you are a citizen of exactly one country
Soft clusteringGMMA point can be 85% cluster A, 10% cluster B, 5% cluster CA pie chart of your ancestry: you can be part Italian, part Irish

In GMM, the same data point can belong to multiple clusters with different probabilities. This is especially useful for points near the boundaries of overlapping Gaussians, where forcing a binary assignment would be arbitrary. The professor phrased it this way: "What if a point has equal probability of belonging to two clusters? It's very unlikely that probability is exactly equal, but if it happens, you decide. It doesn't matter."

16.2.2 Flexibility in Cluster Shape

K-means has one implicit assumption that severely limits it: clusters are spherical. GMM lifts this restriction.

K-means only cares about the Euclidean distance from each center. It assumes equal variance in all directions — clusters are circles (in 2D) or spheres (in higher dimensions). If you have two elongated, cigar-shaped clusters that overlap, K-means cannot identify them correctly. It will cut through them with a straight bisector and produce wrong assignments.

GMM is more flexible because it models three things per component:

  • Mean — the center of each Gaussian (same idea as K-means centroids).
  • Variance — how much a single variable spreads around the mean. Large variance = wide bell curve.
  • Covariance — how two variables move together. If height and weight are positively correlated (taller people tend to be heavier), the covariance captures that tilt.

The covariance matrix encodes both variances and covariances:

  • Diagonal entries (): variance along each axis — controls spread.
  • Off-diagonal entries (): covariance between axes — controls tilt and shape.

Together, these parameters allow GMM to form elliptical clusters of arbitrary orientation, not just circles. The bell curve can be stretched, squeezed, and rotated to fit the data.

Visual intuition: Imagine looking down from above at the bell curves (the professor's "top view"). For a circular cluster, the contour lines are concentric circles — like a target. For an elliptical cluster, the contours are concentric ellipses — like a tilted stretched target. GMM can produce either shape depending on the covariance matrix.

16.2.3 The Core Idea — Data as a Mixture of Gaussians

The fundamental assumption of GMM: the dataset is an additive mixture — a weighted sum of contributions from multiple Gaussian distributions.

If the data has three distinct groups, GMM assumes three separate underlying Gaussians. The final dataset is a combination (mixture) of points drawn from these three curves. Some points come from Gaussian 1, some from Gaussian 2, some from Gaussian 3. The mixing coefficient tells you what fraction of all data points come from Gaussian .

The professor contrasted this with models that assume all data comes from a single distribution: "This is fundamentally different from models that assume all data comes from a single distribution or a single group."

Scope: GMM assumes the data is generated from a finite mixture of Gaussians. If the true data distribution is not well-approximated by a sum of bell curves — for instance, it has sharp cutoffs, exponential tails, or uniform segments — GMM may need many components to fit well. It may even be the wrong model entirely. GMM also assumes the number of components is known in advance — choosing is a separate problem covered in §16.6.
GMM upgrades K-means in two ways: (1) soft probabilistic assignments instead of hard binary ones, and (2) elliptical cluster shapes instead of only spherical ones. The cost: you now need to fit means, covariances, and mixing weights — more parameters, more computation, but far more expressive clusters.

16.3 The GMM Algorithm — Expectation-Maximization

How do you find the best Gaussians when you don't know which points belong to which Gaussian — and you don't know where the Gaussians are? It sounds like a chicken-and-egg problem. The EM algorithm solves it by cycling between "guess which points go where" and "recenter the Gaussians based on the guess." Each cycle improves the fit.
Purpose: The Expectation-Maximization (EM) algorithm finds the maximum-likelihood estimates of the GMM parameters ( for all ) when the cluster assignments are unknown (latent). It is the standard algorithm for fitting Gaussian mixture models.
Inputs & Outputs:
  • Input: Dataset of points; number of components .
  • Output: For each component : mean , variance , mixing weight . Plus soft assignments (responsibilities ) for every point.

16.3.1 Algorithm Overview (Conceptual)

The EM algorithm for GMM alternates between two steps. The professor described them with a coloring analogy that captures the intuition perfectly:

  1. Initialization — Start with random Gaussians. Pick values for the mean () and standard deviation () for each Gaussian you assume exists. If , pick .
  2. E-step (Expectation) — "Color the points." For every data point, calculate what percentage it belongs to each Gaussian. A point may be 99% blue (component 1) and 1% green (component 2). No point is ever 100% one cluster — that is the fundamental difference from K-means.
  3. M-step (Maximization) — "Recalculate the Gaussians." Using the points now assigned (with their percentage weights), recompute the mean, variance, and mixing weight for each Gaussian. The Gaussians shift closer to the data they represent.
  4. Repeat until convergence — when assignments stop changing between two consecutive iterations.

16.3.2 Visual Analogy — The "Coloring" Process

The professor drew concentric circles to represent each Gaussian — these are the "top view" of bell curves, as if looking down from above. The circles represent contours of equal probability density.

Initially, the Gaussians are placed randomly. Points closer to Gaussian 1 get colored mostly blue. Points closer to Gaussian 2 get colored mostly green. Points equally close get half-and-half.

After coloring, the Gaussians are recalculated — they move to better fit the points assigned to them. Then the coloring changes because the Gaussians moved. This cycle continues until stable.

"If you understood the concept, it is very easy, but if you simply try to by-heart the formula 100 percentage, you will miss one or other step. What is that coloring example? Keep in mind, we can do that. You'll be able to solve any given problem."

16.3.3 Formal Algorithm Steps

Step 1 — Initialization:

Choose the number of Gaussians . Randomly initialize parameters for each Gaussian :

  • Mean (in 1D; or vector in multivariate)
  • Variance (in 1D; or covariance matrix in multivariate)
  • Mixing coefficient (start with equal weights)

In practice, Python libraries like scikit-learn run K-means first to get good initial centers, then use the resulting cluster means, covariances, and proportions as the starting GMM parameters.

Step 2 — E-step (Expectation): Compute responsibilities

The responsibility is the probability that data point belongs to component :

What each part means:

  • Numerator: — "prior weight of cluster " times "how likely point is under Gaussian ."
  • Denominator: sum of the same quantity over ALL clusters — normalizes so that for each point .
  • Result: For each point , you get a probability distribution over the clusters. always.

This formula is Bayes' theorem in action: it computes the posterior probability of cluster membership given the data. In Bishop's notation (§9.2), this is , the responsibility of component for data point .

Step 3 — M-step (Maximization): Update parameters using weighted data

Why each update makes sense:

  • New mean: A weighted average of all data points, where each point's contribution is weighted by — how strongly it belongs to cluster . Points that are 95% in cluster pull the mean much harder than points that are 5% in cluster .
  • New variance: A weighted variance — same weighting logic. Measures the spread of points around the new mean, weighted by membership strength.
  • New mixing coefficient: The average responsibility across all points. If many points belong strongly to cluster , will be large; if cluster is tiny, will be small. This is exactly: total effective points in cluster divided by .
Step 4 — Convergence check:

Stop when the log-likelihood of the data stops improving significantly:

where is the log-likelihood of the observed data under the current GMM parameters, and is a small threshold (e.g., ).

Equivalent stopping conditions: parameters change by less than ; no point changes its most-likely cluster assignment between iterations. All three are practically telling the same thing — the model has stopped improving.

Trace on a tiny dataset:

Consider points: with .

Initialization: ; .

E-step (Iteration 1): Compute for each point using the responsibility formula.

  • Point 0: close to , far from ,
  • Point 3: close to , far from ,

M-step (Iteration 1): Recompute means using weighted averages.

— shifted right toward its data.

shifts left toward . The Gaussians tighten around their respective clusters.

Convergence: In the next E-step, the cluster assignments (0,1 → C1; 2,3 → C2) do not change, so the algorithm stops after 2 iterations. The full worked example is in §16.5.

Pitfalls:
  1. Local optima: EM is not guaranteed to find the global maximum of the likelihood. Different random initializations can lead to different final clusterings. In practice, run EM multiple times with different starting points and keep the best result (highest log-likelihood).
  2. Singularities: If a Gaussian component collapses onto a single data point, its variance can shrink to zero and the likelihood can blow up to infinity. This is a known issue with maximum-likelihood GMM (Bishop §9.2.1). Using a small regularization on the covariance or a Bayesian approach avoids this.
  3. Slow convergence: EM can take many iterations when clusters overlap heavily. The log-likelihood often improves rapidly in early iterations and then plateaus — don't mistake the plateau for convergence.
EM is the engine behind GMM. The E-step computes soft assignments (responsibilities). The M-step re-estimates parameters using those weighted assignments. Rinse and repeat. The professor's key insight: "Keep the coloring picture in mind and you'll be able to solve any given problem."

16.4 GMM — Mathematical Foundation

16.4.1 1D Gaussian Probability Density Function

The Gaussian (normal) probability density function (PDF) in one dimension, with mean and variance :

Every symbol named:

  • (mu) — the mean, the center of the bell curve. "The average height."
  • (sigma) — the standard deviation, controls the spread. Larger = wider, flatter bell.
  • — the variance, the square of the standard deviation. "The spread of the heights."
  • — the normalization constant. Ensures the total area under the curve equals 1.
  • — the exponential kernel. Measures how far is from , scaled by the variance. When , this equals 1 (maximum). When is far from , this drops toward 0.

The professor's plain-language summary: "The average height is the mean. The spread of the heights is the variance."

In 1D: the parameter is variance (). In multivariate: the parameter is covariance ().

16.4.2 Multivariate Gaussian Probability Density Function

For -dimensional data :

Every symbol named:

  • — number of dimensions (features). For 2D data like height and weight, .
  • — a data point, a vector of length .
  • — the mean vector, also length . The center in -dimensional space.
  • — the covariance matrix. Replaces the scalar from 1D. Its diagonal holds variances; off-diagonals hold covariances.
  • — the inverse of the covariance matrix (the precision matrix).
  • — the determinant of . A scalar measuring the "volume" of the covariance ellipsoid.
  • — the squared Mahalanobis distance. This is the multivariate generalization of . It measures distance from to in units of the covariance, accounting for correlations between dimensions.

Visual intuition: In 2D, determines the shape of equal-probability contours. When (scaled identity), contours are circles. When has different diagonal values, contours are axis-aligned ellipses. When has non-zero off-diagonals, contours are rotated ellipses. The Mahalanobis distance is constant along each contour.

16.4.3 The GMM Probability Density Function

The overall PDF of a GMM with components is an additive mixture — a weighted sum of Gaussian densities: For the 1D case (exam-relevant): The mixing coefficients must satisfy:

Why these constraints? is the prior probability that a randomly chosen data point comes from component . As probabilities, they must sum to 1 and each must be non-negative.

The professor emphasized: "This is the formula you need to remember." is the probability density at position — it tells you how likely you are to find a data point at that location. represents the weight or relative size of each cluster. If cluster 1 is large (more data points), might be 0.7 and might be 0.3.

Derivation from the latent-variable viewpoint (Bishop §9.2): Each data point has an unobserved (latent) variable indicating which component generated it. uses a 1-of- encoding: if point came from component , 0 otherwise. The joint distribution is . Marginalizing over gives the mixture: . This latent-variable formulation is what makes the EM algorithm possible.

16.4.4 Symbol Registry — GMM (1D)

SymbolMeaningTypeDomain
Number of Gaussian components (clusters)integer
Mixing coefficient (weight) of component scalar,
Mean of Gaussian scalar
Variance of Gaussian scalar
Responsibility — probability point belongs to component scalar,
Number of data pointsinteger
Gaussian PDF evaluated at scalar
The GMM is a weighted sum of Gaussians. The mixing coefficients are probabilities that sum to 1. Each component has its own and . This is the mathematical statement of "the data comes from multiple bell curves added together."

16.5 GMM — Worked Example

This is the canonical exam-style problem. Work through every calculation step. The professor stated explicitly that 1D problems are what you should expect — 2D requires too much hand computation.

16.5.1 Problem Setup

Data: Four points: , , ,

Goal: Fit a mixture of Gaussian components. Run one full iteration of EM (E-step + M-step).

16.5.2 Step 1 — Initialization

Initial parameter guesses:
  • Component 1 (C1): (mean of ), ,
  • Component 2 (C2): (mean of ), ,

The professor noted: "It's not completely random. Python has its own ways of calculating the initial mean. Variance we assume as 1." This is akin to K-means initialization — picking sensible starting points based on domain knowledge.

16.5.3 Step 2 — E-step: Compute Responsibilities

For each point , compute the Gaussian likelihood under each component, then the responsibility .

Gaussian PDF formula:

With :

For :

For :

For (by symmetry with ):

For (by symmetry with ):

Summary of responsibilities (using the approximate values shown in lecture):

Point (C1) (C2)Dominant cluster
00.950.05C1 (strong)
10.800.20C1 (moderate-to-strong)
20.200.80C2 (moderate-to-strong)
30.050.95C2 (strong)

Sense check: Points 0 and 1 are closer to → mostly C1. Points 2 and 3 are closer to → mostly C2. The boundary points (1 and 2) have more mixed responsibilities than the extremes (0 and 3). The probabilities for each point sum to 1. ✓

The lecture used rounded values (0.95, 0.80, 0.20, 0.05). The precise values from the Gaussian PDF evaluation are (0.9526, 0.7311, 0.2689, 0.0474). The course slide reported — this corresponds to the more precise responsibilities. Using the rounded values gives . Both approaches are acceptable; the exam will test your ability to apply the formulas, not the precision of your arithmetic.

16.5.4 Step 3 — M-step: Update Parameters

Update (weighted average):

Using the precise responsibilities:

Using the lecture's approximate values (0.95, 0.80, 0.20, 0.05):

Update :

By symmetry,

With approximate values:

Update (weighted variance):

Using and precise responsibilities:

The variance has shrunk from 1.0 to ~0.62 — the cluster is tightening around its data.

Update mixing coefficients:

The mixing coefficients stay at 0.5 because the responsibilities are symmetric.

Parameter movement after iteration 1:

ParameterInitialAfter Iteration 1Direction
0.5~0.68–0.71→ shifted right toward its data
2.5~2.29–2.33← shifted left toward its data
1.0~0.62↓ tightened around cluster
1.0~0.62↓ tightened around cluster
0.50.5unchanged (symmetric data)
0.50.5unchanged (symmetric data)

16.5.5 Step 4 — Repeat Until Convergence

The E-step and M-step are repeated. In this example, after one iteration the most-likely cluster assignments are already correct (0,1 → C1; 2,3 → C2). Running the E-step again with the updated parameters produces the same hard assignments, so the algorithm converges.

For larger datasets with more overlap, multiple iterations are needed. In general, stop when:

  • The log-likelihood change (e.g., ), or
  • Parameter changes are below threshold, or
  • Cluster assignments stop changing.

The mixing coefficients stayed at 0.5 each for this symmetric example, but in asymmetric real datasets, values shift to reflect the relative sizes of the discovered clusters.

After one EM iteration, both Gaussian means moved toward their natural clusters ( shifted right, shifted left), and both variances shrank (the clusters became tighter). The algorithm stops when these movements become negligible. Final answer: after convergence, (centered on ), (centered on ), (quarter of initial variance), .

16.6 GMM — Practical Considerations

16.6.1 Choosing the Number of Components

"How many clusters are in my data?" is one of the hardest questions in unsupervised learning. GMM doesn't answer it — you must choose . These are the tools to make that choice.

Methods shared with K-means:

  1. Elbow method — Run GMM for and plot the log-likelihood (or BIC/AIC). The curve typically rises sharply at first, then bends like an elbow. Pick the at the bend — after that point, adding more components gives diminishing returns.
  2. Silhouette analysis — For each point, compute the silhouette score: , where is the mean distance to points in the same cluster, and is the mean distance to points in the nearest other cluster. Values range from (wrong cluster) to (well-clustered). Average across all points and pick the that maximizes the average silhouette.
  3. Cross-validation — Split the data, train GMM on folds, evaluate log-likelihood on held-out data. Pick the that gives the best held-out likelihood.

Methods specific to GMM:

4. Bayesian Information Criterion (BIC): 5. Akaike Information Criterion (AIC): Where:
  • — the maximized likelihood of the model (how well it fits). Larger = better fit, so is smaller for better fit.
  • — the total number of free parameters. For GMM with components in dimensions: means (), covariances ( for full covariance), and mixing coefficients (, since they sum to 1).
  • — number of data points.
  • Lower BIC or AIC is better.

The difference: BIC penalizes complexity more heavily ( vs. 2), so it favors simpler models for large . AIC tends to select slightly more complex models.

Procedure: Run GMM for . For each , record the BIC and AIC scores. Plot them. Pick the that minimizes the score. The scores come directly from the GMM fitting output — Python's sklearn.mixture.GaussianMixture provides both .bic() and .aic() methods.

16.6.2 Initialization Strategies

Pitfall: Random initialization can trap EM in poor local optima. Good initialization matters — it can mean the difference between finding meaningful clusters and getting nonsense.
  1. Random initialization — Pick random and . Simple but unreliable. Run multiple times with different seeds and keep the best result (highest log-likelihood).
  2. Hierarchical splitting — Start with (a single Gaussian over all data). Find the component with the largest variance and split it into two. Repeat until you reach the desired . Analogous to choosing the two farthest centroids in K-means initialization.
  3. K-means first, then GMM (recommended) — This is what scikit-learn does by default:
    • Run K-means with the desired .
    • Set initial = centroid of K-means cluster .
    • Set initial = sample covariance of points in cluster .
    • Set initial = (points in cluster ) / (total points).
    K-means is fast and gives sensible starting positions. EM then refines from there, adding soft assignments and elliptical shapes.

16.6.3 Convergence Criteria

All three are equivalent in practice — they detect when the model has stopped improving:

  1. Parameter change below threshold — Stop when , , and for all .
  2. Log-likelihood change below threshold — The most principled approach. Stop when: where is the log-likelihood. Typical .
  3. Assignment stability — Stop when no point changes its most-likely cluster between iterations (or when fewer than a tolerance fraction change).
Choosing is an art: use BIC/AIC + elbow method. Initializing well is a science: use K-means first. Knowing when to stop is simple: watch the log-likelihood plateau. With these three practical decisions made, GMM is a robust and widely applicable clustering tool. The next half of the lecture moves to a completely different paradigm: supervised classification with Support Vector Machines.

16.7 Support Vector Machines — Core Concept

If I show you three lines separating two groups of points and ask which one you'd pick — without knowing any machine learning — you'd choose the one in the middle that gives both groups breathing room. That instinct is the Support Vector Machine. "That's the end of SVM," as the professor put it.

16.7.1 The Classification Problem

Consider predicting whether a student gets admission into their top-choice IIT. Two features matter: CGPA and JEE score. Plot each student as a point on a 2D graph:

  • Blue triangles ▲ = students who got in → label
  • Red circles ● = students who did not → label

The task: draw a line that separates these two classes. In higher dimensions, this becomes a hyperplane.

Visual intuition: The x-axis is CGPA, the y-axis is JEE score. Blue points cluster in the top-right (high CGPA, high JEE). Red points cluster in the bottom-left. The separator is a straight line cutting diagonally between them.

16.7.2 Which Line Is Best?

The professor showed three candidate lines:

  • L₁: Separates the data but is dangerously close to the red points. A new red observation slightly different from the training data could easily fall on the wrong side. No safety margin.
  • L₃: Separates the data but is dangerously close to the blue points. Same problem — no breathing room on the blue side.
  • L₂: Sits squarely in the middle, giving breathing room to both classes. Even if new observations vary slightly from the training data, they are likely to stay on the correct side.
"If I ask you — you don't know machine learning — which among these three lines will you be choosing to differentiate these two classes? You would pick L₂ because it gives breathing space. That is SVM."

16.7.3 Decision Boundary, Margin, and Support Vectors

Three key geometric concepts define the SVM:

Decision boundary (the dashed middle line):

At this line, the prediction is 50-50 — we cannot decide the class. Points exactly on this line are equally likely to be either class.

Margin — The distance from the decision boundary to the nearest data point of each class. The total gap between the two outer margin lines is . The SVM's goal is to make this as wide as possible.

Support vectors — The data points that lie exactly on the margin boundaries (or are closest to the decision boundary). These are the hardest points to classify — the ones that constrain how wide the margin can be. They are the only points that matter for determining and .

The "namaste" analogy: The professor gave a vivid physical metaphor:

"When you're doing namaste, how much can you move your hands apart so that you don't touch the people on both sides? I want to move my hands as far as possible. When you touch somebody on one side, that much only we will take on the other side also — that is the maximum."

Your hands are the margin lines. The people on either side are the support vectors. You spread your hands until they touch the nearest person on each side. That equal distance on both sides defines the maximum margin. The decision boundary runs exactly halfway between your hands.

Critical property of support vectors: If you move any data point that is NOT a support vector, the decision boundary and margin do not change at all. If you move a support vector, the boundary shifts. That is why they are called "support" vectors — they literally support the margin. All other points are irrelevant once the SVM is trained. This sparsity is what makes SVMs efficient: after training, you can discard all non-support-vector data points.

16.7.4 SVM as an Optimization Problem

SVM is fundamentally an optimization (maximization) problem:
  • Goal: Maximize the margin = .
  • Constraint: Every training point must lie on or outside its respective margin line (for hard-margin SVM).

In different dimensions, the separator has different names:

  • 2D: find the best line.
  • 3D: find the best plane.
  • 4D and higher: find the best hyperplane.

The math treats all cases uniformly — even a line is a "hyperplane" in the formalism: only the first weight term is non-zero, and the rest vanish. The professor noted: "In literature, even a line is called a hyperplane because the hyperplane equation is used."

SVM is a supervised classification algorithm. Unlike GMM (unsupervised clustering), SVM requires labeled training data: you must know which points are and which are .

16.7.5 Hard Margin vs. Soft Margin

Scope: Hard-margin SVM assumes the data is linearly separable — that there exists a hyperplane perfectly separating the two classes. In real data, this assumption almost never holds.

Hard margin SVM: No misclassifications allowed. Every training point must be on the correct side of (or exactly on) its margin line. Problem: if there is an outlier — say, a red point deep in blue territory — SVM is forced to draw the boundary near that outlier, producing a terrible classifier.

The professor's example: "Consider some student who got a very high JEE score but due to some issue (say CGPA problem, or some malpractice identified later), even though the student seems like a top candidate, they were not selected. The data point sits in blue territory but is actually red. SVM will draw the boundary near that outlier, creating a wrong boundary."

Soft margin SVM: Allows some misclassifications. The algorithm tolerates a few points on the wrong side of the margin, paying a penalty proportional to the violation. This makes the model more generalizable and less sensitive to outliers. Soft margin SVM (with slack variables ) is covered in the next class and is what is used in virtually all real-world applications.

Hard marginSoft margin
MisclassificationsZero toleranceTolerated, with penalty
Outlier sensitivityExtremely sensitiveRobust
Data requirementMust be linearly separableWorks with overlapping classes
Real-world usageMostly theoreticalUsed everywhere
SVM is the art of finding the widest street between two classes. The street's center line is the decision boundary, its edges are defined by the support vectors, and its width is the margin. Everything else — the primal optimization, the dual formulation, the Lagrangian — is machinery to compute this geometrically intuitive idea efficiently, especially in high dimensions.

16.8 SVM — Mathematical Formulation

16.8.1 Setup and Notation

We have data points. For each point :
  • — a vector of features (e.g., CGPA and JEE score, so ).
  • — the class label.
    • : positive class (got admission, blue triangle ▲)
    • : negative class (did not get admission, red circle ●)
The SVM learns a function from the training data. The sign of gives the predicted class:
  • If → predict
  • If → predict

16.8.2 Hyperplane Equations

Three parallel hyperplanes define the SVM:

Decision boundary (dashed middle line):

Right margin line (positive side, prediction = ):

Left margin line (negative side, prediction = ):

Where:
  • — the weight vector. Like the slope coefficients in a line equation. .
  • — the bias (intercept). A scalar. Shifts the hyperplane away from the origin.
  • — a feature vector.

Any point with is classified . Any point with is classified . Points in between () lie inside the margin.

What about 2D? For a line in 2D, the equation is . This is exactly the hyperplane equation with . The professor emphasized: "Even though it is lower dimension, they use the hyperplane equation itself."

16.8.3 The Normal Vector

From vector algebra: for a hyperplane , the weight vector is perpendicular (normal) to the hyperplane.

Why this matters: To measure the margin, we need the shortest distance from a point to the hyperplane. The shortest path is always along the normal direction — the direction of . This is why the margin width ends up being .

16.8.4 Deriving the Margin Size

Step-by-step derivation of the margin width:

Start on the decision boundary: . Walk units in the direction of (perpendicular to the boundary) until you hit the line .

The unit vector in the direction of is . So your new position is:

Plug this into the line equation:

Distribute the dot product:

Since you started on the decision boundary, . Substitute:

Now (definition of the squared norm):

So the distance from the decision boundary to one margin line is . The total margin (gap between the and lines) is:

Sense check: As gets smaller, the margin gets larger. If , the margin (but then the hyperplane would classify everything as one class — the constraints prevent this). ✓

16.8.5 The Optimization Problem (Primal Form)

Goal: Maximize the margin = .

Maximizing is equivalent to minimizing . For mathematical convenience, we minimize instead. The factor makes the derivative clean: .

Subject to the constraint that every point is correctly classified and lies on or outside its margin:

Why does one inequality cover both classes?

  • For : We need . Multiply by : . ✓
  • For : We need . Multiply both sides by (flipping the inequality): . Since : . ✓

Both cases reduce to the same inequality. This elegant trick is what makes the SVM formulation so compact.

The professor: "From where did the ½ come? Nowhere. It is just a mathematical convenience so that when we take the gradient later it will be easier. You remember in linear regression also we used to add ½ so that the derivative becomes easy."

This is a quadratic programming problem: minimize a quadratic objective subject to linear inequality constraints. For this class of problems, any local minimum is also a global minimum — a crucial property that makes SVM optimization reliable.

16.8.6 Symbol Registry — Linear SVM

SymbolMeaningTypeDomain
Weight vector (normal to hyperplane)vector
Bias (intercept)scalar
Feature vector for data point vector
Class label for data point scalar
Number of data pointsinteger
Number of features (dimensions)integer
Euclidean norm (magnitude) of scalar
MarginTotal width between margin linesscalar
The SVM primal problem: minimize subject to for all . This is the mathematical statement of "find the widest street that separates the two classes." The margin is — smaller means a wider margin.

16.9 From Primal to Dual — The Lagrangian Approach

The primal SVM problem optimizes over (a -dimensional vector). But what if is enormous — say, every pixel in an image is a feature? The dual reformulation pivots from optimizing over variables to optimizing over variables, where is the number of data points. When (few images, many pixels), this is a massive computational win.

16.9.1 Why Convert to a Dual Problem?

In the primal problem, we minimize over . The computation involves dot products for every data point. When is large — think image data with 10,000+ pixels per image but only a few hundred images — this is expensive.

The dual formulation transforms the problem so that:

  • We optimize over Lagrangian multipliers instead of the -dimensional .
  • Only the for support vectors are non-zero. All other .
  • The data appears only as dot products between pairs of points (), not between weights and features.
  • When , the dual is far cheaper to solve.

The professor's own words: "In large dimension data, the number of records are much smaller than the number of columns. So this calculation will be reduced a lot. That's the reason we are doing all of this gimmick."

Note on dimensions: When is small compared to , the primal form is actually more efficient. The dual form is specifically designed for the regime (e.g., image classification, text classification with bag-of-words). The professor focused on the dual because it also sets up the kernel trick (next lecture), where the dimension can be infinite.

16.9.2 Lagrangian Function

For each constraint , we introduce a Lagrangian multiplier . The Lagrangian function is: This is the standard SVM Lagrangian form (Bishop §7.1, equation 7.7). The minus sign is by convention: we minimize with respect to and and maximize with respect to .

16.9.3 KKT Conditions and Stationarity

The Karush-Kuhn-Tucker (KKT) conditions are necessary conditions for optimality in constrained optimization. The professor noted they are covered in the Mathematical Foundations for ML course. The key condition for the dual derivation is stationarity: set the partial derivatives of the Lagrangian to zero.

Derivative with respect to : This is a beautiful result: the optimal weight vector is a linear combination of the training data points, each weighted by . Only points with contribute — those are the support vectors.

Derivative with respect to :

Wait — let's compute carefully. The term inside the sum is . Taking derivative with respect to : . So:

This is a constraint on the values: the weighted sum of labels must be zero.

16.9.4 The Dual Problem

Complete derivation from primal to dual:

Substitute and the constraints into the Lagrangian:

The bias term vanishes because . The two double sums combine (they're the same sum since ), giving .

The dual maximization problem:

Subject to: and for all .

Equivalently, as a minimization (negate the objective, which is what most solvers use):

This is the standard dual form from Bishop §7.1 (equation 7.10). The primal and dual are equivalent — solving one gives the solution to the other via .

16.9.5 Why the Dual Is More Efficient

In the dual, data appears only as dot products . The are non-zero only for support vectors (a consequence of the KKT complementary slackness condition: ).

So the double sum is effectively only over support vectors — a small fraction of the training data. This makes the dual dramatically more efficient when .

KKT complementary slackness (the reason for sparsity): For every data point, either (point is irrelevant — not a support vector) or (point lies exactly on its margin boundary — it IS a support vector). Most points have and can be discarded after training.

16.9.6 The Classification Function

Once the are found, classification of a new point uses:
  • If → classify as
  • If → classify as

The weight vector is recovered as .

Computing (the bias): For any support vector (a point with ), we know . Solving for :

Since , multiply through by :

For numerical stability, average over all support vectors (Bishop §7.1, equation 7.18):

For exam problem-solving, you need only three equations:
  1. Classification:
  2. Weight vector:
  3. Bias: computed from any support vector as above.
The Lagrangian and KKT derivations are for conceptual understanding — the professor stated explicitly: "Derivations you can take from the slide. Nobody may ask, but ML maybe will not ask."

16.10 SVM — Worked Example

This is the canonical exam-style SVM problem. The professor stated: "Just please study solving system of linear equations. Otherwise you will not be able to solve this here." Work through every step — the math is straightforward but you need to be systematic.

16.10.1 Problem Setup

Three data points, each with features augmented by a bias column of 1:

PointFeatures (with bias)Label

The third component "1" is the bias term added manually — the same technique used in linear regression when adding a column of ones for the intercept. This absorbs into the weight vector: the third component of will be .

Visual intuition: Plot these in 2D (ignoring the bias column). is the lone negative point at the bottom. and are the two positive points at the top, symmetrically placed. The decision boundary should be a horizontal line somewhere between and .

16.10.2 Step 1 — Write the System of Linear Equations

For support vectors (all three points will turn out to be support vectors), the classification condition is:

For ():

Compute the dot products:

For ():

For ():

16.10.3 Step 2 — Solve the System of Linear Equations

Subtract Eq 3 from Eq 2:

Let . Substitute into Eq 1:

Substitute into Eq 2:

Therefore:

All three → all three points are support vectors.

16.10.4 Step 3 — Compute and

So . The third component is the negative of the bias: .

16.10.5 Step 4 — Write the Decision Boundary

The decision boundary: .

The decision boundary is the horizontal line .

The margin lines:

  • Right side ():
  • Left side ():

Verification — check that support vectors lie on margin lines:

  • : ✓ (on margin)
  • : ✓ (on margin)
  • : ✓ (on margin)

Margin width: . The effective margin in the 2D projection is the distance between the margin lines: .

16.10.6 Interpretation

Classification rule:
  • Any point with (on or above ) → class
  • Any point with (below ) → class
The decision boundary sits exactly halfway between the negative point at and the positive points at . This is the maximum-margin solution: the margin of 1 unit on each side is the largest possible given these three points.

Sense check: The two positive points and are at the same height, symmetrically placed at and . The single negative point is at , . The maximum-margin line should indeed be horizontal at — the midpoint. The -coordinate doesn't matter because both positive points share the same -value, making the problem effectively 1D in the direction. ✓

The worked example shows the full pipeline: set up the -equations from dot products → solve the linear system → compute → extract from 's bias component → write the decision boundary. For the exam, the professor emphasized: "These three equations — (classification function), equation, and equation — you just use those three equations for problem solving."

16.11 Student Questions and Answers

The following questions capture distinct confusion points raised during the lecture. Repetitive questions have been merged into the clearest canonical version. Frequency noted where multiple students asked the same thing.


Q: Why do we need to remove duplicate records before clustering? A: If you have many copies of the same record, the statistical description (mean, spread) gets biased. One record repeated 100 times will heavily distort the mean. Even though it may not affect all measures equally, the statistical description is the foundation — from there it influences everything downstream: cluster centers, variance estimates, and ultimately the assignments. This applies to both K-means and GMM.
Q: When we "assume two random Gaussians," what exactly do we assume? A: We assume specific numeric values for . That's it. One Gaussian has a certain mean and standard deviation; the other has different values. These are the parameters that define each bell curve. "Random" here means "initial guesses," not "truly random from thin air" — in practice, Python uses K-means to get sensible starting values.
Q: (Multiple students asked variations) What if a point has equal probability of belonging to two clusters (50-50)? A: It's very unlikely that the probabilities are exactly equal, but if it happens, you can assign the point to either cluster — it doesn't matter. Algorithmically, this is handled with or conditions. In soft clustering, the assignment is probabilistic anyway, so a 50-50 split just means the point is genuinely ambiguous.
Q: (Multiple students asked) Do we need to calculate the dot products for ALL records in SVM? A: Practically, the algorithm computes dot products for all records during training. But after solving, the values become zero for everything except the support vectors. So for classification of new points, you effectively only need the support vectors. This sparsity — most — is why the dual formulation is efficient in practice.
Q: What if the data has overlapping points in SVM? A: Remove exact duplicates before running the algorithm — they don't add information and can cause numerical issues. For points that are very close but not identical, hard-margin SVM may struggle to find a perfect separator. Soft-margin SVM (next lecture) handles overlapping classes explicitly by allowing some misclassifications with a penalty.
Q: Does the margin line always touch the support vectors? A: Conceptually, the margin lines are as close to the support vectors as possible without crossing them. When you compute the maximum margin, the margin lines may or may not exactly touch — they must be kept as close as possible. The professor's analogy: "When you're doing namaste, how far can you move your hands apart before touching someone on either side? When you touch someone on one side, that is the limit — you take that same distance on the other side too." In the formal hard-margin solution, the active constraints (support vectors) satisfy the equality exactly.
Q: (Several students asked) How do we get from the primal to the dual problem? Where do the values come from? A: The values are Lagrangian multipliers — they come from the Lagrangian function used to convert the constrained optimization into a dual form. This involves KKT conditions and Lagrangian duality, studied in detail in the Mathematical Foundations for ML course. For the ML course, you only need the final formulas: , , and the formula for . The derivations are for conceptual understanding — "ML maybe will not ask" the derivations.
Q: Why is perpendicular to the hyperplane? A: This is standard vector algebra. For any hyperplane defined by , the gradient is , and the gradient is always perpendicular to the level set. Another way: take any two points on the hyperplane. Then and , so . Thus is perpendicular to every vector lying in the hyperplane — it is the normal vector.
Q: Do we need to solve the system of equations for SVM manually on the exam? A: Yes. You need to know how to write the system of linear equations using the classification function formula , and then solve it for the values. The professor's advice: "Just please study solving system of linear equations. Otherwise you will not be able to solve this here."

16.12 Exam Guidance

16.12.1 Mark Distribution

Exam note: Post-mid-semester content carries 75% of the exam weight. Pre-mid-semester content: 25%. The professor did not specify topic-wise importance within this split, but GMM and SVM are major post-mid topics and likely to appear.

16.12.2 Problem Types

GMM exam problems — Expect 1D problems only (2D is too calculation-heavy for hand computation). The canonical question: "Consider a dataset with four points 0, 1, 2, and 3. Fit a mixture of two Gaussian components." You must be able to:
  1. Compute responsibilities in the E-step using
  2. Update parameters in the M-step:
  3. Check convergence (assignments stop changing or log-likelihood stabilizes)

SVM exam problems — Expect to be given 3-4 data points with labels. You must:

  1. Write the system of linear equations: for each
  2. Solve the system for
  3. Compute and extract
  4. Write the decision boundary equation and margin lines
  5. State the classification rule
The worked example in §16.10 with 3 data points is representative of what to expect.

16.12.3 What to Know (and What Not To)

Exam note — Need to know (memorize & apply):
  • GMM: Responsibility formula, mean update, variance update, mixing coefficient update
  • SVM: Classification function , weight vector , bias formula from a support vector
  • SVM: How to write the system of linear equations from data points

Derivations are for understanding only:

  • Lagrangian function, KKT conditions, and derivation of the dual problem
  • The professor: "Derivations you can take from the slide. Nobody may ask, but ML maybe will not ask."

Open book: Formulas will be available in the slides. The common slides are what you can take into the exam. But you must know which formula to apply when — memorizing the structure is more important than memorizing every symbol.

16.12.4 Study Advice

Exam note — Professor's study recommendations:
  1. Concept first, formulas second. If you understand the "coloring" process for GMM and the "margin maximization" idea for SVM, the formulas become easy. The professor warned: "If you simply try to by-heart the formula 100 percentage, you will miss one or other step."
  2. For SVM: "These three equations — (classification function), equation, and equation — you just use those three equations for problem solving."
  3. For GMM: The E-step = coloring example. Keep that picture in mind: "You'll be able to solve any given problem."
  4. Practice solving systems of linear equations. The SVM exam problem reduces to exactly this skill. The professor: "Just please study solving system of linear equations."
  5. The professor will upload a complete worked SVM example with all solving steps — use it to practice.

16.13 Key Industry Applications and Real-World Connections

  • GMM for unsupervised discovery — height data and beyond. The classic example: adult heights in a city come from two underlying distributions (men and women). GMM discovers these latent groups without ever seeing gender labels. This same pattern applies to several real-world tasks: customer segmentation (discovering spending-personality types from transaction data), anomaly detection (flagging points with low probability under the fitted GMM as outliers), and image segmentation. For image segmentation, the technique is known as vector quantization — each pixel is represented by its closest cluster center (Bishop §9.1.1).
  • SVM for binary classification — admissions, medicine, and finance. The motivating example uses CGPA and JEE scores for admission prediction — a realistic binary classification scenario. The same framework applies to: loan default prediction (will this borrower repay?), medical diagnosis (malignant vs. benign tumor from imaging features), spam detection (spam vs. not-spam from email features), and face detection (face vs. non-face from pixel intensities).
  • Large-dimensional data — why SVM's dual shines. The professor emphasized image data as the motivating case for the dual formulation. Images have thousands of pixels (features) but training sets may have only hundreds of images. In this regime, the dual form reduces computation dramatically by working with dot products between data points rather than dot products with the weight vector. The same advantage applies to text classification with bag-of-words features (vocabulary size = ).
  • Python implementations — K-means initializes GMM. scikit-learn's GaussianMixture uses K-means to initialize cluster centers, covariances, and mixing weights before running EM. This gives faster, more reliable convergence. Similarly, sklearn.svm.SVC implements both linear and kernel SVMs with efficient solvers (SMO, libsvm).
  • Nonlinear SVM — the kernel trick (next lecture). The professor previewed that nonlinear SVM handles data that is not linearly separable. By replacing dot products with kernel functions , the SVM can learn nonlinear decision boundaries while keeping the same optimization framework. The popular Gaussian (RBF) kernel is the default in most libraries.
  • Soft margin SVM — the practical default. Virtually all real-world SVM applications use soft margin (with slack variables and a regularization parameter ) because real data always has noise and overlapping classes. Hard margin is primarily a theoretical building block that leads to the more practical soft-margin formulation.

16.14 Professor Pedagogical Highlights

The professor used several memorable analogies and teaching strategies throughout this lecture. These are preserved here as they capture the intuitive core of each concept.


Reverse engineering analogy for GMM:

"It's like reverse engineering. We are going to look at the data set and we are going to ask: if I have to recreate this particular data set using a few Gaussian distributions, where will I put those bell curves? How wide would they be?"

Namaste analogy for margin:

"When you're doing namaste... how much you can move your hands apart so that you don't touch the people on both sides? I want to move my hands as far as possible. When you touch somebody on one side, that much only we will take on the other side also — that is the maximum."

Top-view visualization for Gaussians:

The concentric circles in GMM plots are the top view of bell curves — "You are standing here and looking at this... You're at the sky. Imagine and you're looking at this."

Heads-up on difficulty — GMM:

"Don't panic if you're not understanding in the beginning. By the end, once we complete that, you will be able to connect the dots or stitch the parts together. It is how everyone is going to feel it. So don't think that only I'm not understanding or only I'm not able to make sense."

Heads-up on difficulty — SVM dual:

"Whatever I'm going to explain to you in the next 10 minutes, none of you are going to make sense, but listen. Listen it once, listen it twice, listen it thrice. You will get an idea."

Formula memorization warning:

"If you understood the concept, it is very easy, but if you simply try to by-heart the formula 100 percentage, you will miss one or other step. What is that coloring example? Keep in mind, we can do that. You'll be able to solve any given problem."

On GMM as K-means extension:

"It is exactly K-means extension. That is why we learned K-means first."

On the ½ in SVM objective:

"From where did it come? Nowhere. It is just a mathematical convenience so that when we take gradient later it will be more easy for us. You remember in linear regression also we used to add ½ so that the derivative becomes easy."

On SVM as an idea:

"If I ask you — you don't know machine learning — which among these three lines will you be choosing to differentiate these two classes? You would pick L₂ because it gives breathing space. That is SVM. That's the end of SVM."

ML Lecture 16 notes · Gaussian Mixture Models and Support Vector Machines

Machine Learning· postgraduate· 2026-06-30

Sections Breakdown

1Context — From K-Means to Gaussian Mixture Models

Bridges from hard K-means clustering to the soft, probabilistic GMM framework, covering the limitations of hard clustering and the reverse-engineering analogy for mixture models.

2Gaussian Mixture Model — Core Concepts

Hard vs. soft clustering comparison, flexibility in cluster shape via covariance matrices, and the core idea of data as a weighted sum of Gaussian distributions.

3The GMM Algorithm — Expectation-Maximization

The EM algorithm steps: initialization, E-step (compute responsibilities), M-step (update parameters), and convergence check. Includes the coloring analogy and formal algorithm statements.

4GMM — Mathematical Foundation

1D and multivariate Gaussian PDFs, the GMM probability density function as an additive mixture, and a complete symbol registry for 1D GMM.

5GMM — Worked Example

Full step-by-step EM on a 4-point dataset with K=2: E-step responsibility calculations, M-step parameter updates, and convergence analysis.

6GMM — Practical Considerations

Choosing K via BIC/AIC/elbow method, initialization strategies (K-means first recommended), and convergence criteria.

7Support Vector Machines — Core Concept

The margin maximization intuition, decision boundary/hyperplane, support vectors and their sparsity property, the namaste analogy, and hard vs. soft margin comparison.

8SVM — Mathematical Formulation

Setup and notation, hyperplane equations, normal vector concept, step-by-step margin width derivation, and the primal optimization problem.

9From Primal to Dual — The Lagrangian Approach

Why convert to dual, Lagrangian function, KKT stationarity conditions, complete dual derivation, and the classification function with the three key exam equations.

10SVM — Worked Example

Full 3-point SVM example with bias column: system of linear equations, solving for alpha values, computing w and b, writing the decision boundary.

11Student Questions and Answers

Consolidated student questions covering duplicate removal, random initialization, 50-50 splits, dot product computation, overlapping points, margin behavior, and Lagrangian derivations.

12Exam Guidance

Mark distribution, GMM and SVM problem types, what to memorize vs. what to understand, and study advice from the professor.

13Key Industry Applications and Real-World Connections

Real-world applications of GMM (customer segmentation, anomaly detection) and SVM (admissions, medicine, finance, image/text classification).

14Professor Pedagogical Highlights

Memorable analogies: reverse engineering for GMM, namaste for SVM margins, top-view for Gaussians, and key teaching strategies.

Postgraduate students in Machine Learning

Exam Revision Notes

Below is the distilled, exam-ready core of this lecture. Every entry is built from the full textbook notes above. Use this section for rapid review — but if something doesn't make sense, go back to the full explanation in the main content.

Gaussian Mixture Models — Soft Clustering and Mixture Concept

Must-know: GMM is a probabilistic clustering model that assigns each data point a soft membership — a probability distribution over clusters — rather than a hard binary assignment. The model assumes data is generated from a weighted sum (mixture) of K Gaussian distributions, each with its own mean , variance , and mixing coefficient (where ).

⚠️ Top pitfall: Forgetting the mixing coefficient constraint . Students often treat as free parameters — they are probabilities and must sum to 1.

Self-check: How does GMM differ from K-means in terms of (a) cluster assignment and (b) cluster shape?

Connects to: K-means clustering (hard assignment counterpart), EM algorithm (the fitting method), covariance matrices (enabling elliptical clusters).

Expectation-Maximization Algorithm for GMM

Must-know: The EM algorithm alternates between two steps. E-step: Compute responsibilities — the probability that point belongs to component . M-step: Update parameters using weighted averages. Repeat until log-likelihood stabilizes. Every point always has fractional membership — no point is ever 100% in one cluster.

⚠️ Top pitfall: Confusing the E-step and M-step formulas. The responsibility formula (E-step) uses the current parameters. The M-step formula uses the responsibilities just computed in the E-step. Also: forgetting that EM can converge to local optima.

Self-check: If and with and equal mixing coefficients, what is the approximate responsibility of for component 1?

Connects to: GMM model definition, convergence criteria (log-likelihood threshold ), K-means EM analogy, local optima problem.

GMM Worked Example — 4-Point Dataset

Must-know: The canonical exam problem: fit Gaussians to points . Initialize: . Run one full EM iteration. After E-step, responsibilities approximately: . After M-step, , , shrink to ~0.62. Both means move toward their natural clusters — variances tighten.

⚠️ Top pitfall: Using the updated mean in the variance formula but forgetting to use it in the squared deviation term . Also: not checking that responsibilities sum to 1 for each point.

Self-check: After the first M-step, why do the mixing coefficients stay at 0.5 for this symmetric dataset?

Connects to: EM algorithm steps, Gaussian PDF evaluation, convergence check, choosing K (BIC/AIC), initialization strategies.

GMM Practical Considerations — Choosing K, Initialization, and Convergence

Must-know: Choosing K: Use BIC () or AIC () — lower is better. BIC penalizes complexity more heavily. Initialization: K-means first (scikit-learn default) gives reliable starting positions. Convergence: Stop when (typically ).

⚠️ Top pitfall: Using BIC/AIC with too few candidate K values (just K=2,3,4). Always test a range and look for the minimum. Also: confusing which is lower-is-better — both BIC and AIC are lower-is-better.

Self-check: For a dataset with n=1000 points, which criterion (BIC or AIC) would favor a simpler model? Why?

Connects to: Elbow method, silhouette analysis, cross-validation for K selection, EM local optima, K-means initialization strategy.

Support Vector Machines — Margin Maximization Concept

Must-know: SVM finds the hyperplane that maximizes the margin between two classes. The margin is . The support vectors are the data points closest to the decision boundary — they are the only points that determine and . Moving any non-support-vector point does NOT change the boundary. This sparsity is the key computational property of SVMs.

⚠️ Top pitfall: Confusing the decision boundary () with the margin lines (). Also: thinking hard-margin SVM works when data is not linearly separable — it doesn't.

Self-check: How many support vectors does a hard-margin SVM typically have relative to the total number of training points?

Connects to: Binary classification, hard vs. soft margin, optimization constraints, Lagrangian dual formulation, kernel trick (next lecture).

SVM Mathematical Formulation — Primal Problem

Must-know: The SVM primal problem minimizes subject to for all . The factor is for derivative convenience. The elegant constraint trick covers both classes in one inequality. The margin is derived by walking units along the normal direction from the decision boundary to either margin line.

⚠️ Top pitfall: Forgetting that the constraint uses (not ). The 1 comes from the margin line equations . Also: not understanding why is perpendicular to the hyperplane — this is fundamental to the margin derivation.

Self-check: Derive why the distance from the decision boundary to one margin line is .

Connects to: Margin width derivation, normal vector concept, quadratic programming, KKT conditions, dual formulation.

SVM Lagrangian Dual — From Primal to Dual

Must-know: The dual formulation transforms the problem from optimizing over to optimizing over Lagrangian multipliers . The key result: . Only support vectors have (all others are zero). The dual is more efficient when . For classification: .

⚠️ Top pitfall: Forgetting the constraint . This comes from setting and is an essential constraint on the values. Also: thinking Lagrangian derivations are required for the exam — they are for understanding only.

Self-check: Why are most after solving the SVM dual? What condition makes an non-zero?

Connects to: Primal optimization, KKT complementary slackness, support vector sparsity, kernel trick (next lecture), bias computation.

SVM Worked Example — 3-Point Dataset with Bias Column

Must-know: The canonical exam problem: 3 points with augmented bias column of 1. ; ; . Solve the system for each . Solution: . Result: , decision boundary .

⚠️ Top pitfall: Forgetting to include the bias column of 1 in the feature vectors when computing dot products. The third component "1" absorbs into so that the decision boundary equation becomes instead of . Also: arithmetic errors in solving the 3×3 linear system — practice this.

Self-check: Verify that each support vector lies exactly on its respective margin line ( for negative, for positive).

Connects to: Classification function, system of linear equations, support vector identification, margin verification, bias extraction from augmented weight vector.

Was this lecture useful?

Loading comments…
🤖

BitsNotes AI Assistant

Subject Notes Assistant

Configure AI Chat

Choose how to access the chatbot
Have your own API key?

Switch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.

🔑 Enter API key above to fetch live models from provider, or enter model name manually.
OpenAI-Compatible API Support

Choose any provider preset (Gemini, DeepSeek, Kimi, GLM, MiniMax, Qwen, OpenAI, Groq, Ollama, etc.) or enter a custom endpoint URL.

Security & Privacy First

Your API key is sent directly from your browser to your specified provider. BitsNotes servers never store or see your key.