Part B: Long Analytical & Numerical Problems
Course - Machine Learning Algorithms (21CSC555J)
Assessment Tier - Part-B University Question Bank
Mark Weightage - 16 Marks per Question (or 4m / 8m / 12m modular sub-parts)
Question 1 (16 Marks)
Question Statement
Explain in detail about different types of learning methods in machine learning with examples. (16 Marks)
Solution 1 (16 Marks)
Machine learning paradigms are categorized based on the nature of learning signals, presence of ground truth annotations, and environmental interaction protocols:
1. Supervised Learning
- Mathematical Formalism: Given a training dataset drawn i.i.d. from unknown joint distribution , find a hypothesis function minimizing empirical risk:
- Sub-Types:
- Regression: Continuous target (e.g., Linear Regression, Ridge, SVR predicting house prices).
- Classification: Discrete target (e.g., Logistic Regression, Random Forest predicting loan default).
2. Unsupervised Learning
- Mathematical Formalism: Given unlabelled feature vectors , discover intrinsic geometric structure, cluster assignments , or a lower-dimensional latent representation ().
- Sub-Types:
- Clustering: Partitioning observations into cohesive groups maximizing inter-cluster separation (e.g., -Means, DBSCAN).
- Dimensionality Reduction: Projecting data while preserving maximum variance or pairwise geodesics (e.g., PCA, t-SNE, UMAP).
- Density Estimation: Modeling probability density function (e.g., Gaussian Mixture Models, Isolation Forest).
3. Semi-Supervised Learning
- Mathematical Formalism: Employs a small labelled dataset alongside a substantially larger unlabelled dataset ().
- Core Assumption (Cluster / Manifold Assumption): Points sharing the same high-density cluster or low-dimensional manifold belong to the same class.
- Techniques & Example: Pseudo-labeling, Label Propagation. In medical imaging, a radiologist labels 200 MRI scans, while 50,000 unlabelled scans guide feature representations via contrastive learning.
4. Reinforcement Learning (RL)
- Mathematical Formalism: Formulated as a Markov Decision Process (MDP) defined by tuple . An agent in state selects action under policy , receiving scalar reward and transitioning to state :
- Example: Autonomous vehicle trajectory control, AlphaGo, and robotic arm manipulation.
Examiner's Note
Define all four paradigms explicitly with their mathematical loss/optimization objectives, distinguishing between feedback mechanisms (instantaneous loss, internal heuristics, delayed scalar reward).
Question 2 (16 Marks)
Question Statement
- a) Derive Logistic-Regression classification model from Linear Regression. (8 Marks)
- b) Write short notes on: (8 Marks)
- i) Sigmoidal transfer function
- ii) Odds and Logit function
- iii) Binary Cross-Entropy Loss function
Solution 2 (16 Marks)
a) Derivation of Logistic Regression from Linear Regression (8 Marks)
1. The Limitation of Standard Linear Regression
Standard linear regression models the dependent variable as an affine linear combination: For binary classification (), modeling posterior probability directly with violates Kolmogorov's axioms because can evaluate to or .
2. Step-by-Step Derivation via Odds and Logit
To constrain outputs strictly to , we construct the mapping from probability to the real line in three mathematical steps:
Step 1: Odds Ratio
Let . The Odds of the event occurring is the ratio of probability of occurrence to non-occurrence:
Step 2: The Logit (Log-Odds) Link Function
Taking the natural logarithm maps the non-negative interval onto the full real line :
We now equate this unbounded quantity to the linear regression equation:
Step 3: Solving for Probability (Sigmoid Inversion)
Exponentiating both sides: Dividing numerator and denominator by :
Substituting :
b) Short Notes on Core Logistic Regression Primitives (8 Marks)
i) Sigmoidal Transfer Function
- Formula:
- Mathematical Properties:
- Strict Bounds: , .
- Symmetry: with midpoint .
- Derivative: .
ii) Odds and Logit Function
- Odds: The likelihood ratio of success versus failure (). An odds of indicates an event is 4 times more likely to occur than not.
- Logit: The inverse sigmoid function . It linearizes probability: a unit increase in increases the log-odds of the positive class by (or multiplies the odds by ).
iii) Binary Cross-Entropy Loss Function
Derived via Maximum Likelihood Estimation across independent training observations: Taking the negative log-likelihood yields the strictly convex loss:
- If , loss is . As , loss approaches .
- If , loss is . As , loss approaches .
Examiner's Note
Show the 3 algebraic steps: . Highlight that the derivative of the sigmoid is and that Cross-Entropy is strictly convex, unlike Mean Squared Error.
Question 3 (16 Marks)
Question Statement
- i) Difference between classification and regression models? (4 Marks)
- ii) What is the impact of data class Imbalance on ML model. Describe the techniques used to rectify it with an suitable example. (12 Marks)
Solution 3 (16 Marks)
i) Classification vs. Regression Models (4 Marks)
| Evaluation Dimension | Classification | Regression |
|---|---|---|
| Target Variable () | Discrete / Categorical ( or ) | Continuous / Real-valued () |
| Model Output | Class probabilities and decision boundaries | Numerical scalar quantity along a continuous curve |
| Loss Function | Cross-Entropy, Hinge Loss, Zero-One Loss | Mean Squared Error (MSE), Mean Absolute Error (MAE), Huber Loss |
| Evaluation Metrics | Accuracy, Precision, Recall, , ROC-AUC | , RMSE, MAE, Mean Absolute Percentage Error (MAPE) |
| Example | Predicting whether an email is Spam or Ham | Predicting stock prices or real estate valuation |
ii) Class Imbalance: Impact and Rectification Techniques (12 Marks)
1. Adverse Impacts on Machine Learning Models
- The Accuracy Paradox: In fraud detection with legitimate and fraudulent transactions, a trivial model predicting "Legitimate" for all cases achieves accuracy while detecting of fraud.
- Decision Boundary Drift: Standard optimization algorithms minimize global misclassification rate, pushing decision boundaries toward the minority class and treating minority errors as negligible noise.
2. Techniques to Rectify Class Imbalance
A. Data-Level Resampling Techniques
- Synthetic Minority Over-sampling Technique (SMOTE):
- Instead of simple duplication (which causes overfitting), SMOTE synthesizes new minority points along the line segment connecting -nearest minority neighbors:
- NearMiss Undersampling:
- Selects majority class instances based on distance to nearest minority instances to eliminate redundant samples.
B. Algorithm-Level Modifications
- Cost-Sensitive Learning (Class Weighting):
- Assigns penalty weights inversely proportional to class frequencies: Misclassifying a rare fraud transaction is penalized more than misclassifying a legitimate one.
- Focal Loss:
- Adds a modulating factor to cross-entropy to suppress gradients from well-classified easy examples.
C. Post-Processing: Threshold Moving
- Shifts the classification threshold from default to a lower probability (e.g., ) to maximize Recall or -score on the minority class.
Examiner's Note
Provide concrete numbers for the Accuracy Paradox ( accuracy with recall). Include the SMOTE interpolation formula and explain class weight scaling.
Question 4 (16 Marks)
Question Statement
Explain the concept of confusion matrix and compute the below measures with definition? (16 Marks)
- a) Accuracy
- b) Recall
- c) Precision
- d) F1 score
- e) False Positive Rate
Evaluate for the following two university problem datasets:
- Binary Confusion Matrix ():
- Actual Pos (0) / Pred Pos (0): , Actual Pos (0) / Pred Neg (1):
- Actual Neg (1) / Pred Pos (0): , Actual Neg (1) / Pred Neg (1):
- Multi-Class Fruit Confusion Matrix ():
| Actual \ Predicted | Apple | Orange | Mango |
|---|---|---|---|
| Apple | 7 | 8 | 9 |
| Orange | 1 | 2 | 3 |
| Mango | 3 | 2 | 1 |
Solution 4 (16 Marks)
1. Confusion Matrix Concept and Metric Definitions (6 Marks)
A Confusion Matrix is a contingency layout that cross-tabulates actual ground truth labels against model predictions, allowing granular evaluation of classifier performance:
- Accuracy: Overall proportion of correct classifications:
- Recall (Sensitivity / True Positive Rate): Proportion of actual positives correctly identified:
- Precision (Positive Predictive Value): Proportion of predicted positives that are truly positive:
- -Score: The harmonic mean of precision and recall:
- False Positive Rate (FPR / Fall-out): Proportion of actual negatives incorrectly flagged as positive:
2. Evaluation of Binary Dataset () (5 Marks)
Given matrix parameters:
Computations:
- Accuracy:
- Recall:
- Precision:
- -Score:
- False Positive Rate (FPR):
3. Evaluation of Multi-Class Fruit Matrix () (5 Marks)
Total observations .
- Overall Accuracy:
Class-by-Class One-vs-Rest Decomposition:
1. Class: Apple
2. Class: Orange
3. Class: Mango
Examiner's Note
In multi-class matrices, calculate TP as the diagonal cell, FN as the row sum minus diagonal, FP as the column sum minus diagonal, and TN as all remaining cells.
Question 5 (16 Marks)
Question Statement
Construct Decision tree for the given dataset using Information gain and Entropy. How decision tree handles the overfitting? (16 Marks)
| Day | Past Trend | Open Interest | Trading Volume | Return |
|---|---|---|---|---|
| 1 | Positive | Low | High | Up |
| 2 | Negative | High | Low | Down |
| 3 | Positive | Low | High | Up |
| 4 | Positive | High | High | Up |
| 5 | Negative | Low | High | Down |
| 6 | Positive | Low | Low | Down |
| 7 | Negative | High | High | Down |
| 8 | Negative | Low | High | Down |
| 9 | Positive | Low | Low | Down |
| 10 | Positive | High | High | Up |
Solution 5 (16 Marks)
1. Total Dataset Entropy Computation (4 Marks)
Total samples : (Days 1, 3, 4, 10) and (Days 2, 5, 6, 7, 8, 9).
2. Information Gain for Candidate Attributes at Root (6 Marks)
1. Attribute: Past Trend (Values: Positive, Negative)
- Negative ( samples: Days 2, 5, 7, 8):
- (Pure Node)
- Positive ( samples: Days 1, 3, 4, 6, 9, 10):
- Expected Entropy:
- Information Gain:
2. Attribute: Open Interest (Values: High, Low)
- High ( samples: Days 2, 4, 7, 10):
- Low ( samples: Days 1, 3, 5, 6, 8, 9):
- Expected Entropy:
- Information Gain:
3. Attribute: Trading Volume (Values: High, Low)
- High ( samples: Days 1, 3, 4, 5, 7, 8, 10):
- Low ( samples: Days 2, 6, 9):
- Expected Entropy:
- Information Gain:
Selection:
Select Past Trend as the Root Node.
3. Expanding Tree Branches (3 Marks)
- Branch 1:
Past Trend = Negative(Days 2, 5, 7, 8): All samples have Pure Leaf Node: Down. - Branch 2:
Past Trend = Positive(Days 1, 3, 4, 6, 9, 10): Evaluate remaining attributes:Open InterestandTrading Volume:- Evaluating
Trading Volumeon this subset:High(Days 1, 3, 4, 10): All samples have (Pure Leaf Node: Up).Low(Days 6, 9): Both samples have (Pure Leaf Node: Down).
- Evaluating
4. Final Decision Tree Architecture & Operational Rules (3 Marks)
Production Rules:
Examiner's Note
Note that Open Interest is completely pruned because Past Trend followed by Trading Volume achieves pure separation in only two levels.
Question 6 (16 Marks)
Question Statement
- a) Explain in detail about bagging ensemble techniques classification? (10 marks)
- b) Define stacking and Voting ensemble model? (6 marks)
- (OR)
- Describe the random forest model with example and justify the hyper parameter importance? (16 marks)
Solution 6 (16 Marks)
1. Bagging, Stacking, and Voting Ensembles (16 Marks)
a) Bagging (Bootstrap Aggregation) Mechanics (10 Marks)
Bagging reduces the variance of unstable, high-capacity estimators by training multiple independent models on resampled subsets:
- Bootstrap Resampling: From training set of size , sample points uniformly with replacement. The probability of an instance not being chosen is: Thus, each base model trains on unique instances, leaving as Out-of-Bag (OOB) samples.
- Parallel Execution: All base estimators train independently in parallel.
- Aggregation: Binary/multiclass predictions are consolidated via plurality vote:
b) Stacking and Voting Ensembles (6 Marks)
- Voting Classifier:
- Hard Voting: Predicts the class receiving the simple majority of individual model votes ().
- Soft Voting: Averages predicted class probabilities across all models and selects the class maximizing average probability:
- Stacking (Stacked Generalization):
- Heterogeneous base models (: SVM, : Random Forest, : XGBoost) generate out-of-fold predictions.
- A Meta-Learner (typically Logistic Regression or ElasticNet) trains on these predictions as input features to learn which base models perform best in different regions of the feature space.
2. OR: Random Forest Algorithm and Hyperparameter Tuning (16 Marks)
1. Algorithmic Overview
Random Forest introduces Random Feature Subspacing to standard bagging: at every candidate node split, only a random subset of features is considered.
2. The Decorrelation Mechanism
For an ensemble of trees with individual variance and pairwise correlation : As grows large, variance approaches . Random feature selection drives , reducing overall ensemble variance without increasing bias.
3. Hyperparameter Justification
n_estimators: Increasing trees stabilizes predictions and eliminates variance without causing overfitting.max_features: Balances individual tree bias against ensemble correlation (default ).max_depth&min_samples_split: Prevents individual trees from learning extreme noise.
Examiner's Note
Write the Out-of-Bag derivation for Bagging, contrast Hard vs. Soft voting, and explain the ensemble variance reduction formula .
Question 7 (16 Marks)
Question Statement
- a) Explain the detailed concept and features of: (10 Marks)
- i) AdaBoost
- ii) Gradient Boosting
- b) How feature importance plays a major role in predicting the target variable? (6 Marks)
Solution 7 (16 Marks)
a) Boosting Paradigms: AdaBoost vs. Gradient Boosting (10 Marks)
i) AdaBoost (Adaptive Boosting)
- Mechanism: Sequentially trains decision stumps by dynamically adjusting instance weights.
- Weight Update Formula: where estimator weight is . Misclassified samples receive increased weights, forcing subsequent estimators to focus on difficult instances.
ii) Gradient Boosting (GBM / XGBoost)
- Mechanism: Optimizes arbitrary differentiable loss functions by iteratively fitting regression trees directly to the negative gradient (pseudo-residuals) of the loss:
- Additive Expansion: where is the step length (shrinkage / learning rate ).
b) Role of Feature Importance in Target Prediction (6 Marks)
- Interpretability & Governance: Quantifies which variables drive model decisions, fulfilling regulatory explainability requirements (e.g., credit approval).
- Dimensionality Reduction: Identifies non-informative features, allowing removal of noisy columns to speed up training.
- Scientific Discovery: Uncovers unexpected biological or economic relationships (e.g., identifying primary biomarker genes in oncology).
- Computation Methods:
- Mean Decrease in Impurity (MDI): Total reduction in Gini/Entropy contributed by a feature across all splits.
- Permutation Importance: Evaluates the drop in validation score when values of a single feature are randomly shuffled.
Examiner's Note
Contrast the two boosting mechanisms: AdaBoost adjusts sample weights, whereas Gradient Boosting fits base trees to pseudo-residuals (negative gradients).
Question 8 (16 Marks)
Question Statement
- i) Explain the working principle of K nearest neighbour classifier? (10 Marks)
- ii) What are the different distance measures are used in the KNN and how it impacts the neighbours on KNN model? (6 Marks)
Solution 8 (16 Marks)
i) Working Principle of K-Nearest Neighbors (KNN) (10 Marks)
KNN is an instance-based, non-parametric, lazy learning classifier:
- Training Phase ( Time): Stores training vectors . No parametric function is learned.
- Inference Phase ( Time):
- Distance Evaluation: Compute metric distance between query point and all stored samples.
- Neighborhood Selection: Sort distances and identify the smallest instances ().
- Classification: Apply plurality voting:
- Distance-Weighted Voting: Weights votes by inverse distance:
ii) Distance Measures and Their Impact on Neighborhoods (6 Marks)
1. Distance Formulations
- Euclidean Distance (): . Generates spherical, circular neighborhoods. Highly sensitive to outliers due to squaring.
- Manhattan Distance (): . Generates diamond-shaped neighborhoods. Robust to outliers and suited for urban grid networks.
- Minkowski Distance (): . Generalization ().
- Cosine Distance: . Evaluates angular orientation, making it invariant to document length in text classification.
2. Impact on Decision Boundaries & Preprocessing Requirement
- Scale Dominance Hazard: If Feature A has scale (income) and Feature B has scale (rating), Feature A will completely dominate distance by orders of magnitude.
- Remedy: Z-score standardization or Min-Max normalization is mandatory prior to running KNN.
Examiner's Note
Highlight that KNN training is lazy learning, while inference is computationally intensive. Explain why feature scaling is strictly mandatory for distance-based models.
Question 9 (16 Marks)
Question Statement
- a) Describe the issues of supervised learning algorithm. (6 Marks)
- b) Explain Naïve Bayes Classifier with an Example and discuss its variants (Multinomial, Gaussian). (10 Marks)
Solution 9 (16 Marks)
a) Core Issues in Supervised Learning Algorithms (6 Marks)
- Bias-Variance Dilemma: High bias causes underfitting; high variance causes overfitting. Achieving minimal out-of-sample error requires optimizing model capacity.
- Curse of Dimensionality: As feature dimension , volume of feature space grows exponentially (), causing points to become equidistant and rendering distance metrics ineffective.
- Label Noise & Measurement Artifacts: Erroneous or subjective annotations corrupt loss gradient updates.
- Class Imbalance: Disproportionate class ratios cause models to ignore minority targets.
b) Naïve Bayes Classifier: Principle, Mathematics, and Example (10 Marks)
1. Mathematical Formulation
Given feature vector , Bayes' Theorem yields: Applying the Class-Conditional Independence Assumption: The decision rule selects the class maximizing posterior probability:
2. Worked Example (Spam Classification)
Classify an incoming message containing words :
- Priors:
- Likelihoods:
Compute unnormalized posterior scores:
Normalizing:
3. Key Variants
- Multinomial Naïve Bayes: Evaluates integer word counts using Laplace smoothing:
- Gaussian Naïve Bayes: Evaluates continuous attributes via normal density parameters ().
Examiner's Note
Show the independence factor expansion and demonstrate the zero-frequency problem resolved by Laplace smoothing .