session: "6103-advanced-ml/2026-09-15 1830 Advance Machine Learning"
title: "Advance Machine Learning"
date: "2026-09-15 18:30"
duration: "1h 28m"
language: "en"
model: "deepseek-ai/DeepSeek-V3.2"
parts: 2
transcript_chars: 49157
generated: "2026-11-23T01:49:46+05:30"
Advanced Machine Learning
Overview
This class introduced logistic regression as a core classification algorithm within supervised learning. It covered the model's structure, which combines a linear equation with a sigmoid function to produce probabilistic outputs, and explained the training process aimed at finding an optimal decision boundary. The session also introduced key evaluation metrics for classification, specifically the confusion matrix and accuracy, and touched on model robustness and the distinction between linear and polynomial decision boundaries. This lecture serves as a bridge from fundamental classification concepts to more advanced topics like deep learning.
Learning outcomes
- Explain why logistic regression is used for classification despite its name.
- Calculate class probabilities and make predictions using a trained logistic regression model.
- Interpret a confusion matrix and calculate accuracy.
- Distinguish between linearly separable and inseparable data and describe when polynomial logistic regression might be needed.
- Describe the process of training a logistic regression model and the concept of a decision boundary.
Core concepts
Logistic Regression for Classification
A supervised learning method for predicting categorical outcomes. It uses the sigmoid function to map a linear combination of inputs to a probability between 0 and 1. It matters because it provides probabilistic interpretations for binary decisions, forming a foundation for more complex models.
Sigmoid (Logistic) Function
An S-shaped function that converts any real number into a value between 0 and 1. It is crucial because it allows the linear model's output to be interpreted as a probability, enabling classification.
Decision Boundary
The line, plane, or curve that separates different classes in the feature space. In logistic regression, it is defined where the predicted probability equals 0.5. It connects to training, as the goal is to adjust weights to position this boundary to minimize misclassifications.
Confusion Matrix
A table used to evaluate the performance of a classification model by comparing predicted and actual classes. It matters because it provides a detailed breakdown of correct and incorrect predictions, enabling the calculation of metrics like accuracy, precision, and recall.
Model Robustness and Retraining
A robust model performs well on new data from the same statistical distribution as the training data. Retraining involves updating model weights with new data, which erases the previous model's "memory." This connects to the practical challenge of maintaining model performance over time as data evolves.
Formulas and maths
- Sigmoid/Logistic Function:
\sigma(x) = \frac{1}{1 + e^{-x}} x: Input value (a real number).- Used to convert any real number into a probability between 0 and 1.
- Logistic Regression Model:
P(y=1) = \frac{1}{1 + e^{-(\theta_0 + \theta_1 x_1 + \theta_2 x_2 + ...)}} P(y=1): Probability of the positive class.\theta_0, \theta_1, ...: Model coefficients/weights.x_1, x_2, ...: Input feature values.- Used to calculate the probability for a given input during prediction.
- Example Trained Model:
P = \frac{1}{1 + e^{-(5 + 8*age + 3*salary)}} - Specific instance of the logistic regression formula with given weights.
- Used for prediction with features
age and salary. - Accuracy:
Accuracy = \frac{TP + TN}{TP + TN + FP + FN} TP: True Positives. TN: True Negatives.FP: False Positives. FN: False Negatives.- Used to evaluate overall correctness of a classifier from a confusion matrix.
- Misclassification Rate:
Misclassification = \frac{FP + FN}{Total} or 1 - Accuracy FP: False Positives. FN: False Negatives.Total: Total number of observations.- Used as an error metric, complementary to accuracy.
Worked examples
1. Probability Calculation:
- Given model:
P = 1 / (1 + e^(-(5 + 8*age + 3*salary))) - For
age=29, salary=2000: - Linear part:
5 + 8*29 + 3*2000 = 5 + 232 + 6000 = 6237 - Probability:
1 / (1 + e^(-6237)) ≈ 1 (very close to 1). - Classification with default threshold (0.5):
- If probability = 0.75 → Predict "yes".
- If probability = 0.51 → Predict "yes".
- If probability = 0.50 → Predict "yes" (if threshold is ≥0.5).
- If probability = 0.45 → Predict "no".
2. Training Visualization:
- Start with random weights (e.g.,
θ0=5, θ1=10, θ2=7). This creates a random decision boundary leading to, for example, 8 misclassifications. - After updating weights, a new decision boundary might result in only 4 misclassifications.
3. Confusion Matrix & Accuracy:
- Given: TP=100, TN=50, FP=10, FN=5.
- Total observations = 100 + 50 + 10 + 5 = 165.
- Accuracy = (100 + 50) / 165 = 150 / 165.
- Misclassification rate = (10 + 5) / 165 = 15 / 165.
Questions asked in class
- Q: "Classification have only yes and no value?"
- A: No. It can have two classes (binary) or more than two (multi-class).
- Q: "How to calculate the error [in logistic regression]?"
- A: We cannot use MSE or MAE. We use cross-entropy, which will be covered in deep learning.
- Q: "Data point are on the line?"
- A: On the line means probability = 0.5. Classification depends on the defined threshold (e.g., if threshold ≥0.5, it goes to class "yes").
- Q: Regarding plotting: "Both the axis I have taken. Because?"
- A: Because there are two input features (age and salary), so both axes are used in the plot.
- Q: Is R square (from linear regression) equivalent to cross entropy (in logistic regression)?
- A: No, they are different. Not equivalent.
- Q: How to decide whether to use linear or polynomial logistic regression?
- A: Through hit and try, or by plotting variables and using domain knowledge/experience.
- Q: Does the model retain memory after retraining?
- A: No. Retraining updates the weights; previous weights are lost.
- Q: If more data comes later, should we expect the model to perform well on that new data?
- A: Only if the new data comes from the same statistical distribution/pattern as the training data. Otherwise, the model may fail.
Key takeaways
- Logistic regression is a classification algorithm that outputs probabilities via the sigmoid function.
- The "logit" is the linear combination of inputs (
θ0 + θ1*x1 + ...) inside the sigmoid function. - The default classification threshold is 0.5: predict class 1 if probability ≥ 0.5, else predict class 0.
- The decision boundary is defined where the predicted probability equals 0.5.
- Training involves iteratively adjusting weights to reduce misclassifications and improve the decision boundary.
- A confusion matrix breaks down predictions into True Positives, True Negatives, False Positives, and False Negatives.
- Accuracy is calculated as (TP + TN) / Total observations.
- A Type 1 error is a False Positive; a Type 2 error is a False Negative.
- Logistic regression can model non-linear decision boundaries through polynomial terms (polynomial logistic regression).
- A model is robust if it performs well on new data from the same statistical distribution as the training data.
- Retraining a model with new data updates its weights and does not retain "memory" of previous weights.
- Error in logistic regression is calculated using cross-entropy loss, not Mean Squared Error.
Exam-style questions
1. **Given a trained logistic regression model P = 1 / (1 + e^(-(-2 + 0.5*x1 + 1.5*x2))) and a data point with x1=3, x2=1, calculate the predicted probability and the class label using a 0.5 threshold.**
- Outline: Compute the linear part:
-2 + 0.5*3 + 1.5*1 = -2 + 1.5 + 1.5 = 1. Apply sigmoid: 1/(1+e^(-1)). This probability is >0.5, so predict class 1.
2. From a confusion matrix with TP=80, TN=60, FP=15, FN=10, calculate the accuracy and misclassification rate.
- Outline: Total = 165. Accuracy = (80+60)/165 = 140/165. Misclassification = (15+10)/165 = 25/165 or 1 - Accuracy.
3. Explain the difference between a linearly separable and a linearly inseparable dataset in the context of logistic regression. What model extension can address inseparability?
- Outline: Linearly separable data can be perfectly split by a straight line (hyperplane). Inseparable data cannot. Polynomial logistic regression, which uses curved decision boundaries, can address this.
4. Describe what happens during the retraining of a logistic regression model. Does the model "remember" its previous state?
- Outline: Retraining involves using (old + new) data to recalculate the model weights via the optimization algorithm. The previous weights are overwritten; the model does not retain memory of its previous state.
Glossary
- Supervised Learning - Machine learning where the model learns from labeled data, includes regression and classification.
- Classification - A predictive modeling problem where the output variable is categorical.
- Binary Classification - Classification with exactly two possible outcomes.
- Multi-class Classification - Classification with more than two possible outcomes.
- Sigmoid/Logistic Function - An S-shaped function that maps any real value to a value between 0 and 1.
- Logit - The linear combination of input features (
θ0 + θ1*x1 + ...) within the logistic regression model. - Decision Boundary - The surface that separates different predicted classes in the feature space.
- Threshold - A cutoff probability value used to convert a predicted probability into a class label.
- Confusion Matrix - A table used to describe the performance of a classification model.
- True Positive (TP) - An observation correctly predicted as the positive class.
- False Positive (FP) - An observation incorrectly predicted as the positive class (Type 1 error).
- False Negative (FN) - An observation incorrectly predicted as the negative class (Type 2 error).
- Accuracy - The proportion of total predictions that are correct.
- Linearly Separable - Data that can be perfectly separated by a linear decision boundary.
- Polynomial Logistic Regression - Logistic regression using polynomial features to create non-linear decision boundaries.
- Robust Model - A model that maintains good performance on new, unseen data from the same distribution.
Follow-ups
- Detailed discussion on how and when to adjust the classification threshold (beyond the default 0.5) is postponed.
- Error calculation for logistic regression (Cross-entropy) will be covered in the deep learning section.
- The mechanism of gradient descent for updating weights will be covered in deep learning.
- Other performance metrics from the confusion matrix (precision, recall, specificity, AUC) are suggested for self-study and may be picked up in deep learning.
- Feature engineering is acknowledged as important but was not covered due to time constraints.
- How to confirm a model's robustness is noted as not part of the course syllabus.
- Cross-validation was mentioned as a different concept for model evaluation.
- Assignment 1 is based on the topics covered in this class.
Exam verification — corrections & additions
- Class label: the category/target of an observation (e.g. repay = yes/no). It is a category, not a probability.
- Generalization: the ability of a model to produce the correct output for inputs that were not in the training set. It holds only while the new data follows the same distribution as the training data.
- False Negative = actually positive, predicted negative (Type 2 error). False Positive = actually negative, predicted positive (Type 1 error).
- Full 80-question answer key:
C:\PORJECTX\aml-import\AML-FINAL-EXAM-ANSWER-KEY.md