IAE Academy

GATE DA

LDA, SVMs and decision trees

Linear discriminant analysis, support vector machines and decision trees

Linear discriminant analysis, support vector machines and decision trees are three classic classifiers. LDA draws a linear boundary from the class means and a shared covariance matrix. An SVM picks the separating hyperplane with the widest margin. A decision tree splits the data greedily using impurity measures such as entropy and the Gini index. The calculations to master are a discriminant score, a margin width, a kernel value and the information gain of a split. Each is short once the formulas and conventions below are fixed.

7 previous-year questions · 7 solved · 6 practice questions

Conventions and the classification setting

All three methods learn a rule from labelled training data , . Each is a feature vector, written in bold and treated as a column vector. In a data matrix the samples are the rows. Distances are Euclidean unless stated.

  1. LDA and decision trees handle two or more classes, labelled (or for two classes).

  2. For an SVM the two class labels are coded . This coding is what makes the constraint work.

  3. is the weight (normal) vector and is the bias (offset) of a linear boundary .

  4. and mean the natural logarithm unless stated. Entropy in bits uses , the usual choice for decision trees, and this is stated each time below.

The boundary is a hyperplane. The signed distance of a point from it is , and its absolute value is the ordinary distance. This one fact drives the SVM margin.

DISTANCE OF A POINT FROM A HYPERPLANE

Euclidean distance from to the hyperplane , for .

Linear discriminant analysis (LDA)

LDA is a generative classifier. It models each class as a Gaussian with its own mean and a common (shared) covariance matrix , and it uses class priors . Bayes' rule then gives a rule that is linear in , because the quadratic term is the same for every class and cancels.

LDA PARAMETER ESTIMATES (POOLED COVARIANCE)

Class means, priors and the pooled within-class covariance, where is the number of samples in class . Dividing by instead of only rescales . With equal priors the decisions are unchanged. With unequal priors the term gets a slightly different relative weight, so borderline decisions can change.

LINEAR DISCRIMINANT FUNCTION

Assign to the class with the largest ; is the natural logarithm. This assumes Gaussian classes with a common .

TWO-CLASS LDA RULE

This is . The boundary is a hyperplane with normal vector . It passes through the midpoint of the means when . Unequal priors shift it away from the more probable class.

With equal priors and any shared , LDA assigns to the class whose mean is nearest in Mahalanobis distance . If also , this becomes the nearest class mean in Euclidean distance. When is not a multiple of , is in general not parallel to the line joining the means, because down-weights directions of high variance. The exception is when is an eigenvector of ; then stays parallel to it.

EXAM TIP

A classifier with a separate covariance matrix for each class is quadratic discriminant analysis (QDA), not LDA. The shared covariance is exactly what makes the LDA boundary linear.

Fisher's criterion

Fisher's view is geometric and needs no Gaussian assumption. Project the data onto a direction , and choose the that pushes the projected class means far apart relative to the spread within each projected class. For two classes with sample means , define the within-class scatter and the between-class scatter .

FISHER CRITERION (TWO CLASSES)

Here are the projected means and the projected scatters. Maximise over . depends only on the direction of , not on its length.

FISHER'S OPTIMAL DIRECTION

The same direction as the two-class LDA weight vector, because is proportional to the pooled covariance. must be invertible.

Fisher's method gives only a direction. To classify you still have to choose a threshold on the projection, for example the midpoint of the projected means. For classes, has rank at most , so there are at most useful discriminant directions.

Worked example: LDA

WORKED EXAMPLE

Two classes in have means and and share the covariance . Classify (a) with equal priors, (b) with priors .

Solution
  1. , so .

  2. The midpoint of the means is . Then and .

  3. (a) Equal priors: , so the score is and goes to class 1.

  4. (b) , so the score is and goes to class 0.

Answer: (a) Class 1. (b) Class 0. The strong prior for class 0 moves the boundary towards class 1 and flips the decision.

Support vector machines: the maximum-margin hyperplane

When data is linearly separable, many hyperplanes separate the classes. The SVM picks the one with the largest margin, which is the gap between the two classes measured perpendicular to the boundary. Rescale so that the closest points of each class satisfy ; this is the canonical scaling. The two margin hyperplanes and are then parallel to the boundary, and each lies at distance from it.

MARGIN WIDTH

The distance between the hyperplanes . Valid only under the canonical scaling (closest points at ). The bias does not affect it.

HARD-MARGIN SVM (PRIMAL)

Requires linearly separable data. Maximising is the same as minimising .

HARD-MARGIN SVM (DUAL)

Only points with contribute to ; these are the support vectors. By complementary slackness, , so every support vector lies exactly on .

  1. Every support vector lies on a margin hyperplane. Removing a point with and retraining leaves the solution unchanged. In degenerate cases a point can lie on a margin hyperplane and still have .

  2. The decision function is .

  3. can be found from any support vector : (because ).

  4. Because , the values of the positive support vectors add up to those of the negative ones.

  5. At the hard-margin optimum , so the margin width is also .

WORKED EXAMPLE

Training data: positives and negatives . Find the hard-margin hyperplane and its margin width.

Solution
  1. All four points lie on the line . The closest points of the two classes are and , at distance . The maximum-margin boundary is the perpendicular bisector of the segment joining them, so for some .

  2. Both closest points are support vectors, so their constraints are active. For with : , so . For with : , so , and .

  3. , so the margin width is . This equals the distance between the closest points, as it should.

  4. Check the other points. For : , so . For : , so . Both lie outside the margin and have .

  5. Dual check: gives . Then gives , and , as it must.

Answer: The hyperplane is , i.e. . The margin width is . The support vectors are and , each with .

Soft margins, the role of C, and kernels

Real data is rarely separable. The soft-margin SVM lets points violate the margin by a slack and charges a penalty for it. The parameter trades margin width against violations. For finite the problem has a solution whether or not the data is separable.

SOFT-MARGIN SVM (PRIMAL)

In the dual, the only change from the hard margin is the box constraint .

SOFT-MARGIN SVM AS HINGE LOSS

At the optimum , which turns the constrained problem into this unconstrained one.

Multiplier / slack

Where the point lies

()

Correct side, on or outside the margin; not a support vector

Exactly on the margin; a support vector

Inside the margin but on the correct side; a support vector

On the decision boundary ; a support vector

Misclassified; a support vector

  1. Each misclassified training point has , so is an upper bound on the number of training errors.

  2. In the soft-margin case, compute from a support vector with , which lies exactly on the margin.

Large

Small

Penalty on violations

Heavy

Light

Margin

Tends to be narrower

Tends to be wider

Training errors

Tend to be fewer; approaches the hard margin as on separable data

More are tolerated

Risk

Overfitting, sensitivity to outliers

Underfitting

A kernel lets the SVM draw a non-linear boundary. Replace every dot product by , where maps into a higher-dimensional feature space. The mapping never has to be computed. must be symmetric, and its Gram matrix must be positive semi-definite (no negative eigenvalues) for every finite set of points.

COMMON KERNELS

Polynomial kernel: degree a positive integer and . RBF (Gaussian) kernel: , often written . RBF values lie in and equal 1 only when .

KERNELISED DECISION FUNCTION

Only the support vectors () contribute to the sum.

EXAM TIP

For the polynomial kernel in two dimensions, the implicit feature space has 6 dimensions: . In general with in dimensions corresponds to features, and here. A very large RBF makes each training point its own island and tends to overfit. A very small gives a very smooth boundary, close to linear.

Decision trees: impurity, information gain and the split

A decision tree classifies by asking a sequence of questions about the features. Each internal node tests one feature; for a numeric feature the test is a threshold such as . Each leaf predicts the majority class of the training samples that reach it. The tree is grown greedily from the root: at each node, try the candidate splits, keep the one that makes the children purest, then recurse. There is no backtracking, so greedy growth is not guaranteed to give the best or the smallest tree. Depth is counted with the root at depth 0.

ENTROPY (IN BITS)

is the fraction of class in node . Entropy ranges from (a pure node) to (all classes equally likely), which is bit for two balanced classes.

GINI INDEX

Ranges from (pure) to (equal classes), which is for two balanced classes. For two classes with proportions : .

MISCLASSIFICATION ERROR

Ranges from to . For two classes, . Entropy and Gini respond more strongly to changes in node purity, so they are the usual criteria for growing a tree.

INFORMATION GAIN OF A SPLIT

is the subset sent to child by the test . The same weighted-average pattern with in place of gives the Gini reduction. Choose the split with the largest gain.

GAIN RATIO

Divides the gain by the entropy (in bits) of the split proportions themselves. This penalises tests that break the node into many small branches.

  1. Compute the class counts at the node and its impurity.

  2. For each candidate split, count the classes in every child and compute each child's impurity.

  3. Weight each child's impurity by its share of the samples and add the results.

  4. Gain = parent impurity minus weighted child impurity. Pick the split with the largest gain.

  5. For a numeric feature, sort the values. It is enough to test thresholds midway between neighbouring distinct values whose labels differ.

WORKED EXAMPLE

A node has 10 samples: 6 positive and 4 negative. A test sends 5 samples left (4 positive, 1 negative) and 5 right (2 positive, 3 negative). Find the information gain (in bits) and the Gini reduction.

Solution
  1. Parent: .

  2. Left: , . Right: , .

  3. Weighted child entropy: . So IG bits.

  4. Gini: parent ; left ; right . Weighted , so the reduction is .

Answer: Information gain bits; Gini reduction .

EXAM TIP

Information gain is never negative, because entropy is concave: the weighted child entropy cannot exceed the parent's. A gain of exactly 0 means every child has the same class proportions as the parent. Plain information gain favours features with many distinct values; an ID-like feature gives pure single-sample children and the maximum possible gain. Gain ratio is the usual remedy.

Depth, pruning, overfitting and comparison

A tree grown until every leaf is pure fits the training set perfectly, provided no two identical inputs carry different labels. Such a tree usually overfits: low training error, higher test error. Depth and number of leaves measure complexity. With the root at depth 0, a tree of depth has at most leaves if every split is binary.

  1. Pre-pruning (early stopping): stop growing at a maximum depth, at a minimum number of samples per node, or when the best gain falls below a threshold.

  2. Post-pruning: grow the full tree, then cut back subtrees whose removal does not hurt error on a held-out validation set. Alternatively, use a complexity penalty: cost-complexity pruning trades training error against the number of leaves.

  3. Deeper trees tend to have lower bias and higher variance; shallow trees tend to the reverse.

Property

LDA

SVM

Decision tree

Boundary

Linear (shared )

Linear, or non-linear via a kernel

Axis-parallel splits; predictions piecewise constant

Objective

Class-conditional Gaussians; Fisher separation

Maximum margin plus a slack penalty

Greedy impurity reduction

Key hyper-parameters

None essential (priors can be estimated or set)

, the kernel and its parameters

Depth, minimum samples per node, pruning

Depends on

All training points, through the means and

Support vectors only

The samples reaching each node

Does feature scaling matter?

No: any invertible linear rescaling of the features leaves the decisions unchanged

Yes, for linear and kernel SVMs alike (the margin is a Euclidean distance)

No: rescaling a feature monotonically keeps the order of its values, which is all a split uses

EXAM TIP

SVM and LDA trained on the same two-class data generally give different boundaries. LDA uses every point, through the class means and , while the SVM is decided by the points on or inside the margin. Moving a point that stays on the correct side, outside the margin, changes the class mean and so the LDA boundary, but it does not change the SVM.

PREVIOUS-YEAR QUESTIONS

7 questions from the DA papers

Try each question first, then open the answer. We placed each question under a topic ourselves; the exam paper does not label topics.

See these papers in full: GATE DA 2026 · GATE DA 2025 · GATE DA 2024

GATE 2026 DA Q.23

GATE 2026 · DAQ.23 · 1 mark · MSQ

In the following table, the Task column lists a few tasks related to machine learning. The Algorithm column lists a few algorithms.

Each entry "t" from the Task column is to be matched with an appropriate entry "a" from the Algorithm column such that the task "t" can be solved using the algorithm "a". Denote such a match as t:a.

| Task | Algorithm |
|---|---|
| T1 – Clustering | A1 – Markov Chain Monte Carlo |
| T2 – Classification | A2 – K-Medoid |
| T3 – Sampling | A3 – Linear Discriminant Analysis |
| T4 – Feature Extraction | A4 – Naive Bayes |

Which of the following options is/are the correct matching(s)?

  1. (A)

    T1:A4, T2:A3, T3:A1, T4:A2

  2. (B)

    T1:A2, T2:A4, T3:A1, T4:A3

  3. (C)

    T1:A3, T2:A4, T3:A1, T4:A2

  4. (D)

    T1:A4, T2:A2, T3:A1, T4:A3

Answer and solution
See the question in the paper
GATE 2026 DA Q.23: answer and solution

GATE 2025 DA Q.53

GATE 2025 · DAQ.53 · 2 marks · MSQ

Consider designing a linear binary classifier , on the following training data: Class-1: , Class-2: . Hard-margin support vector machine (SVM) formulation is solved to obtain and . Which of the following options is/are correct?

  1. (A)

    and

  2. (B)

    The number of support vectors is 3

  3. (C)

    The margin is

  4. (D)

    Training accuracy is 98%

Answer and solution
See the question in the paper
GATE 2025 DA Q.53: answer and solution

GATE 2025 DA Q.55

GATE 2025 · DAQ.55 · 2 marks · MSQ

Consider a two-class problem in with class labels red and green. Let and be the means of the two classes. Given test sample , a classifier calculates the squared Euclidean distance (denoted by ) between and the means of the two classes and assigns the class label that the sample is closest to. That is, the classifier computes and assigns the label red to if , and green otherwise. Which of the following statements is/are correct?

  1. (A)

    The sample is assigned the label green if

  2. (B)

    is a linear function of

  3. (C)

    , where and are functions of and

  4. (D)

    is a quadratic polynomial in

Answer and solution
See the question in the paper
GATE 2025 DA Q.55: answer and solution

GATE 2024 DA Q.17

GATE 2024 · DAQ.17 · 1 mark · MCQ

Consider the dataset with six datapoints: , where , , , , , and the labels are given by , and . A hard margin linear support vector machine is trained on the above dataset. Which ONE of the following sets is a possible set of support vectors?

  1. (A)

  2. (B)

  3. (C)

  4. (D)

Answer and solution
See the question in the paper
GATE 2024 DA Q.17: answer and solution

GATE 2024 DA Q.22

GATE 2024 · DAQ.22 · 1 mark · MCQ

For any binary classification dataset, let and be the between-class and within-class scatter (covariance) matrices, respectively. The Fisher linear discriminant is defined by , that maximizes

If , is non-singular and , then must satisfy which ONE of the following equations?

Note: denotes the set of real numbers.

  1. (A)

  2. (B)

  3. (C)

  4. (D)

Answer and solution
See the question in the paper
GATE 2024 DA Q.22: answer and solution

GATE 2024 DA Q.53

GATE 2024 · DAQ.53 · 2 marks · MSQ

Consider the following figures representing datasets consisting of two-dimensional features with two classes denoted by circles and squares. Which of the following is/are TRUE?

GATE 2024 DA question 53: Four panels, each a 2-D scatter on axes with ticks 1, 2, 3 (both axes).Tap to open full size
Figure from the GATE 2024 DA paper. It is part of the question.
Figure description

Four panels, each a 2-D scatter on axes with ticks 1, 2, 3 (both axes). Panel (i): circles at (1,3), (2,3), (1,2); squares at (2,1), (3,1) and (2, about 0.3) just below the x=2, y=1 square. Panel (ii): circle at (2,2); squares at (1,2), (3,2), (2,3), (2,1) forming a diamond around the circle. Panel (iii): squares at (1,3) and (3,1); circles at (3,3) and (1,1) (an XOR layout). Panel (iv): squares at (1, about 2.2), (2, about 2.6), (1, about 1.2); circles at (3, about 1.5), (3, about 0.5), (2, about 0.4).

  1. (A)

    (i) is linearly separable.

  2. (B)

    (ii) is linearly separable.

  3. (C)

    (iii) is linearly separable.

  4. (D)

    (iv) is linearly separable.

Answer and solution
GATE 2024 DA Q.53: answer and solution

GATE 2024 DA Q.62

GATE 2024 · DAQ.62 · 2 marks · NAT

Details of ten international cricket games between two teams "Green" and "Blue" are given in Table C. This table consists of matches played on different pitches, across formats along with their winners. The attribute Pitch can take one of two values: spin-friendly (represented as S) or pace-friendly (represented as F). The attribute Format can take one of two values: one-day match (represented as O) or test match (represented as T).

A cricket organization would like to use the information given in Table C to develop a decision-tree model to predict outcomes of future games between these two teams.

To develop such a model, the computed InformationGain(C, Pitch) with respect to the Target is ______ (rounded off to two decimal places).

GATE 2024 DA question 62: Table C with columns Match Number, Pitch, Format, Winner (Target).Tap to open full size
Figure from the GATE 2024 DA paper. It is part of the question.
Figure description

Table C with columns Match Number, Pitch, Format, Winner (Target). Rows: 1 S T Green; 2 S T Blue; 3 F O Blue; 4 S O Blue; 5 F T Green; 6 F O Blue; 7 S O Green; 8 F T Blue; 9 F O Blue; 10 S O Green.

Answer and solution
GATE 2024 DA Q.62: answer and solution

PRACTICE

6 questions to test yourself

PRACTICE 11 mark · NAT

A hard-margin linear SVM trained on separable data gives and under the canonical scaling (support vectors satisfy ). What is the width of the margin, ? Give your answer to one decimal place.

Answer and solution

Answer: (accepted range )

  1. .

  2. Margin width . The bias does not affect the width.

PRACTICE 21 mark · MCQ

A decision-tree node holds 8 samples: 2 of class A, 2 of class B and 4 of class C. Using , the entropy of the node in bits is:

  1. (A)

    1

  2. (B)

    1.5

  3. (C)

    1.585

  4. (D)

    2

Answer and solution

Answer: (B)

  1. The proportions are .

  2. bits.

  3. The maximum for three classes is , reached only when the classes are equal. This node is not balanced, so its entropy is below that.

PRACTICE 32 marks · MSQ

Which of the following statements about the soft-margin SVM with penalty parameter are correct?

  1. (A)

    A very small tolerates many margin violations and favours a wider margin.

  2. (B)

    As on linearly separable data, the solution approaches the hard-margin SVM.

  3. (C)

    Every training point with is a support vector.

  4. (D)

    Decreasing always lowers the training error.

Answer and solution

Answer: (A), (B)

  1. A is true. A small makes slack cheap, so the term dominates and the margin widens.

  2. B is true. A huge makes any violation prohibitively expensive, which gives the hard-margin problem when a separating hyperplane exists.

  3. C is false. Support vectors are exactly the points with .

  4. D is false. Decreasing tolerates more violations, so training error generally rises or stays the same.

PRACTICE 42 marks · NAT

A node has 12 samples: 8 positive and 4 negative. A split sends 6 samples to the left child (all positive) and 6 to the right child (2 positive, 4 negative). Using the Gini index, find the reduction in impurity (parent Gini minus weighted child Gini). Give the answer to three decimal places.

Answer and solution

Answer: (accepted range )

  1. Parent: , so .

  2. The left child is pure, so . Right child: , so .

  3. Weighted child Gini .

  4. Reduction .

PRACTICE 51 mark · NAT

For the RBF kernel with , compute for and , where is the Euclidean norm. Give the answer to three decimal places.

Answer and solution

Answer: (accepted range )

  1. , so .

  2. .

  3. Check: the value lies in , as every RBF kernel value must.

PRACTICE 62 marks · MCQ

Two classes share the covariance matrix , with means and and equal priors. With and the midpoint of the means, the LDA rule assigns the point to:

  1. (A)

    Class 0, since

  2. (B)

    Class 1, since

  3. (C)

    Class 1, since

  4. (D)

    Class 0, since

Answer and solution

Answer: (A)

  1. and , so .

  2. The midpoint is , so .

  3. . With equal priors the point goes to class 0.

  4. With the score would be and the answer would flip, which shows why matters.

OFFICIAL GATE 2027 SYLLABUS WORDING

Copied from the GATE 2027 syllabus; see all 2027 syllabi.

GATE DA

linear discriminant analysis, support vector machine, decision trees

Preparing in Kolkata? IAE Academy's course for GATE DA.