MACHINE LEARNING

106403
Back to MACHINE LEARNING

Module 3: Classification Algorithms

  1. Q1f. Which of the following is true about Naive Bayes? (i) Assumes that all the features in a dataset are equally important (ii) Assumes that all the features in a dataset are independent (ii) Both (i) and (ii) (iv) None of the above20222m

    Module 3: Classification Algorithms

    Which of the following is true about Naive Bayes?
    (i) Assumes that all the features in a dataset are equally important
    (ii) Assumes that all the features in a dataset are independent
    (ii) Both (i) and (ii)
    (iv) None of the above

    View this question on its own page →
    Worked Solution

    Answer: (ii) Assumes that all features are independent (given the class) — note option numbering duplicate, intended as (ii). Strictly Naive Bayes assumes conditional independence; (i) is not an assumption.

    Clarification:

    Naive Bayes classifier: P(y∣x1..xn)∝P(y)∏iP(xi∣y)P(y|x_1..x_n) \propto P(y)\prod_i P(x_i|y)

    • Assumption: Features are conditionally independent given class xi⊥xj∣yx_i \perp x_j | y. That is (ii) essentially. This is strong/naive.
    • It does NOT assume all features equally important (i) — importance is implicitly learned via P(xi∣y)P(x_i|y) likelihoods; correlated important features still get weight. Equal importance is not required.
    • The option list has typo: second (ii) should be (iii) Both (i) and (ii). Since (i) is false, Both is false.
    • Therefore correct is only independence assumption → (ii). Some keys mark (ii) Both due to loose teaching, but precise answer is independence only.

    If exam expects textbook shortcut "Naive Bayes assumes independence and equal importance", some mark (iii) Both — mention this nuance.

  2. Q1g. The feature of ANN in which ANN creates its own organization or representation of information it receives during learning time is (i) adaptive learning (ii) self-organization (iii) what-if analysis (iv) supervised learning20222m

    Module 3: Classification Algorithms

    The feature of ANN in which ANN creates its own organization or representation of information it receives during learning time is
    (i) adaptive learning
    (ii) self-organization
    (iii) what-if analysis
    (iv) supervised learning

    View this question on its own page →
    Worked Solution

    Answer: (ii) self-organization

    Explanation:

    ANN features:

    • Adaptive learning (i): Ability to learn to perform tasks based on data.
    • Self-organization (ii): ANN creates its own representation/organization of information it receives during learning — weights self-adjust to capture structure. Best exemplified by Kohonen Self-Organizing Maps (SOM) and also hidden layer representations in general ANNs.
    • What-if analysis is not ANN-specific.
    • Supervised learning requires external target labels.

    The phrase "creates its own organization of information it receives during learning time" is textbook definition of self-organization (also called self-organisation / unsupervised adaptation).

    Hence (ii) self-organization.

  3. Q1g. What is a support vector? (i) The distance between any two data points (ii) The average distance between all data points (iii) The distance between any two boundary data points . (iv)The minimum distance between any two data points20232m

    Module 3: Classification Algorithms

    What is a support vector?
    (i) The distance between any two data points
    (ii) The average distance between all data points
    (iii) The distance between any two boundary data points .
    (iv)The minimum distance between any two data points

    View this question on its own page →
    Worked Solution

    Answer: None of the given options is precisely correct. The closest educational intent is (iii), but technically support vectors are data points, not a distance.

    Correct definition:
    A support vector is a training sample that lies closest to the decision hyperplane and directly influences its position and orientation. For a hard-margin SVM with hyperplane wTx+b=0w^T x + b = 0:

    wTxi+b=±1w^T x_i + b = \pm 1 for support vectors, and margin =2/∣∣w∣∣= 2/||w||.

    • (i) distance between any two data points — false
    • (ii) average distance — false
    • (iii) distance between any two boundary data points — confuses support vector (a point) with margin (a distance)
    • (iv) minimum distance between any two data points — false

    If forced to choose: Many university keys mark (iii) as expected answer, interpreting support vectors as the points that define the minimum distance (margin) between classes. Ideally answer should be: "the training vectors closest to the hyperplane that satisfy yi(wTxi+b)=1y_i(w^T x_i+b)=1".

  4. Q1h. Which of the following is true about averaging ensemble? (i) It can only be used in classification problem (ii) It can only be used in regression problem (ii) It can be used in both classification as well as regression (iv) None of the above20222m

    Module 3: Classification Algorithms

    Which of the following is true about averaging ensemble?
    (i) It can only be used in classification problem
    (ii) It can only be used in regression problem
    (ii) It can be used in both classification as well as regression
    (iv) None of the above

    View this question on its own page →
    Worked Solution

    Answer: (iii) It can be used in both classification as well as regression — corrected from typo second (ii)

    Explanation — Averaging Ensemble:

    • Bagging / Voting / Averaging: Train MM base learners on bootstrap samples, average predictions: y^=1M∑mfm(x)\hat{y}= \frac1M\sum_m f_m(x) for regression, or soft voting / probability averaging for classification.
    • Classification: averaging predicted probabilities or logits, e.g., Random Forest classification by majority vote (which is averaging indicator) or averaging probabilities.
    • Regression: direct average of continuous outputs, e.g., Random Forest regressor.
    • Reduces variance, improves generalization.

    So NOT limited to only classification or only regression. Hence (iii) Both (intended as third option despite mislabeled).

    Options had typo: listed (ii) twice; correct mapping: (iii) It can be used in both...

  5. Q1h. In neural network. which of the following techniques is used to deal with over fitting? × (i) Dropout (ii) Regularization. (iii) Batch normalization (iv) All of the above20232m

    Module 3: Classification Algorithms

    In neural network. which of the following techniques is used to deal with over fitting? ×
    (i) Dropout
    (ii) Regularization.
    (iii) Batch normalization
    (iv) All of the above

    View this question on its own page →
    Worked Solution

    Answer: (iv) All of the above

    Explanation — techniques to deal with overfitting in Neural Networks:

    1. Dropout (i): Randomly drops neurons (with prob p∼0.2−0.5p\sim0.2-0.5) during training. Prevents co-adaptation, acts as ensemble approximation. Used in fully connected layers.

    2. Regularization (ii):

      • L2 (weight decay): adds λ∣∣w∣∣22\lambda ||w||_2^2 to loss, penalizes large weights.
      • L1: adds λ∣∣w∣∣1\lambda ||w||_1, induces sparsity.
      • Makes model simpler and generalizes better.
    3. Batch Normalization (iii): Normalizes layer inputs per mini-batch to zero mean/unit variance. Reduces internal covariate shift, allows higher learning rates, has slight regularization effect due to noise from batch statistics.

    Other methods: Early stopping, data augmentation, reducing network capacity, cross-validation.

    Since dropout, L1/L2 regularization and batch norm all help reduce overfitting, (iv) All of the above is correct.

  6. Q1j. Which of the following is the best algorithm for text classification? (i) KNN - (ii) Decision tree (iii) Random forest (iv) Naive Bayes20232m

    Module 3: Classification Algorithms

    Which of the following is the best algorithm for text classification?
    (i) KNN -
    (ii) Decision tree
    (iii) Random forest
    (iv) Naive Bayes

    View this question on its own page →
    Worked Solution

    Answer: (iv) Naive Bayes — generally considered best baseline for text classification, though context dependent.

    Explanation:

    • Naive Bayes (Multinomial/Bernoulli): Highly effective for high-dimensional sparse text (Bag-of-Words / TF-IDF). Fast, works well with small data, handles thousands of features, empirically strong for spam, sentiment, topic classification. Assumption of conditional independence of words given class surprisingly works well in practice.
    • KNN: Lazy, computationally expensive at inference, suffers from curse of dimensionality in text.
    • Decision Tree: Prone to overfit on sparse text, not ideal.
    • Random Forest: Better than single tree but slower and often still outperformed by NB/SVM for raw text without embeddings.

    In modern deep learning era, Transformers/BERT outperform all, but among given classical options, Naive Bayes (and Linear SVM — not listed) is textbook best for text. Some keys may accept Random Forest as competitive, but traditional exam answer is (iv) Naive Bayes.

  7. Q2b. What is decision tree algorithm? What are the issues in decision tree induction?20227m

    Module 3: Classification Algorithms

    What is decision tree algorithm? What are the issues in decision tree induction?

    View this question on its own page →
    Worked Solution

    Decision Tree Algorithm:
    Tree where internal nodes test attribute, branches = values, leaves = class. Learns by greedy top-down, divide-and-conquer.

    Algorithm (ID3/C4.5):

    1. If all examples same class or attributes empty → leaf.
    2. Choose best attribute AA by Information Gain Gain(S,A)=Entropy(S)−∑v(∣Sv∣/∣S∣)Entropy(Sv)Gain(S,A)=Entropy(S)-\sum_v (|S_v|/|S|)Entropy(S_v) (or Gain Ratio, Gini).
    3. Split SS by AA values, recurse on subsets.

    Entropy: H(S)=−∑pilog⁡2piH(S)= -\sum p_i \log_2 p_i

    Issues in Decision Tree Induction:

    1. Choosing attribute selection measure: Gain biases to many-valued attributes → Gain Ratio (C4.5) or Gini (CART).
    2. Overfitting: Tree grows until pure, memorizes noise. Solutions: pre-pruning (stop early, min samples/chi-square), post-pruning (reduced-error pruning, cost-complexity), validation set.
    3. Underfitting / Bias: Too shallow tree misses pattern.
    4. Handling continuous attributes: Need discretization — find best split threshold x<tx < t.
    5. Handling missing values: Surrogate splits, fractional examples, imputation (C4.5).
    6. Incorporating costs / noisy data: Different misclassification costs, pruning for noise robustness.
    7. Inconsistent data / Large hypothesis space: Exponential 3n3^n possible trees; greedy may get local optimum, not globally optimal (NP-hard).
    8. Instability: Small data change → large tree change; ensemble methods (Random Forest) mitigate.
    9. Class imbalance, oblique splits, scalability for large datasets.
  8. Q3b. How does Back Propagation Rule help in learning in Neural Network?20237m

    Module 3: Classification Algorithms

    How does Back Propagation Rule help in learning in Neural Network?

    View this question on its own page →
    Worked Solution

    Backpropagation Rule — How it Helps Learning in Neural Networks:

    Neural network learns by minimizing loss L=12∑(y−y^)2L = \frac12\sum (y-\hat y)^2 or cross-entropy via gradient descent. Backpropagation efficiently computes ∂L/∂w\partial L/\partial w for all weights using chain rule, propagating error backward.

    Steps:

    1. Forward pass: For each layer ll: z(l)=W(l)a(l−1)+b(l)z^{(l)}=W^{(l)}a^{(l-1)}+b^{(l)}, a(l)=σ(z(l))a^{(l)}=\sigma(z^{(l)}). Compute loss LL.
    2. Backward pass:
      • Output error: $\delta^{(L)} =
        abla_a L \odot \sigma'(z^{(L)})$
      • Propagate: δ(l)=(W(l+1)Tδ(l+1))⊙σ′(z(l))\delta^{(l)} = (W^{(l+1)T}\delta^{(l+1)})\odot \sigma'(z^{(l)})
      • Gradients: ∂L∂W(l)=δ(l)a(l−1)T\frac{\partial L}{\partial W^{(l)}} = \delta^{(l)} a^{(l-1)T}, ∂L∂b(l)=δ(l)\frac{\partial L}{\partial b^{(l)}} = \delta^{(l)}
    3. Update: W:=W−η∂L∂WW := W - \eta \frac{\partial L}{\partial W}, b:=b−η∂L∂bb:=b-\eta \frac{\partial L}{\partial b}

    Why crucial:

    • Makes training deep networks computationally feasible O(∣W∣)O(|W|) instead of naive O(∣W∣2)O(|W|^2).
    • Enables learning of hierarchical features (early layers edges, deeper semantic).
    • Works with any differentiable activation (sigmoid, ReLU, tanh).
    • Basis for SGD, Adam optimization.

    Example: 2-layer MLP with MSE: error at output δ=(y^−y)⋅σ′(z)\delta = (\hat y - y)\cdot \sigma'(z), hidden error δh=W2Tδ⋅σ′(zh)\delta_h = W_2^T \delta \cdot \sigma'(z_h) — weight updates proportional to contribution to error (credit assignment). Without backprop, no efficient credit assignment across layers would be possible.

    Extensions: Batch norm, dropout, gradient clipping to stabilize backprop, avoid vanishing/exploding gradients.

  9. Q4. Explain how the linear maximum-margin classifier can be modified to be non-linear and to allow misclassification of the training examples. Give a derivation of the modified optimization problem needed for training. You need only derive a statement of the primal optimization problem.202214m

    Module 3: Classification Algorithms

    Explain how the linear maximum-margin classifier can be modified to be non-linear and to allow misclassification of the training examples. Give a derivation of the modified optimization problem needed for training. You need only derive a statement of the primal optimization problem.

    View this question on its own page →
    Worked Solution

    Linear Maximum-Margin Classifier (Hard SVM):

    Primal: min⁡w,b12∣∣w∣∣2\min_{w,b} \frac12||w||^2 s.t. yi(wTxi+b)≥1y_i(w^T x_i + b) \ge 1, yi∈{−1,1}y_i\in\{-1,1\}

    Margin =2/∣∣w∣∣=2/||w||, support vectors satisfy equality. Only linear separable case, no slack.

    Modifications for Non-linear and Non-separable:

    1. Allow misclassification (Soft Margin): Introduce slack ξi≥0\xi_i \ge 0:
      yi(wTxi+b)≥1−ξiy_i(w^T x_i+b) \ge 1-\xi_i. ξi>0\xi_i>0 violates margin, ξi>1\xi_i>1 misclassifies. Add penalty C∑ξiC\sum\xi_i.

    2. Make Non-linear via Feature Map ϕ(x)\phi(x) and Kernel: Map x→ϕ(x)x\to\phi(x) to higher dimension where linear separation possible. Replace wTxw^T x with wTϕ(x)w^T\phi(x). Kernel trick: K(xi,xj)=ϕ(xi)Tϕ(xj)K(x_i,x_j)=\phi(x_i)^T\phi(x_j) avoids explicit high-dim computation (Polynomial, RBF).

    Derivation — Primal for Soft-Margin Non-linear SVM:

    Minimize over w,b,ξw,b,\xi:
    min⁡w,b,ξ12∣∣w∣∣2+C∑i=1nξi\min_{w,b,\xi} \frac12||w||^2 + C\sum_{i=1}^n \xi_i
    s.t. yi(wTϕ(xi)+b)≥1−ξiy_i(w^T\phi(x_i)+b) \ge 1-\xi_i, ξi≥0\xi_i \ge 0, i=1..ni=1..n

    • First term maximizes margin (1/∣∣w∣∣1/||w||).
    • Second penalizes violations; CC trades margin width vs training error (small CC wider margin more violations, large CC hard margin approx).
    • ξi=max⁡(0,1−yi(wTϕ(xi)+b))\xi_i = \max(0, 1-y_i(w^T\phi(x_i)+b)) = hinge loss.

    If separable, optimum ξi=0\xi_i=0 recovers hard margin. Non-linear version retains same form with ϕ\phi. Dual leads to w=∑αiyiϕ(xi)w=\sum\alpha_i y_i\phi(x_i) and kernelized decision f(x)=∑αiyiK(xi,x)+ ⁣bf(x)=\sum\alpha_i y_i K(x_i,x)+\!b.

    Without slack & kernel, linear separable only; with them, general-purpose classifier.

  10. Q4a. Discuss various issues in Decision Tree Learning.20237m

    Module 3: Classification Algorithms

    Discuss various issues in Decision Tree Learning.

    View this question on its own page →
    Worked Solution

    Issues in Decision Tree Learning:

    1. Determining Correct Depth / Overfitting: Fully grown tree overfits training data (memorizes noise). Need pruning.

      • Pre-pruning: Stop early via max_depth, min_samples_split, χ2\chi^2 test, information gain threshold.
      • Post-pruning: Grow full, then prune using validation set (reduced-error pruning, cost-complexity pruning in CART with α\alpha).
    2. Attribute Selection Measure: Information Gain biases to many-valued attributes (e.g., ID column). Gain Ratio (C4.5) normalizes by SplitInfo, Gini index (CART), or use least biased measures.

    3. Handling Continuous Attributes: Need to find optimal threshold tt for split A≤tA \le t vs >t>t by sorting values and evaluating gain for candidate mid-points — O(nlog⁡n)O(n\log n) per attribute.

    4. Handling Missing Values: Training: ignore missing or distribute fractionally (C4.5). Testing: follow both branches weighted. Alternatives: surrogate splits (CART), imputation.

    5. Handling Noisy Data & Outliers: Noise causes incorrect splits; pruning and robust measures (e.g., use majority voting at leaves) help.

    6. Inconsistent Data: Same feature vector with different labels → cannot achieve 100% accuracy; need probabilistic leaves.

    7. Computational Complexity: Finding optimal tree is NP-hard; greedy heuristics may produce locally optimal but globally suboptimal trees. Ensembles mitigate.

    8. Data Fragmentation: Splits reduce sample per leaf, estimates unreliable at deep levels.

    9. Instability / High Variance: Small data perturbations → very different tree (solved by Random Forest bagging).

    10. Class Imbalance: Majority class dominates gain; need weighted entropy, stratified sampling, cost-sensitive splits.

    11. Replicated Subtrees & Oblique Splits: Axis-parallel splits cannot represent diagonal boundaries efficiently → need multivariate trees.

  11. Budget App•POCKETLY

    Pocketly on Android

    Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.

    Install Pocketly
  12. Q4b. Discuss with examples of instance-based learning algorithms.20237m

    Module 3: Classification Algorithms

    Discuss with examples of instance-based learning algorithms.

    View this question on its own page →
    Worked Solution

    Instance-Based Learning (Lazy Learning): Stores training instances, delays generalization until query. Prediction via similarity to stored instances, not explicit model.

    General steps: Store D={(xi,yi)}D=\{(x_i,y_i)\}; for query xqx_q, find kk nearest neighbors by distance (Euclidean/Manhattan/cosine), combine (majority vote / weighted average / local regression).

    Examples:

    1. k-Nearest Neighbors (k-NN):

      • Classification: y^=arg⁡max⁡c∑xi∈Nk(xq)I(yi=c)\hat y = \arg\max_c \sum_{x_i\in N_k(x_q)} \mathbb{I}(y_i=c) (optionally distance-weighted: wi=1/d(xq,xi)2w_i=1/d(x_q,x_i)^2)
      • Regression: y^=1k∑yi\hat y = \frac1k\sum y_i
      • Choose kk via CV; small kk flexible but noisy, large kk smooth but underfits. Need feature scaling, handles multi-modal, no training time, slow query O(nd)O(n d), needs KD-tree/ball-tree for speed. Pros: simple, effective with many data. Cons: curse of dimensionality, sensitive to irrelevant features.
    2. Locally Weighted Regression (LWR):

      • Fits local model (e.g., linear) weighted by kernel wi=exp⁡(−d(xq,xi)2/2τ2)w_i=\exp(-d(x_q,x_i)^2/2\tau^2). Prediction f^(xq)=xqTβq \hat f(x_q)=x_q^T\beta_q where βq=(XTWX)−1XTWy\beta_q=(X^T W X)^{-1}X^T W y.
      • Example: LOESS for smoothing.
    3. Case-Based Reasoning (CBR): Solves new problems by adapting solutions from similar past cases (e.g., medical diagnosis: retrieve similar patient cases, adapt treatment). Retrieve-Reuse-Revise-Retain cycle.

    4. Radial Basis Function (RBF) Network (kernel memory based): Some interpretations include it.

    Characteristics: No explicit training, incremental easily, ability to model complex boundaries locally, but memory intensive, needs careful distance metric selection and feature weighting.

  13. Q5. Following is a data set that contains two attributes, X and Y, and two class labels, ‘+’ and ‘–’. Each attribute can take three different values: 0, 1, or 2. The concept for the ‘+’ class is Y = 1 and the concept for the ‘–’ class is X = 0 ∨ X = 2. ![image](https://res.cloudinary.com/djkpavwmp/image/upload/v1764335073/q5_zh4zj9.png) (a) Build a decision tree on the data set. Does the tree capture the ‘+’ and ‘–’ concepts? (b) What are the accuracy, precision, recall and F1-measure of the decision tree? (Note that precision, recall, and F1-measure are defined with respect to the ‘+’ class.)202214m

    Module 3: Classification Algorithms

    Following is a data set that contains two attributes, X and Y, and two class labels, ‘+’ and ‘–’.
    Each attribute can take three different values: 0, 1, or 2.

    The concept for the ‘+’ class is Y = 1
    and the concept for the ‘–’ class is X = 0 ∨ X = 2.

    image

    (a)
    Build a decision tree on the data set.
    Does the tree capture the ‘+’ and ‘–’ concepts?

    (b)
    What are the accuracy, precision, recall and F1-measure of the decision tree?
    (Note that precision, recall, and F1-measure are defined with respect to the ‘+’ class.)

    View this question on its own page →
  14. Q5a. State the mathematical formulation of the SVM problem. Give an outline of the method for solving the problem.20237m

    Module 3: Classification Algorithms

    State the mathematical formulation of the SVM problem. Give an outline of the method for solving the problem.

    View this question on its own page →
    Worked Solution

    Mathematical Formulation of SVM Problem:

    Given D={(xi,yi)},yi∈{−1,1}D=\{(x_i,y_i)\}, y_i\in\{-1,1\}, i=1..ni=1..n.

    Primal (Soft-margin, most general):

    min⁡w,b,ξ12∣∣w∣∣2+C∑i=1nξi\min_{w,b,\xi} \frac12||w||^2 + C\sum_{i=1}^n \xi_i
    s.t. yi(wTxi+b)≥1−ξiy_i(w^T x_i + b) \ge 1-\xi_i, ξi≥0\xi_i \ge 0

    Hard margin special case C→∞C\to\infty, ξi=0\xi_i=0.

    Dual (Wolfe Dual, kernelizable):

    Using Lagrange multipliers αi≥0\alpha_i\ge0, μi≥0\mu_i\ge0:
    L=12∣∣w∣∣2+C∑ξi−∑αi[yi(wTxi+b)−1+ξi]−∑μiξiL = \frac12||w||^2 +C\sum\xi_i -\sum\alpha_i[y_i(w^T x_i+b)-1+\xi_i] -\sum\mu_i\xi_i

    KKT: w=∑αiyixiw=\sum\alpha_i y_i x_i, ∑αiyi=0\sum\alpha_i y_i=0, C−αi−μi=0C-\alpha_i-\mu_i=0

    Dual:
    max⁡α∑iαi−12∑i,jαiαjyiyjK(xi,xj)\max_{\alpha} \sum_i \alpha_i -\frac12\sum_{i,j}\alpha_i\alpha_j y_i y_j K(x_i,x_j)
    s.t. 0≤αi≤C0\le\alpha_i\le C, ∑iαiyi=0\sum_i \alpha_i y_i =0

    K(xi,xj)=xiTxjK(x_i,x_j)=x_i^T x_j (linear) or kernel K=ϕ(xi)Tϕ(xj)K=\phi(x_i)^T\phi(x_j).

    Decision: f(x)=sign(∑i:αi>0αiyiK(xi,x)+b)f(x)=sign(\sum_{i:\alpha_i>0}\alpha_i y_i K(x_i,x)+b), bb from support vectors where 0<αi<C0<\alpha_i<C via ys(∑αiyiK(xi,xs)+b)=1y_s(\sum\alpha_i y_i K(x_i,x_s)+b)=1.

    Outline of Method for Solving:

    1. Choose CC (and kernel hyperparameters γ\gamma via CV).
    2. Solve Quadratic Programming dual for α\alpha ( convex QP). Use algorithms: SMO (Sequential Minimal Optimization) — iteratively optimizes pair of α\alpha analytically, efficient O(n)O(n); or interior point, gradient ascent.
    3. Identify Support Vectors αi>0\alpha_i>0 (approx 10−510^{-5}). SVs on margin 0<αi<C0<\alpha_i<C, inside/errors αi=C\alpha_i=C.
    4. Compute ww (implicitly via kernel) and bb averaging over margin SVs.
    5. Classify new xx via sign of kernel expansion.

    For large data, use LIBSVM / LIBLINEAR, Pegasos (primal SGD).

    Properties: Convex, global optimum, sparsity (only SVs matter), max margin minimizes VC bound, good generalization.

  15. Q6. For the Sun Burn data set given below, construct a decision tree. | Name | Hair | Height | Weight | Location | Class | |--------|--------|----------|---------|----------|-------| | Sunita | Blonde | Average | Light | No | Yes | | Anita | Blonde | Tall | Average | Yes | No | | Kavita | Brown | Short | Average | Yes | No | | Sushma | Blonde | Short | Average | No | Yes | | Xavier | Red | Average | Heavy | No | Yes | | Balaji | Brown | Tall | Heavy | No | No | | Ramesh | Brown | Average | Heavy | No | No | | Sweta | Blonde | Short | Light | Yes | No |202314m

    Module 3: Classification Algorithms

    For the Sun Burn data set given below, construct a decision tree.

    Name Hair Height Weight Location Class
    Sunita Blonde Average Light No Yes
    Anita Blonde Tall Average Yes No
    Kavita Brown Short Average Yes No
    Sushma Blonde Short Average No Yes
    Xavier Red Average Heavy No Yes
    Balaji Brown Tall Heavy No No
    Ramesh Brown Average Heavy No No
    Sweta Blonde Short Light Yes No
    View this question on its own page →
    Worked Solution

    Sun Burn Decision Tree Construction (ID3 style):

    Dataset: 8 examples, 4 attributes + Class {Yes=3, No=5}
    Entropy H(S)=−(3/8)log⁡2(3/8)−(5/8)log⁡2(5/8)=0.954H(S)= - (3/8)\log_2(3/8) - (5/8)\log_2(5/8)=0.954

    Evaluate each attribute Information Gain.

    Similar exhaustive calc shows Hair or Height gives high gain. Manual computation:

    • Hair: Blonde (4 ex: 2Y,2N) H=1H=1, Brown (3 ex:0Y,3N) H=0H=0, Red (1 ex:1Y,0N) H=0H=0 → Weighted =4/8∗1=0.5=4/8*1=0.5 → Gain =0.954−0.5=0.454=0.954-0.5=0.454
    • Weight & Location similar calculations, Hair best initially.

    Root: Hair

    • Hair=Brown → Leaf No (3/3, pure)
    • Hair=Red → Leaf Yes (1/1)
    • Hair=Blonde (4 ex remains: Sunita Y, Anita N, Sushma Y, Sweta N) — need further split on remaining attributes (Height, Weight, Location).

    Subset Blonde SBS_B: 2Y/2N H=1H=1

    • Height: Tall 1N, Average 1Y, Short 1Y+1N (H=1H=1) → Gain small
    • Weight: Light 1Y1N (H=1H=1), Average 2 examples 1Y1N → no gain
    • Location: No → 2Y (Sunita,Sushma) pure Yes; Yes →2N (Anita,Sweta) pure No → Weighted entropy 00 → Gain =1=1

    So next split Location.

    Resulting Tree:

    Hair?
    ├─ Brown → No
    ├─ Red → Yes
    └─ Blonde → Location?
               ├─ No → Yes (Sunita,Sushma)
               └─ Yes → No (Anita,Sweta)
    

    Alternative equivalent tree with Weight/Height may also achieve pure leaves but Location gives perfect split for this subset. This tree classifies all 8 training examples correctly (100% training accuracy).

    If using Gini/C4.5, structure similar; root may be Location then Hair depending tie-breaking; any fully consistent tree with 3 leaves is acceptable. Pruning not needed due small data.

    Interpretation: For this data, Hair color and absence of Location (No) predicts Sun Burn Yes in blondes.

  16. Q6b. Explain the bagging and boosting with example.20227m

    Module 3: Classification Algorithms

    Explain the bagging and boosting with example.

    View this question on its own page →
    Worked Solution

    Bagging and Boosting (Ensemble Methods):

    Both combine weak learners (e.g., decision trees) to strong ensemble but differ in strategy.

    Bagging (Bootstrap Aggregating) — Breiman:

    • Create MM bootstrap samples (sample with replacement, size nn) from training data.
    • Train one base learner on each sample in parallel, e.g., deep trees in Random Forest.
    • Aggregate: Classification majority vote, Regression averaging: f^(x)=1M∑fm(x)\hat f(x)=\frac1M\sum f_m(x)
    • Reduces variance, prevents overfitting, robust to noise.
    • Example: Random Forest bagging 100 trees on loan default data, each tree sees 63% unique rows + random feature subset, vote gives stable prediction. Out-of-bag error estimates generalization without CV.

    Boosting (e.g., AdaBoost, Gradient Boosting):

    • Sequential. Train weak learners (stumps) iteratively; each new learner focuses on previously misclassified weighted examples.
    • AdaBoost: Maintain weights wiw_i; initially 1/n1/n, increase weight for misclassified, decrease for correct. Final prediction weighted vote F(x)=sign(∑αmfm(x))F(x)=sign(\sum \alpha_m f_m(x)) where αm=12ln⁡((1−em)/em)\alpha_m=\frac12\ln((1-e_m)/e_m).
    • Gradient Boosting: Fits new learner to residual (negative gradient of loss) ri=−∂L(yi,Fm−1(xi))/∂Fm−1r_i = -\partial L(y_i, F_{m-1}(x_i))/\partial F_{m-1}.
    • Reduces bias (+ variance), converts weak → strong, but prone to overfit if noisy; sequential not easily parallel.

    Comparison:

    Bagging Boosting
    Data Bootstrap subsets Weighted full data, adaptive
    Training Parallel, independent Sequential, dependent
    Reduces Variance Bias
    Sensitivity to noise Robust Sensitive
    Example learners Full trees Shallow stumps

    Example: Bagging on noisy medical data stable; Boosting on same achieves higher accuracy but may overfit unless early stopping/shrinkage.

  17. Q7. Discuss the steps in K-means algorithm and evaluate the following table using K-means : ![image](https://res.cloudinary.com/djkpavwmp/image/upload/v1764335242/portfolio_assets/egykrgdjwvrs0gzwlw4d.png)202214m

    Module 3: Classification Algorithms

    Discuss the steps in K-means algorithm and evaluate the following table using K-means :

    image

    View this question on its own page →
  18. Q7a. Discuss the Algorithmic convergence & Generalization property of ANN.20237m

    Module 3: Classification Algorithms

    Discuss the Algorithmic convergence & Generalization property of ANN.

    View this question on its own page →
    Worked Solution

    Algorithmic Convergence & Generalization of ANN:

    Algorithmic Convergence:

    • Perceptron: Converges in finite steps if linearly separable (Novikoff theorem, mistakes ≤(R/γ)2\le (R/\gamma)^2). For non-separable, does not converge without modification (pocket algorithm).
    • MLP with Backprop/GD: Non-convex loss, no guarantee of global optimum; GD converges to stationary point / local minima if learning rate η<2/L\eta <2/L (Lipschitz) and with decreasing schedule ∑η=∞\sum\eta=\infty, ∑η2<∞\sum\eta^2<\infty (Robbins-Monro). SGD converges almost surely to local minima. Practical: momentum, Adam help escape saddle points, converge faster but may not generalize optimally. Over-parameterized nets converge to zero training loss (interpolation regime).
    • Factors: Weight initialization (Xavier/He), learning rate scheduling, batch size, gradient vanishing/exploding (sigmoid/tanh) mitigated by ReLU, BatchNorm, Residuals.
    • Universal Approximation: Single hidden layer with enough neurons can approximate any continuous function (Cybenko 1989) — ensures representational capacity to converge to target if optimization succeeds.

    Generalization Property:

    • Capacity vs Generalization: More parameters → higher VC dimension, risk overfitting. Classical bias-variance U-curve: test error decreases then increases. Modern deep nets exhibit double descent — over-parameterized still generalizes due to implicit regularization.
    • Measures: Generalization error Etest−EtrainE_{test}-E_{train}. Controlled by regularization: weight decay (L2L2), dropout, early stopping, data augmentation, batchnorm.
    • Theoretical bounds: VC, Rademacher. For ANN with WW weights, VC ∼O(Wlog⁡W)\sim O(W\log W).
    • Empirical: Validation set, cross-validation estimate generalization; early stopping halts before validation error rises.
    • Inductive bias: Smoothness, translational invariance (CNN) improve generalization to unseen data.
    • Trade-off: Under-parameterized → underfit, over-parameterized without regularization → memorize noise, poor test performance. Proper tuning yields best generalization.

    ANN converges algorithmically via gradient methods but generalization requires controlling complexity.

  19. Q7b. What are the applications of supervised machine learning in modern business?20237m

    Module 3: Classification Algorithms

    What are the applications of supervised machine learning in modern business?

    View this question on its own page →
    Worked Solution

    Applications of Supervised ML in Modern Business:

    Supervised learning (labeled (x,y)(x,y)) drives most enterprise AI where historical outcomes exist.

    1. Finance / Banking:

      • Credit scoring, loan default prediction (classification, risk modeling)
      • Fraud detection (supervised on labeled transactions)
      • Algorithmic trading price prediction (regression)
    2. E-commerce / Retail:

      • Recommendation systems (collaborative filtering as supervised ranking)
      • Customer churn prediction, Lifetime Value (LTV) regression
      • Demand forecasting (time series regression), price optimization
    3. Marketing / Sales:

      • Targeted advertising CTR prediction P(click∣x)P(click|x)
      • Lead scoring, sentiment analysis on customer feedback (NLP classification)
      • A/B test outcome modeling
    4. Healthcare / Insurance:

      • Disease diagnosis from labs/images (supervised classification)
      • Claim fraud detection, underwriting risk
    5. Operations / Supply Chain:

      • Inventory demand prediction, predictive maintenance (failure classification from sensor logs)
      • Delivery time estimation, route optimization regression
    6. HR / Management:

      • Employee attrition prediction, resume screening classification
    7. Customer Service:

      • Chatbot intent classification, ticket routing, spam filtering

    Value: Automates decision making, personalizes experience, reduces cost, improves accuracy over rules. Requires labeled data collection, feature engineering, monitoring for drift, ROI measured via precision/recall for business KPI trade-off (e.g., high recall for fraud at cost of precision).

    Example workflow: Bank collects 100k loan records labeled default/no-default with features (income, history) → train XGBoost, validate precision 0.85 → deploy to score new applications.

  20. Q8b. What is ANN? Explain feed forward and back propagation algorithm with example.20227m

    Module 3: Classification Algorithms

    What is ANN? Explain feed forward and back propagation algorithm with example.

    View this question on its own page →
    Worked Solution

    Artificial Neural Network (ANN):

    Computational model inspired by biological neurons. Network of interconnected units (neurons) that processes inputs via weighted sums and non-linear activations to learn mappings.

    • Neuron: net=∑wixi+bnet=\sum w_i x_i + b, y=f(net)y=f(net) where ff is activation (sigmoid 1/(1+e−net)1/(1+e^{-net}), tanh, ReLU max(0,net)max(0,net)).
    • Architecture: Input layer → one or more hidden layers → output layer. Fully connected. Depth determines representation power.

    Feedforward Algorithm:
    Information flows forward only, no cycles.

    1. Initialize weights small random.
    2. For each layer ll: a(l)=f(W(l)a(l−1)+b(l))a^{(l)}=f(W^{(l)}a^{(l-1)}+b^{(l)})
    3. At output, compute loss E=12∑(y−a(L))2E=\frac12\sum(y-a^{(L)})^2 or cross-entropy.
    4. Example: 2-input XOR with hidden 2 neurons: h1=sigmoid(w11x1+w12x2+b1)h_1=sigmoid(w_{11}x_1+w_{12}x_2+b_1), output=sigmoid(v1h1+v2h2+c)output=sigmoid(v_1h_1+v_2h_2+c).

    Backpropagation Algorithm:
    Efficient gradient computation via chain rule to train weights.

    1. Forward pass as above, store net,anet, a.
    2. Output error δ(L)=(y−a(L))f′(net(L))\delta^{(L)}=(y-a^{(L)})f'(net^{(L)})
    3. Propagate backward: δ(l)=(W(l+1)Tδ(l+1))⊙f′(net(l))\delta^{(l)}= (W^{(l+1)T}\delta^{(l+1)})\odot f'(net^{(l)})
    4. Gradients ∂E/∂W(l)=δ(l)a(l−1)T\partial E/\partial W^{(l)}=\delta^{(l)}a^{(l-1)T}
    5. Update W:=W+ηδaTW:=W+\eta\delta a^T, b:=b+ηδb:=b+\eta\delta (SGD).
    6. Iterate over epochs until convergence.

    Example with numbers: Single neuron with sigmoid, input 0.5, target 1, w=0.3w=0.3, net=0.15net=0.15, o=0.537o=0.537, E=0.107E=0.107, δ=(0.463)∗0.248=0.115\delta=(0.463)*0.248=0.115, Δw=0.1∗0.115∗0.5=0.0057\Delta w=0.1*0.115*0.5=0.0057 → weight increases.

    Feedforward computes prediction; backprop assigns blame and updates weights to reduce loss, enabling learning of non-linear boundaries.

  21. Q9. Write short notes on any two of the following: (a) Naive Bayes (b) Logistic Regression \(c\) Back Propagation algorithm202314m

    Module 3: Classification Algorithms

    Write short notes on any two of the following:

    (a) Naive Bayes
    (b) Logistic Regression
    (c) Back Propagation algorithm

    View this question on its own page →
    Worked Solution

    Short Note — Any Two (all three covered for completeness):

    (a) Naive Bayes:
    Bayes classifier with strong independence assumption.
    P(Ck∣x)∝P(Ck)∏iP(xi∣Ck)P(C_k|x) \propto P(C_k)\prod_i P(x_i|C_k). Types: Gaussian (continuous xi∼N(μk,i,σ2)x_i\sim N(\mu_{k,i},\sigma^2)), Multinomial (counts/TF for text), Bernoulli (binary). Training: Estimate priors P(Ck)=Nk/NP(C_k)=N_k/N, likelihoods via MLE/MAP with Laplace smoothing α=1\alpha=1 to avoid zero counts. Prediction: C^=arg⁡max⁡kP(Ck)∏P(xi∣Ck)\hat C =\arg\max_k P(C_k)\prod P(x_i|C_k) (log sum for stability). Pros: Fast O(nd)O(n d), works well on high-dim sparse text, needs little data. Cons: independence violated often, poor probability calibration. Use for spam, sentiment, document classification.

    (b) Logistic Regression:
    Discriminative linear classifier modeling P(y=1∣x)=σ(wTx+b)P(y=1|x)=\sigma(w^T x+b), σ(z)=1/(1+e−z)\sigma(z)=1/(1+e^{-z}). Decision boundary linear. Loss = binary cross-entropy J=−1m∑[ylog⁡y^+(1−y)log⁡(1−y^)]J=-\frac1m\sum[y\log\hat y+(1-y)\log(1-\hat y)] (MLE). Gradient $
    abla J = X^T(\hat y - y)/m,solvedviaGD/SGD/Newton.Regularize, solved via GD/SGD/Newton. Regularize L1/L2.Multi−classviasoftmax. Multi-class via softmax P(y=k|x)=\exp(w_k^T x)/\sum \exp(w_j^T x).Interpretablecoefficients(oddsratio),outputsprobabilities,goodbaseline.Example:. Interpretable coefficients (odds ratio), outputs probabilities, good baseline. Example: w^T x=0$ → 0.5 threshold.

    (c) Back Propagation:
    Algorithm to train MLPs by efficient gradient via chain rule. Forward: a(l)=f(W(l)a(l−1)+b(l))a^{(l)}=f(W^{(l)}a^{(l-1)}+b^{(l)}), compute loss. Backward: $\delta^{(L)}=
    abla L \odot f'(z^{(L)}),, \delta^{(l)}=W^{(l+1)T}\delta^{(l+1)}\odot f'(z^{(l)}),grads, grads \partial L/\partial W^{(l)}=\delta^{(l)}a^{(l-1)T}.Update. Update W:=W-\eta\partial L/\partial W.Enablesdeeplearning,. Enables deep learning, O(W)complexityvsnaive complexity vs naive O(W^2)$. Needs differentiable activations, suffers vanishing gradient (solved by ReLU, residual, batchnorm).

    For exam attempt any two → choose (a) and (b) for completeness, or (b)+(c) as requested.