BTCE | 5th Sem
AiML SubjectExtra Questions

AI/ML Unit 3 & 4: Q/A Bank

Generated and Prepared By Thiruselvan (ThiruXD)

PART B: ANALYTICAL & DESCRIPTIVE QUESTIONS (30 Questions) — With Answers

Section 1: Decision Trees & Concept Learning


Q1. Explain the characteristics of Artificial Intelligence and mention any two applications of AI.

Answer:

Characteristics of Artificial Intelligence:

  1. Learning & Adaptation: AI systems can learn from data and improve performance over time (e.g., neural networks, reinforcement learning).
  2. Reasoning & Problem Solving: AI can reason logically, solve puzzles, plan, and make decisions.
  3. Perception: AI can interpret sensory data (vision, speech, text) to understand the environment.
  4. Natural Language Processing: AI can understand and generate human language.
  5. Autonomy: AI systems can operate independently without constant human intervention.
  6. Generalization: AI can apply learned knowledge to new, unseen situations.

Two Applications of AI:

  1. Healthcare: AI is used for medical image diagnosis (e.g., detecting tumors in X-rays), drug discovery, and personalized treatment recommendations.
  2. Autonomous Vehicles: AI enables self-driving cars to perceive surroundings, make driving decisions, and navigate safely using computer vision and sensor fusion.

Q2. Differentiate between a root node and a leaf node in decision tree structures.

Answer:

FeatureRoot NodeLeaf Node
PositionTopmost node of the treeTerminal/bottom nodes
FunctionRepresents the first/primary attribute testRepresents final classification outcome
ChildrenHas one or more child nodesHas no child nodes
Decision RoleSplits the entire dataset based on an attributeAssigns a class label to instances reaching it
Attribute TestContains a test on an attributeContains no attribute test
UniquenessExactly one root per treeMultiple leaves possible

Example: In a tree deciding whether to play tennis:

  • Root node: “Outlook?” (Sunny/Overcast/Rain)
  • Leaf nodes: “Yes” or “No” (final decisions)

Q3. Explain the basic representation of a decision tree with a suitable example.

Answer:

A decision tree is a flowchart-like tree structure where:

  • Internal nodes = tests on attributes
  • Branches = outcomes of tests
  • Leaf nodes = class labels (decisions)

Example: Play Tennis Decision Tree

                [Outlook?]
               /    |    \
          Sunny  Overcast  Rain
            |       |       |
       [Humidity?] Yes   [Wind?]
        /     \          /    \
     High   Normal    Strong  Weak
      |       |         |       |
     No      Yes       No      Yes

Representation as rules:

  • IF Outlook=Sunny AND Humidity=High → No
  • IF Outlook=Sunny AND Humidity=Normal → Yes
  • IF Outlook=Overcast → Yes
  • IF Outlook=Rain AND Wind=Strong → No
  • IF Outlook=Rain AND Wind=Weak → Yes

Each path from root to leaf represents a classification rule.


Q4. Explain the concept of entropy in Decision Tree learning and state its mathematical expression.

Answer:

Entropy measures the impurity, uncertainty, or disorder in a dataset. In decision tree learning, it quantifies how mixed the class labels are in a set of instances.

  • If all instances belong to one class → entropy = 0 (pure)
  • If classes are equally distributed → entropy = 1 (maximum impurity for binary)

Mathematical Expression:

For a dataset S with c classes:

Entropy(S)=−∑i=1cpilog⁡2(pi)Entropy(S) = -\sum_{i=1}^{c} p_i \log_2(p_i)

Where:

  • pᵢ = proportion of instances belonging to class i
  • c = number of classes
  • log₂ = logarithm base 2 (entropy measured in bits)

Example: For 2 classes with 9 positive and 5 negative instances:

  • p₊ = 9/14, p₋ = 5/14
  • Entropy = −(9/14)log₂(9/14) − (5/14)log₂(5/14) = 0.940 bits

Q5. Define Information Gain mathematically and explain how it is used for split attribute selection in the ID3 algorithm.

Answer:

Information Gain measures the reduction in entropy achieved by splitting a dataset on a particular attribute. It is the expected reduction in entropy.

Mathematical Definition:

Gain(S,A)=Entropy(S)−∑v∈Values(A)∣Sv∣∣S∣Entropy(Sv)Gain(S, A) = Entropy(S) - \sum_{v \in Values(A)} \frac{|S_v|}{|S|} Entropy(S_v)

Where:

  • S = set of training instances
  • A = attribute to test
  • Values(A) = set of possible values of A
  • S_v = subset of S where attribute A = v
  • |S_v|/|S| = weight of the subset

Usage in ID3:

  1. Compute Entropy(S) for the current node.
  2. For each attribute A, compute Gain(S, A).
  3. Select the attribute with the maximum Information Gain as the splitting attribute.
  4. Create branches for each value of the selected attribute.
  5. Recurse on each subset.

Example: If Outlook has highest gain (0.246), ID3 selects Outlook as root.


Q6. Outline the step-by-step procedure of the ID3 decision tree learning algorithm.

Answer:

ID3 Algorithm:

Input: Training set S, attribute set A Output: Decision tree

Procedure:

  1. Create a root node for the tree.
  2. If all instances in S belong to the same class C → return a leaf node labeled C.
  3. If A is empty (no attributes left) → return a leaf node labeled with the majority class in S.
  4. If S is empty → return a leaf node labeled with the majority class of the parent node.
  5. Otherwise:
    1. Calculate Entropy(S).
    2. For each attribute Aᵢ in A, calculate Information Gain(S, Aᵢ).
    3. Select attribute A* with maximum Information Gain.
    4. Label the node with A*.
    5. For each possible value v of A*:
      • Create a branch for v.
      • Let S_v = subset of S with A* = v.
      • If S_v is empty → attach a leaf node with majority class of S.
      • Else → recursively call ID3(S_v, A − {A*}).
  6. Return the tree.

Termination: When all attributes are used, or all instances belong to one class.


Q7. Illustrate how a decision tree represents boolean concepts like AND and OR functions.

Answer:

AND Function (A ∧ B):

Truth table:

ABA AND B
000
010
100
111

Decision Tree:

        [A?]
       /    \
      0      1
      |      |
     No    [B?]
           /   \
          0     1
          |     |
         No    Yes

OR Function (A ∨ B):

Truth table:

ABA OR B
000
011
101
111

Decision Tree:

        [A?]
       /    \
      0      1
      |      |
    [B?]   Yes
    /   \
   0     1
   |     |
  No    Yes

Key Insight: Decision trees can represent any Boolean function. AND requires checking both conditions; OR requires only one.


Q8. State two major limitations of the standard ID3 Decision Tree algorithm and discuss how C4.5 addresses them.

Answer:

Limitation 1: Preference for attributes with many values

  • ID3 uses Information Gain, which favors attributes with many distinct values (e.g., a “Date” attribute would have high gain but poor generalization).
  • C4.5 Solution: Uses Gain Ratio = Gain(S,A) / SplitInformation(S,A), where SplitInformation penalizes attributes with many values.

Limitation 2: Cannot handle continuous attributes

  • ID3 only works with discrete/categorical attributes.
  • C4.5 Solution: Discretizes continuous attributes by finding threshold values that maximize information gain (binary splits: A ≤ threshold vs. A > threshold).

Additional Limitations Addressed by C4.5:

  • Missing values: C4.5 handles missing attribute values by distributing instances proportionally.
  • Overfitting: C4.5 includes pruning (reduced-error pruning) to simplify trees.
  • Rule generation: C4.5 can generate production rules from trees.

Q9. Discuss the concept of overfitting in decision trees and detail two strategies (pre-pruning and post-pruning) to prevent it.

Answer:

Overfitting in Decision Trees: Overfitting occurs when a decision tree learns the training data too well, including noise and outliers, resulting in:

  • Very deep trees with many branches
  • Poor generalization to unseen data
  • High training accuracy but low test accuracy

Causes:

  • Growing tree until every leaf is pure
  • Small datasets with noise
  • Too many attributes

Strategy 1: Pre-pruning (Early Stopping)

  • Stop growing the tree before it perfectly classifies training data.
  • Criteria:
    • Maximum depth limit
    • Minimum number of samples per leaf (e.g., ≥ 5)
    • Minimum information gain threshold
    • Statistical significance tests (χ² test)
  • Advantage: Computational efficiency
  • Disadvantage: May stop too early (horizon effect)

Strategy 2: Post-pruning (Pruning after full growth)

  • Grow the full tree, then remove branches that don’t improve validation performance.
  • Methods:
    • Reduced Error Pruning: Remove subtree if validation accuracy doesn’t decrease.
    • Cost-Complexity Pruning (Weakest Link): Minimize R(T) + α|T|, where |T| = number of leaves.
    • Rule Post-Pruning: Convert tree to rules, prune each rule independently.
  • Advantage: More reliable, avoids horizon effect
  • Disadvantage: Computationally expensive

Q10. Describe the inductive bias of the ID3 algorithm compared to the Candidate Elimination algorithm.

Answer:

Inductive Bias: The set of assumptions a learning algorithm uses to generalize beyond training data.

ID3 Inductive Bias:

  • Preference bias: ID3 searches a complete hypothesis space (all decision trees) but prefers:
    1. Shorter trees over longer trees
    2. High Information Gain attributes near the root
  • Restriction bias: None (can represent any Boolean function)
  • Nature: Preference/ordering bias (not restrictive)

Candidate Elimination Inductive Bias:

  • Restriction bias: The hypothesis space is restricted to conjunctions of attribute constraints (no disjunctions, no negations).
  • Preference bias: None (all consistent hypotheses are equally valid)
  • Nature: Restriction bias (limits expressiveness)

Comparison Table:

AspectID3Candidate Elimination
Hypothesis SpaceAll decision treesConjunctive concepts only
Bias TypePreference (search order)Restriction (space limitation)
Handles DisjunctionYesNo
Handles NegationYesNo
OutputSingle treeVersion space (S and G sets)
Noise HandlingPoor (overfits)Very poor (inconsistent data breaks it)

Section 2: Artificial Neural Networks & Perceptrons


Q11. Define an Artificial Neural Network (ANN) and explain its structural representation (input, hidden, and output layers).

Answer:

Definition: An Artificial Neural Network (ANN) is a computational model inspired by biological neural networks, consisting of interconnected processing units (neurons) that learn patterns from data through adjustment of connection weights.

Structural Representation:

  1. Input Layer:
    • Receives raw features/data
    • One neuron per input feature
    • No computation (just passes values forward)
    • Example: For image classification, one neuron per pixel
  2. Hidden Layer(s):
    • Intermediate layers between input and output
    • Perform computations via weighted sums + activation functions
    • Extract increasingly abstract features
    • Can have multiple layers (deep learning)
    • Example: Edge detection → shapes → objects
  3. Output Layer:
    • Produces final prediction/classification
    • One neuron per class (classification) or one for regression
    • Activation depends on task (softmax for multi-class, sigmoid for binary)

Diagram:

Input Layer    Hidden Layer    Output Layer
   x₁ ──┐
        ├──→ h₁ ──┐
   x₂ ──┤        ├──→ y₁
        ├──→ h₂ ──┤
   x₃ ──┘        └──→ y₂

Key Components:

  • Weights (wᵢⱼ): Connection strengths
  • Bias (b): Threshold adjustment
  • Activation function: Non-linear transformation

Q12. Explain the Perceptron model with a neat structural diagram outline, defining the role of weights and thresholding.

Answer:

Perceptron Model: The simplest neural network model for binary classification, proposed by Rosenblatt (1958).

Structural Diagram:

        x₁ ──w₁──┐
                 │
        x₂ ──w₂──┼──→ [Σ] ──→ [Activation φ] ──→ Output y
                 │
        x₃ ──w₃──┘
                 │
        bias b ──┘

Mathematical Formulation:

y=ϕ(∑i=1nwixi+b)y = \phi\left(\sum_{i=1}^{n} w_i x_i + b\right)

Where:

  • xᵢ = inputs
  • wᵢ = weights
  • b = bias (threshold)
  • φ = activation function (step function for classic perceptron)

Role of Weights:

  • Each weight wᵢ represents the importance/strength of input xᵢ
  • Positive weight: excitatory (supports positive class)
  • Negative weight: inhibitory (supports negative class)
  • Weights are learned during training

Role of Thresholding:

  • The weighted sum Σwᵢxᵢ + b is compared to a threshold (usually 0)
  • If Σwᵢxᵢ + b ≥ 0 → output = 1 (positive class)
  • If Σwᵢxᵢ + b < 0 → output = 0 (negative class)
  • Bias b shifts the decision boundary away from origin

Learning Rule:

  • wᵢ ← wᵢ + η(target − output)xᵢ
  • Only updates when misclassification occurs

Q13. Define bias in an Artificial Neural Network unit and state its functional role in shifting activation thresholds.

Answer:

Definition: Bias (b) is an additional parameter in a neural network neuron that is added to the weighted sum of inputs before applying the activation function. It acts like an adjustable threshold.

Mathematical Role:

z=∑i=1nwixi+bz = \sum_{i=1}^{n} w_i x_i + b y=ϕ(z)y = \phi(z)

Functional Roles:

  1. Shifting the Activation Threshold:
    • Without bias, the neuron activates only when Σwᵢxᵢ crosses 0.
    • With bias, the threshold shifts to −b.
    • Positive bias: makes neuron more likely to activate (lowers threshold).
    • Negative bias: makes neuron less likely to activate (raises threshold).
  2. Enabling Learning of Non-Zero Boundaries:
    • Without bias, decision boundary must pass through origin.
    • Bias allows the boundary to shift anywhere in space.
  3. Example (AND gate):
    • Need w₁=1, w₂=1, b=−1.5
    • Activates only when x₁+x₂ ≥ 1.5 (i.e., both are 1)
  4. Biological Analogy: Like the threshold potential in biological neurons.

Effect: Bias increases the flexibility of the model, allowing it to fit data better.


Q14. Explain why a single-layer Perceptron cannot solve the XOR problem and show how a multi-layer feedforward network overcomes this limitation.

Answer:

XOR Problem:

x₁x₂XOR
000
011
101
110

Why Single-Layer Perceptron Fails:

A single-layer perceptron creates a

linear decision boundary

(a straight line in 2D):

w1x1+w2x2+b=0w_1x_1 + w_2x_2 + b = 0

Plotting XOR points:

  • (0,0) → class 0
  • (0,1) → class 1
  • (1,0) → class 1
  • (1,1) → class 0

These points are not linearly separable — no single straight line can separate class 0 from class 1. The positive and negative examples are diagonally arranged.

Multi-Layer Network Solution:

A multi-layer network with a hidden layer can create non-linear decision boundaries by combining multiple linear boundaries.

Example: 2-2-1 Network

Hidden neuron h₁: OR function (w₁=1, w₂=1, b=−0.5) Hidden neuron h₂: AND function (w₁=1, w₂=1, b=−1.5) Output neuron: h₁ AND NOT h₂

x₁ ──┬──→ h₁ (OR) ──┐
     │               ├──→ y (XOR)
x₂ ──┴──→ h₂ (AND) ─┘

Computation:

  • (0,0): h₁=0, h₂=0 → y=0
  • (0,1): h₁=1, h₂=0 → y=1
  • (1,0): h₁=1, h₂=0 → y=1
  • (1,1): h₁=1, h₂=1 → y=0

The hidden layer transforms the input space into a new space where XOR becomes linearly separable.


Q15. Explain the role of non-linear activation functions (e.g., Sigmoid, ReLU, Tanh) in Artificial Neural Networks.

Answer:

Role of Non-Linear Activation Functions:

  1. Introduce Non-Linearity: Without non-linear activation, a multi-layer network collapses to a single linear transformation (composition of linear functions is linear). Non-linearity allows networks to approximate complex functions.
  2. Enable Universal Approximation: A network with non-linear activations can approximate any continuous function (Universal Approximation Theorem).
  3. Bound Output Range: Functions like Sigmoid and Tanh constrain outputs to specific ranges.

Common Activation Functions:

FunctionFormulaRangeCharacteristics
Sigmoidσ(z) = 1/(1+e⁻ᶻ)(0, 1)Smooth, differentiable, vanishing gradient for large
Tanhtanh(z) = (eᶻ−e⁻ᶻ)/(eᶻ+e⁻ᶻ)(−1, 1)Zero-centered, still vanishing gradient
ReLUf(z) = max(0, z)[0, ∞)Computationally efficient, avoids vanishing gradient for z>0, can cause “dying ReLU”
Leaky ReLUf(z) = max(αz, z)(−∞, ∞)Fixes dying ReLU problem
Softmaxsoftmax(zᵢ) = eᶻⁱ/Σeᶻʲ(0,1), sums to 1Used for multi-class output

Importance:

  • Sigmoid: Good for binary classification output layer
  • Tanh: Better for hidden layers (zero-centered)
  • ReLU: Default choice for deep networks (fast, effective)
  • Softmax: Standard for multi-class classification

Without Non-Linearity: Deep network = linear regression, cannot learn XOR, image features, etc.


Q16. Describe the forward pass and error calculation steps in the Backpropagation algorithm.

Answer:

Forward Pass:

  1. Initialize: Input layer receives feature vector x.
  2. For each hidden layer l = 1 to L−1:
    • Compute weighted sum: z⁽ˡ⁾ = W⁽ˡ⁾a⁽ˡ⁻¹⁾ + b⁽ˡ⁾
    • Apply activation: a⁽ˡ⁾ = φ(z⁽ˡ⁾)
  3. Output layer:
    • Compute z⁽ᴸ⁾ = W⁽ᴸ⁾a⁽ᴸ⁻¹⁾ + b⁽ᴸ⁾
    • Compute prediction: ŷ = φ(z⁽ᴸ⁾)

Error Calculation:

  1. Compute loss/error:
    • For regression: E = ½(ŷ − y)²
    • For classification: E = −[y log ŷ + (1−y)log(1−ŷ)] (cross-entropy)
    • Total error: E_total = Σ Eᵢ over all training samples
  2. Compute output layer delta:
    • δ⁽ᴸ⁾ = ∂E/∂z⁽ᴸ⁾ = (ŷ − y) · φ’(z⁽ᴸ⁾)
    • For sigmoid + MSE: δ⁽ᴸ⁾ = (ŷ − y) · ŷ(1−ŷ)
  3. Backpropagate delta to hidden layers:
    • For l = L−1 down to 1:
      • δ⁽ˡ⁾ = (W⁽ˡ⁺¹⁾)ᵀ δ⁽ˡ⁺¹⁾ ⊙ φ’(z⁽ˡ⁾)
    • Where ⊙ is element-wise multiplication
  4. Compute gradients:
    • ∂E/∂W⁽ˡ⁾ = δ⁽ˡ⁾ (a⁽ˡ⁻¹⁾)ᵀ
    • ∂E/∂b⁽ˡ⁾ = δ⁽ˡ⁾
  5. Update weights and biases:
    • W⁽ˡ⁾ ← W⁽ˡ⁾ − η ∂E/∂W⁽ˡ⁾
    • b⁽ˡ⁾ ← b⁽ˡ⁾ − η ∂E/∂b⁽ˡ⁾

Summary: Forward pass computes prediction; backward pass computes error gradients and updates weights to minimize error.


Q17. State the gradient descent weight update rule used in the Backpropagation algorithm using the chain rule of calculus.

Answer:

Gradient Descent Weight Update Rule:

wij(l)←wij(l)−η∂E∂wij(l)w_{ij}^{(l)} \leftarrow w_{ij}^{(l)} - \eta \frac{\partial E}{\partial w_{ij}^{(l)}}

Where:

  • wᵢⱼ⁽ˡ⁾ = weight from neuron i in layer l−1 to neuron j in layer l
  • η = learning rate
  • E = error/loss function
  • ∂E/∂wᵢⱼ⁽ˡ⁾ = gradient of error with respect to weight

Chain Rule Derivation:

For output layer weight wⱼₖ⁽ᴸ⁾:

∂E∂wjk(L)=∂E∂y^k⋅∂y^k∂zk(L)⋅∂zk(L)∂wjk(L)\frac{\partial E}{\partial w_{jk}^{(L)}} = \frac{\partial E}{\partial \hat{y}_k} \cdot \frac{\partial \hat{y}_k}{\partial z_k^{(L)}} \cdot \frac{\partial z_k^{(L)}}{\partial w_{jk}^{(L)}}

Where:

  • z_k⁽ᴸ⁾ = Σⱼ wⱼₖ⁽ᴸ⁾ aⱼ⁽ᴸ⁻¹⁾ + bₖ⁽ᴸ⁾
  • ∂z_k⁽ᴸ⁾/∂wⱼₖ⁽ᴸ⁾ = aⱼ⁽ᴸ⁻¹⁾

Simplified Form:

∂E∂wjk(L)=δk(L)⋅aj(L−1)\frac{\partial E}{\partial w_{jk}^{(L)}} = \delta_k^{(L)} \cdot a_j^{(L-1)}

Where δ_k⁽ᴸ⁾ = ∂E/∂z_k⁽ᴸ⁾ (local gradient/error term).

For Hidden Layers (using chain rule recursively):

δj(l)=ϕ′(zj(l))∑kwjk(l+1)δk(l+1)\delta_j^{(l)} = \phi'(z_j^{(l)}) \sum_k w_{jk}^{(l+1)} \delta_k^{(l+1)}

Final Update Rule:

wij(l)←wij(l)−η⋅δj(l)⋅ai(l−1)w_{ij}^{(l)} \leftarrow w_{ij}^{(l)} - \eta \cdot \delta_j^{(l)} \cdot a_i^{(l-1)}

Intuition: Weights are adjusted in the direction opposite to the gradient (steepest descent) to minimize error.


Q18. Explain the role of Artificial Neural Networks in pattern recognition tasks with a concrete example.

Answer:

Role of ANNs in Pattern Recognition:

ANNs excel at pattern recognition because they:

  1. Learn hierarchical features automatically
  2. Handle high-dimensional data
  3. Generalize from training examples
  4. Are robust to noise and variations
  5. Can learn complex non-linear mappings

Concrete Example: Handwritten Digit Recognition (MNIST)

Task: Classify images of handwritten digits (0-9).

Network Architecture:

  • Input Layer: 784 neurons (28×28 pixel images, flattened)
  • Hidden Layer 1: 128 neurons with ReLU
  • Hidden Layer 2: 64 neurons with ReLU
  • Output Layer: 10 neurons with Softmax (one per digit)

Process:

  1. Forward Pass: Image pixels → weighted sums → activations → class probabilities
  2. Pattern Learning:
    • Early layers learn edges, strokes
    • Middle layers learn loops, curves
    • Later layers learn digit-specific features
  3. Output: Probability distribution over 10 digits
  4. Error: Cross-entropy loss between predicted and true label
  5. Backpropagation: Update weights to reduce error

Other Pattern Recognition Applications:

  • Speech Recognition: Convert audio to text (RNNs, Transformers)
  • Face Recognition: Identify individuals from images (CNNs)
  • Medical Diagnosis: Detect tumors in X-rays/MRIs
  • Fraud Detection: Identify anomalous transactions

Why ANNs Work: They learn feature representations directly from raw data, unlike traditional methods requiring hand-crafted features.


Q19. Discuss the convergence properties of the Perceptron Learning Rule versus Gradient Descent in Delta Rule learning.

Answer:

Perceptron Learning Rule:

Update Rule: wᵢ ← wᵢ + η(target − output)xᵢ (only when misclassified)

Convergence Properties:

  1. Guaranteed Convergence: If the data is linearly separable, the perceptron learning rule will converge to a solution in finite steps (Perceptron Convergence Theorem).
  2. No Convergence: If data is not linearly separable (e.g., XOR), the algorithm will never converge — weights oscillate indefinitely.
  3. Multiple Solutions: Can converge to any separating hyperplane, not necessarily optimal.
  4. No Probability: Outputs are hard 0/1, no confidence measure.
  5. Step Function: Not differentiable, so no gradient information.

Delta Rule (Gradient Descent) Learning:

Update Rule: wᵢ ← wᵢ + η(target − output)xᵢ (always updates)

Convergence Properties:

  1. Guaranteed Convergence: Converges to the least mean squared error (LMS) solution for any dataset (even non-separable).
  2. No Guarantee of Zero Error: For non-separable data, converges to minimum error, not zero error.
  3. Unique Solution: Converges to the unique LMS solution (for a given learning rate).
  4. Smooth Convergence: Uses differentiable activation (linear/sigmoid), enabling gradient computation.
  5. Learning Rate Sensitivity: Too high η → divergence; too low η → slow convergence.

Comparison Table:

PropertyPerceptron RuleDelta Rule
ActivationStep functionLinear/Sigmoid
ConvergenceOnly if linearly separableAlways (to LMS)
Error at ConvergenceZero (if separable)Minimum MSE
DifferentiableNoYes
UpdatesOnly on misclassificationEvery sample
SolutionAny separating hyperplaneUnique LMS solution

Key Insight: Delta rule generalizes perceptron rule to non-separable data and differentiable activations, forming the basis for backpropagation.


Q20. Analyze the vanishing gradient problem in deep feedforward networks trained via backpropagation and suggest methods to mitigate it.

Answer:

Vanishing Gradient Problem:

Definition: In deep networks, gradients of the error with respect to early-layer weights become extremely small (approach zero) during backpropagation, preventing effective learning in early layers.

Cause:

  • Backpropagation multiplies gradients layer by layer (chain rule).
  • Activation functions like Sigmoid/Tanh have derivatives ≤ 0.25 (sigmoid) or ≤ 1 (tanh).
  • For a network with L layers: gradient ∝ ∏ φ’(z⁽ˡ⁾)
  • With sigmoid: 0.25^L → exponentially small for large L.

Effect:

  • Early layers learn very slowly or not at all.
  • Network fails to learn hierarchical features.
  • Training becomes ineffective in deep networks.

Mathematical Illustration:

∂E∂w(1)=δ(L)∏l=2L(w(l)ϕ′(z(l−1)))\frac{\partial E}{\partial w^{(1)}} = \delta^{(L)} \prod_{l=2}^{L} \left( w^{(l)} \phi'(z^{(l-1)}) \right)

If φ’ ≤ 0.25 and w < 1, product → 0 exponentially.

Mitigation Methods:

  1. ReLU Activation:
    • φ’(z) = 1 for z > 0, 0 for z < 0
    • No vanishing for positive activations
    • Most common solution
  2. Batch Normalization:
    • Normalizes layer inputs, keeping them in the linear region of activations
    • Reduces internal covariate shift
  3. Residual Connections (ResNet):
    • Skip connections: a⁽ˡ⁾ = a⁽ˡ⁻¹⁾ + F(a⁽ˡ⁻¹⁾)
    • Gradient flows directly through skip connections
  4. Better Weight Initialization:
    • Xavier/Glorot initialization (for tanh)
    • He initialization (for ReLU)
    • Prevents gradients from shrinking/exploding
  5. LSTM/GRU (for RNNs):
    • Gating mechanisms control gradient flow
  6. Gradient Clipping:
    • Clips gradients to a maximum value (prevents explosion, not vanishing)
  7. Architectural Changes:
    • Use fewer layers
    • Use wider layers instead of deeper

Section 3: Bayesian Learning & Probabilistic Models


Q21. State Bayes Theorem, define each parameter (P(h), P(D), P(D|h), P(h|D)), and explain its significance in machine learning.

Answer:

Bayes Theorem:

P(h∣D)=P(D∣h)⋅P(h)P(D)P(h|D) = \frac{P(D|h) \cdot P(h)}{P(D)}

Parameter Definitions:

ParameterNameMeaning
P(h)Prior probabilityProbability of hypothesis h before observing data
P(D)Marginal likelihood / EvidenceProbability of observing data D under all hypotheses
**P(Dh)**Likelihood
**P(hD)**Posterior probability

Expanded Form:

P(h∣D)=P(D∣h)⋅P(h)∑h′∈HP(D∣h′)⋅P(h′)P(h|D) = \frac{P(D|h) \cdot P(h)}{\sum_{h' \in H} P(D|h') \cdot P(h')}

Significance in Machine Learning:

  1. Optimal Classification: Bayes theorem provides the theoretically optimal classifier (Bayes Optimal Classifier) that minimizes misclassification probability.
  2. Combining Prior Knowledge and Data: Allows incorporation of domain knowledge (prior) with empirical evidence (likelihood).
  3. Uncertainty Quantification: Provides probability distributions over hypotheses, not just point estimates.
  4. Foundation for Algorithms:
    • Naive Bayes classifier
    • Bayesian networks
    • Bayesian regression
    • Gaussian processes
  5. Model Comparison: Can compare models via P(model|data).
  6. Incremental Learning: Posterior from one dataset can serve as prior for the next.
  7. Regularization: Prior acts as a regularizer, preventing overfitting.

Q22. Differentiate clearly between Prior Probability P(h) and Posterior Probability P(h|D) in Bayesian learning.

Answer:

| Aspect | Prior Probability P(h) | Posterior Probability P(h|D) | | --- | --- | --- | | Definition | Probability of hypothesis h before seeing data | Probability of hypothesis h after seeing data D | | Timing | Before observation | After observation | | Basis | Domain knowledge, assumptions, previous experience | Prior + likelihood of observed data | | Formula | Given/assumed | P(h|D) = P(D|h)P(h)/P(D) | | Role | Initial belief | Updated belief | | Data Influence | Independent of data | Depends on data D | | Use | Starting point for Bayesian inference | Final answer for decision making | | Example | P(disease) = 0.01 (1% of population has disease) | P(disease|positive test) = 0.16 (after positive test) | | Symbol | P(h) | P(h|D) | | Bayesian Updating | Used as input | Output of Bayes theorem |

Example — Medical Diagnosis:

  • Prior: P(Cancer) = 0.01 (1% prevalence)
  • Likelihood: P(Positive|Cancer) = 0.9, P(Positive|No Cancer) = 0.1
  • Evidence: P(Positive) = 0.9×0.01 + 0.1×0.99 = 0.108
  • Posterior: P(Cancer|Positive) = (0.9×0.01)/0.108 = 0.083

The posterior (8.3%) is much higher than the prior (1%) because the positive test provides evidence for cancer.

Key Insight: Posterior = Prior updated by data. With more data, posterior becomes more accurate and less dependent on prior.


Q23. Explain how Bayes Theorem is applied to concept learning tasks and derive the relationship between Maximum A Posteriori (MAP) and Maximum Likelihood (ML) hypotheses.

Answer:

Bayes Theorem in Concept Learning:

In concept learning, we want to find the best hypothesis h from hypothesis space H given training data D.

P(h∣D)=P(D∣h)⋅P(h)P(D)P(h|D) = \frac{P(D|h) \cdot P(h)}{P(D)}
  • P(h): Prior probability of hypothesis h (before seeing data)
  • P(D|h): Likelihood — probability of observing data D if h is true
  • P(h|D): Posterior — probability h is correct after seeing D

Maximum A Posteriori (MAP) Hypothesis:

The MAP hypothesis is the most probable hypothesis given the data:

hMAP=arg⁡max⁡h∈HP(h∣D)=arg⁡max⁡h∈HP(D∣h)P(h)P(D)h_{MAP} = \arg\max_{h \in H} P(h|D) = \arg\max_{h \in H} \frac{P(D|h)P(h)}{P(D)}

Since P(D) is independent of h:

hMAP=arg⁡max⁡h∈HP(D∣h)⋅P(h)h_{MAP} = \arg\max_{h \in H} P(D|h) \cdot P(h)

Maximum Likelihood (ML) Hypothesis:

The ML hypothesis assumes all hypotheses are equally likely a priori (uniform prior):

hML=arg⁡max⁡h∈HP(D∣h)h_{ML} = \arg\max_{h \in H} P(D|h)

Derivation of Relationship:

Starting from MAP:

hMAP=arg⁡max⁡h∈HP(D∣h)⋅P(h)h_{MAP} = \arg\max_{h \in H} P(D|h) \cdot P(h)

If we assume uniform prior: P(hᵢ) = 1/|H| for all hᵢ ∈ H

Then:

hMAP=arg⁡max⁡h∈HP(D∣h)⋅1∣H∣=arg⁡max⁡h∈HP(D∣h)=hMLh_{MAP} = \arg\max_{h \in H} P(D|h) \cdot \frac{1}{|H|} = \arg\max_{h \in H} P(D|h) = h_{ML}

Conclusion:

  • ML is a special case of MAP when priors are uniform.
  • MAP = ML when P(h) is constant for all h.
  • If priors are not uniform, MAP and ML may differ.

Example: In learning a Boolean function, if all Boolean functions are equally likely, MAP = ML. If simpler functions have higher prior, MAP prefers simpler hypotheses.


Q24. Describe the Naive Bayes classification algorithm and write down its governing classification equation.

Answer:

Naive Bayes Classification Algorithm:

Assumption: Features are conditionally independent given the class label.

Goal: Classify a new instance x = (x₁, x₂, …, xₙ) into one of the classes y ∈ Y.

Governing Classification Equation:

yNB=arg⁡max⁡y∈YP(y)∏i=1nP(xi∣y)y_{NB} = \arg\max_{y \in Y} P(y) \prod_{i=1}^{n} P(x_i | y)

Where:

  • P(y) = prior probability of class y
  • P(xᵢ|y) = conditional probability of feature xᵢ given class y
  • ∏ = product over all features

Derivation from Bayes Theorem:

P(y∣x1,...,xn)=P(x1,...,xn∣y)⋅P(y)P(x1,...,xn)P(y|x_1, ..., x_n) = \frac{P(x_1, ..., x_n|y) \cdot P(y)}{P(x_1, ..., x_n)}

Using conditional independence:

P(x1,...,xn∣y)=∏i=1nP(xi∣y)P(x_1, ..., x_n|y) = \prod_{i=1}^{n} P(x_i|y)

Since P(x₁,…,xₙ) is constant for all y:

P(y∣x1,...,xn)∝P(y)∏i=1nP(xi∣y)P(y|x_1, ..., x_n) \propto P(y) \prod_{i=1}^{n} P(x_i|y)

Algorithm Steps:

  1. Training:
    • Calculate prior probabilities P(y) for each class.
    • Calculate conditional probabilities P(xᵢ|y) for each feature value and class.
    • Use Laplace smoothing to avoid zero probabilities.
  2. Prediction:
    • For a new instance x, compute P(y) · ∏P(xᵢ|y) for each class y.
    • Choose the class with maximum value.

Types:

  • Gaussian Naive Bayes: For continuous features (assumes normal distribution)
  • Multinomial Naive Bayes: For discrete counts (text classification)
  • Bernoulli Naive Bayes: For binary features

Advantages: Simple, fast, works well with small data, handles multi-class. Disadvantages: Independence assumption often violated.


Q25. Explain how Bayesian learning applies conditional probability to text/document classification or general attribute classification tasks.

Answer:

Bayesian Learning in Text Classification:

Task: Classify documents into categories (e.g., spam/not spam, sports/politics).

Representation: Document = bag of words (x₁, x₂, …, xₙ) where xᵢ = word presence/count.

Applying Bayes Theorem:

P(Class∣Document)=P(Document∣Class)⋅P(Class)P(Document)P(Class|Document) = \frac{P(Document|Class) \cdot P(Class)}{P(Document)}

Naive Bayes Assumption: Words are conditionally independent given the class.

P(Document∣Class)=P(w1,w2,...,wn∣Class)=∏i=1nP(wi∣Class)P(Document|Class) = P(w_1, w_2, ..., w_n|Class) = \prod_{i=1}^{n} P(w_i|Class)

Classification Rule:

ClassNB=arg⁡max⁡c∈CP(c)∏i=1nP(wi∣c)Class_{NB} = \arg\max_{c \in C} P(c) \prod_{i=1}^{n} P(w_i|c)

Training (Learning Parameters):

  1. Prior: P(c) = (number of documents in class c) / (total documents)

  2. Conditional Probability: (Laplace smoothing with vocabulary size |V|)

    P(wi∣c)=count of wi in documents of class c+1total words in class c+∣V∣P(w_i|c) = \frac{\text{count of } w_i \text{ in documents of class } c + 1}{\text{total words in class } c + |V|}

Example — Spam Filtering:

Training data:

  • Spam emails: 100
  • Non-spam emails: 200
  • P(Spam) = 100/300 = 0.33, P(Not Spam) = 0.67

For word “free”:

  • Appears 80 times in spam (out of 1000 words) → P(free|Spam) = 0.08
  • Appears 10 times in non-spam (out of 2000 words) → P(free|Not Spam) = 0.005

New email: “free money”

  • P(Spam|email) ∝ 0.33 × P(free|Spam) × P(money|Spam)
  • P(Not Spam|email) ∝ 0.67 × P(free|Not Spam) × P(money|Not Spam)

Classify as spam if P(Spam|email) > P(Not Spam|email).

General Attribute Classification:

For any attribute-value representation:

  • P(xᵢ|y) computed from frequency counts in training data.
  • Works for discrete attributes directly; continuous attributes need discretization or Gaussian assumption.

Q26. Analyze the impact of the “conditional independence assumption” in Naive Bayes classifiers when features are actually correlated.

Answer:

Conditional Independence Assumption:

Naive Bayes assumes: P(x₁, …, xₙ|y) = ∏ᵢ P(xᵢ|y)

This means features are independent of each other given the class label.

Impact When Features Are Correlated:

1. Probability Estimates Become Unreliable:

  • The product ∏P(xᵢ|y) overestimates or underestimates the true joint probability.
  • If features are positively correlated, the product double-counts evidence.
  • If negatively correlated, it under-counts.

2. Overconfident Predictions:

  • The classifier may become overconfident in its predictions.
  • Posterior probabilities are pushed toward 0 or 1.
  • Example: If “free” and “money” always appear together in spam, Naive Bayes counts them as two independent pieces of evidence, overestimating P(spam).

3. Classification Accuracy May Still Be Good:

  • Despite violated assumptions, Naive Bayes often performs well in practice.
  • Reason: For classification, we only need the argmax to be correct, not the exact probabilities.
  • Even if probabilities are poorly estimated, the correct class may still have the highest score.

4. Cases Where It Fails:

  • When correlated features provide redundant information.
  • When the correlation structure differs between classes.
  • Example: If x₁ = x₂ (perfectly correlated), Naive Bayes treats them as two independent features, effectively squaring the evidence.

5. Mathematical Illustration:

  • True: P(x₁=1, x₂=1|y) = 0.3 (correlated)
  • Naive Bayes: P(x₁=1|y) × P(x₂=1|y) = 0.6 × 0.6 = 0.36 (overestimate)

Mitigation:

  • Feature selection (remove correlated features)
  • Use Bayesian networks that model dependencies
  • Use decorrelation techniques (PCA)
  • Use Tree-Augmented Naive Bayes (TAN)

Conclusion: The independence assumption is a simplifying approximation. It makes computation tractable and often works well, but violates the true data-generating process when features are correlated.


Q27. Explain the zero-frequency problem (zero probability) in Naive Bayes classification and demonstrate how Laplace smoothing resolves it.

Answer:

Zero-Frequency Problem:

In Naive Bayes, if a feature value never appears with a particular class in training data, its conditional probability is zero:

P(xi∣y)=count(xi,y)count(y)=0P(x_i|y) = \frac{\text{count}(x_i, y)}{\text{count}(y)} = 0

Since classification uses a

product

:

P(y)∏i=1nP(xi∣y)P(y) \prod_{i=1}^{n} P(x_i|y)

If any P(xᵢ|y) = 0, the entire product becomes zero, regardless of other features.

Example:

  • Training: Class “Spam” never contains word “meeting”
  • P(meeting|Spam) = 0
  • New email: “meeting free money”
  • P(Spam|email) ∝ P(Spam) × P(meeting|Spam) × P(free|Spam) × P(money|Spam) = 0
  • The email is classified as “Not Spam” even if all other words strongly indicate spam.

Laplace Smoothing (Additive Smoothing):

Add a small constant α (usually 1) to all counts:

P(xi∣y)=count(xi,y)+αcount(y)+α⋅∣V∣P(x_i|y) = \frac{\text{count}(x_i, y) + \alpha}{\text{count}(y) + \alpha \cdot |V|}

Where:

  • α = smoothing parameter (α=1 for Laplace)
  • |V| = number of possible values for feature xᵢ (vocabulary size)

Effect:

  • No probability is ever exactly zero.
  • Unseen feature values get a small non-zero probability.
  • The sum of probabilities still equals 1.

Example (with α=1):

  • Vocabulary size |V| = 1000
  • count(meeting, Spam) = 0
  • count(Spam) = 500
  • P(meeting|Spam) = (0+1)/(500+1000) = 1/1500 ≈ 0.00067 (not zero)

Variations:

  • Lidstone Smoothing: α ≠ 1 (smaller α → less smoothing)
  • Laplace: α = 1
  • No smoothing: α = 0 (original)

Benefits:

  • Prevents zero probabilities
  • Improves generalization to unseen data
  • Reduces overfitting
  • Makes classifier more robust

Q28. Compare Bayesian learning approaches with Decision Tree learning in terms of handling noise, continuous data, and prior knowledge.

Answer:

AspectBayesian LearningDecision Tree Learning
Noise HandlingProbabilistic framework naturally handles noise; outliers have low likelihood but don’t break the modelSensitive to noise; outliers can create spurious splits; pruning helps but doesn’t eliminate
Continuous DataHandles naturally with probability distributions (Gaussian, etc.); no discretization neededRequires discretization of continuous attributes (binary splits in C4.5); may lose information
Prior KnowledgeExplicitly incorporated via prior probabilities P(h); domain knowledge can be encodedLimited; inductive bias is fixed (prefer shorter trees, high gain attributes); no explicit prior mechanism
Missing ValuesHandles elegantly by marginalizing over missing values; can compute probabilities without themRequires special handling (C4.5 distributes instances proportionally); less natural
OverfittingLess prone with proper priors; Bayesian regularizationProne to overfitting; needs pruning (pre/post)
InterpretabilityLess interpretable (probabilistic parameters); but can compute confidenceHighly interpretable (if-then rules, tree structure)
Computational ComplexityCan be expensive (summing over hypothesis space); Naive Bayes is efficientEfficient (greedy, recursive partitioning)
Data RequirementsWorks well with small data if priors are good; Naive Bayes needs less dataNeeds sufficient data to make reliable splits; can overfit with small data
Multi-classNatural extension; computes P(yx) for all classes
AssumptionsConditional independence (Naive Bayes) or specific distributionsAxis-parallel splits; no distributional assumptions
OutputProbability distribution over classesClass label + confidence from leaf purity

Summary:

  • Bayesian learning is more principled, handles uncertainty and prior knowledge naturally, and is robust to noise, but can be computationally expensive and less interpretable.
  • Decision trees are intuitive, fast, and interpretable, but sensitive to noise, require discretization for continuous data, and have limited prior incorporation.
  • Practical Note: Choice depends on the problem — Bayesian methods for probabilistic reasoning and small data; decision trees for interpretable rule-based systems and large discrete datasets.

Q29. Explain how the Find-S algorithm operates and contrast how it handles negative training instances versus positive instances.

Answer:

Find-S Algorithm:

Purpose: Finds the most specific hypothesis consistent with all positive training examples.

Hypothesis Representation: Conjunction of attribute constraints: h = ⟨a₁, a₂, …, aₙ⟩ where each aᵢ is either:

  • A specific value (e.g., “Sunny”)
  • “?” (any value acceptable)
  • “∅” (no value acceptable — only for empty hypothesis)

Algorithm Steps:

  1. Initialize h to the most specific hypothesis: h = ⟨∅, ∅, …, ∅⟩ (no positive instances covered)
  2. For each positive training example x:
    • For each attribute constraint aᵢ in h:
      • If aᵢ = ∅ → replace with xᵢ (first positive example)
      • If aᵢ ≠ xᵢ → replace aᵢ with “?” (generalize)
      • If aᵢ = “?” → keep as “?” (already general)
    • (h becomes more general to cover the new positive example)
  3. Negative examples: Ignored completely.
  4. Output final hypothesis h.

Example:

Training data:

SkyAirTempHumidityWindWaterForecastEnjoySport
SunnyWarmNormalStrongWarmSameYes
SunnyWarmHighStrongWarmSameYes
RainyColdHighStrongWarmChangeNo
SunnyWarmHighStrongCoolChangeYes

Find-S process:

  1. h = ⟨∅, ∅, ∅, ∅, ∅, ∅⟩
  2. First positive: h = ⟨Sunny, Warm, Normal, Strong, Warm, Same⟩
  3. Second positive: Humidity differs (Normal vs High) → h = ⟨Sunny, Warm, ?, Strong, Warm, Same⟩
  4. Negative example ignored.
  5. Third positive: Water differs (Warm vs Cool), Forecast differs (Same vs Change) → h = ⟨Sunny, Warm, ?, Strong, ?, ?⟩

Final hypothesis: ⟨Sunny, Warm, ?, Strong, ?, ?⟩

Handling of Positive vs. Negative Instances:

AspectPositive InstancesNegative Instances
RoleUsed to generalize hypothesisCompletely ignored
Effect on hh becomes more general (specific → “?”)No effect
ConsistencyEnsures h covers all positivesDoes not ensure h excludes negatives
Why?Find-S only seeks the most specific hypothesis consistent with positivesNegative examples could make h more specific, but Find-S chooses not to use them

Limitations:

  1. Ignores negative examples: May output a hypothesis that covers negative instances.
  2. No backtracking: Cannot recover from a too-general hypothesis.
  3. Inconsistent data: If positive examples conflict, h may become overly general (“?” for all).
  4. Single hypothesis: Doesn’t represent uncertainty (unlike version space).

Contrast with Candidate Elimination: Candidate Elimination uses both positive and negative examples to maintain S (specific) and G (general) boundaries of the version space.


Q30. Compare Maximum A Posteriori (MAP) hypothesis with Minimum Description Length (MDL) principle in probabilistic machine learning.

Answer:

Maximum A Posteriori (MAP) Hypothesis:

hMAP=arg⁡max⁡h∈HP(h∣D)=arg⁡max⁡h∈HP(D∣h)⋅P(h)h_{MAP} = \arg\max_{h \in H} P(h|D) = \arg\max_{h \in H} P(D|h) \cdot P(h)
  • Finds the most probable hypothesis given data and prior.
  • Balances likelihood (fit to data) with prior (complexity/preference).

Minimum Description Length (MDL) Principle:

hMDL=arg⁡min⁡h∈H[LC1(h)+LC2(D∣h)]h_{MDL} = \arg\min_{h \in H} \left[ L_{C_1}(h) + L_{C_2}(D|h) \right]

Where:

  • L_{C₁}(h) = description length of hypothesis h (bits)
  • L_{C₂}(D|h) = description length of data D encoded using h (bits)
  • MDL states: The best hypothesis minimizes the total description length (hypothesis + data given hypothesis).
  • Based on Occam’s Razor: Simpler hypotheses (shorter descriptions) are preferred.

Relationship Between MAP and MDL:

Using Shannon’s information theory: The optimal code length for an event with probability p is −log₂(p) bits.

hMAP=arg⁡max⁡hP(D∣h)P(h)h_{MAP} = \arg\max_h P(D|h)P(h) =arg⁡max⁡hlog⁡2P(D∣h)+log⁡2P(h)= \arg\max_h \log_2 P(D|h) + \log_2 P(h) =arg⁡min⁡h[−log⁡2P(D∣h)−log⁡2P(h)]= \arg\min_h \left[ -\log_2 P(D|h) - \log_2 P(h) \right] =arg⁡min⁡h[L(D∣h)+L(h)]=hMDL= \arg\min_h \left[ L(D|h) + L(h) \right] = h_{MDL}

Therefore: MAP and MDL are equivalent when:

  • L(h) = −log₂ P(h)
  • L(D|h) = −log₂ P(D|h)

Comparison Table:

AspectMAPMDL
FoundationBayesian probabilityInformation theory / coding
ObjectiveMaximize posterior probabilityMinimize total description length
Trade-offLikelihood vs. priorData fit vs. hypothesis complexity
PriorExplicit P(h)Implicit via description length L(h)
InterpretationMost probable hypothesisBest compression of data
AssumptionsPrior distribution knownCoding scheme chosen
OutputSingle hypothesisSingle hypothesis
EquivalenceMAP = MDL when code lengths = −log probabilitiesMDL = MAP when probabilities = 2^(−length)

Example — Decision Tree Learning:

  • MAP: Prefer trees with high P(D|h) × P(h), where P(h) penalizes complex trees.
  • MDL: Prefer trees that minimize (tree description length + misclassification encoding length).

Both lead to Occam’s Razor: simpler hypotheses that fit data well are preferred.

Key Insight: MDL provides an information-theoretic justification for Bayesian model selection. The prior P(h) in MAP corresponds to the description length of the hypothesis in MDL.


On this page