Machine Learning

Machine Learning & Supervised Learning Fundamentals

Machine Learning & Supervised Learning Fundamentals

High-Yield Revision Hub

Master Machine Learning & Supervised Learning Fundamentals

High-yield concepts, mathematical formulas, and practice questions for Machine Learning and Supervised Learning.

Concept Breakdown

Detailed technical explanation

Machine Learning algorithms learn predictive patterns from data without being explicitly programmed. Supervised Learning handles labeled target outputs via Regression (predicting continuous numerical quantities) and Classification (predicting categorical labels). Core linear models include Linear Regression (optimized via MSE) and Logistic Regression (using log-loss and sigmoid activation for probability estimation).

Model generalization is governed by the Bias-Variance Tradeoff: underfitting stems from insufficient model complexity (high bias), while overfitting arises from excessive model capacity capturing sample noise (high variance). Overfitting is mitigated using Regularization (L1 Lasso for sparse feature selection, L2 Ridge for weight decay), Cross-Validation, Dropout, Early Stopping, and Ensemble Methods (Random Forests, Gradient Boosted Trees).

Model performance must be evaluated using domain-appropriate metrics: Accuracy can be misleading on imbalanced datasets, requiring Precision, Recall, F1-Score, and ROC-AUC curves. Feature scaling (standardization/normalization) is mandatory for distance-based models (KNN, SVM) and gradient-based solvers to ensure stable and unbiased convergence.

Key Revision Rules

Essential formulas and core points to memorize

  • 1🧠 Supervised vs. Unsupervised vs. Reinforcement Learning: Supervised learning maps labeled inputs X -> Y (Regression & Classification). Unsupervised learning discovers hidden patterns/clusters in unlabeled data X (K-Means, PCA). Reinforcement learning optimizes actions via rewards and penalties in an environment (Q-Learning).
  • 2📈 Linear Regression & Mean Squared Error (MSE): Models continuous output y = w^T x + b. Loss function: MSE = (1/n) * ∑ (y_i - y_hat_i)^2. Convex loss function guarantees a single global minimum.
  • 3🎯 Logistic Regression & Sigmoid Function: Models probability of binary outcomes using the sigmoid activation σ(z) = 1 / (1 + e^-z), mapping real numbers z to probabilities (0, 1). Loss function: Binary Cross-Entropy L = -[y log(y_hat) + (1-y) log(1-y_hat)].
  • 4⚖️ Bias-Variance Tradeoff: High Bias -> Underfitting (model too simple, high training & validation error). High Variance -> Overfitting (model fits noise, low training error but high validation error). Total Error = Bias^2 + Variance + Irreducible Error.
  • 5🛑 Regularization (L1 Lasso vs. L2 Ridge): L1 (Lasso) adds λ ∑ |w_i| penalty, forcing irrelevant feature weights to exactly ZERO (performing feature selection). L2 (Ridge) adds λ ∑ w_i^2 penalty, shrinking weights towards zero without making them zero.
  • 6📊 Confusion Matrix & Evaluation Metrics: Precision = TP / (TP + FP) (Quality of positive predictions). Recall (Sensitivity) = TP / (TP + FN) (Coverage of actual positives). F1-Score = 2 * (Precision * Recall) / (Precision + Recall) (Harmonic mean).
  • 7⚡ Gradient Descent Optimization: Weight update rule: w^(t+1) = w^(t) - α ∇L(w). Learning rate α controls step size. Too large α -> divergence/oscillation; too small α -> extremely slow convergence.
  • 8🌳 Decision Trees & Impurity Metrics: Splits nodes by maximizing Information Gain or minimizing impurity. Gini Impurity = 1 - ∑ p_i^2. Entropy H(S) = -∑ p_i log2(p_i). Decision trees are non-parametric and prone to overfitting if not pruned.
  • 9📐 K-Nearest Neighbors (KNN) & Scaling: Non-parametric, instance-based algorithm. Classification by majority vote of k closest neighbors. Highly sensitive to feature scales, requiring Z-score normalization or Min-Max scaling prior to distance calculation.
  • 10🔄 K-Fold Cross-Validation: Partitions dataset into K equal subsets (folds). Trains model on K-1 folds and tests on the remaining 1 fold, repeating K times to provide unbiased performance estimates without data leakage.

Common Exam Mistakes

Where students frequently lose marks

Mistake: Relying solely on Classification Accuracy for imbalanced datasets (e.g., 99% accuracy on a dataset with 99% negative cases while missing all positive cases). Use Precision, Recall, or F1-Score instead.
Mistake: Confusing L1 (Lasso) and L2 (Ridge) regularization. L1 produces sparse weights (zeroing parameters for feature selection), whereas L2 shrinks weights smoothly without setting them strictly to zero.
Mistake: Forgetting to scale features before running distance-based algorithms like KNN or SVM. Unscaled features with large numerical ranges will dominate distance metrics.
Mistake: Setting the Gradient Descent learning rate α too high, causing loss to explode or oscillate endlessly around the minimum instead of converging.
Mistake: Performing feature normalization or imputation on the ENTIRE dataset before splitting into Train/Test sets, causing severe Data Leakage.

Topic Quiz Practice

1 of 10
Question 1

Which of the following machine learning algorithms is an UNSUPERVISED learning algorithm used for clustering data into k distinct groups?