Logistic Regression: Probabilities, Classes, and Decision Boundaries
Foundations and Motivations for Probability Estimation
Course Framework: AI400 Advanced Data Science, AUM Fall 2026, Week 3 — Day 1, taught by Tanya Roosta, Ph.D.
Core Focus: Understanding logistic regression through probabilities, classes, and decision boundaries.
Motivation for Probability Estimation over Discrete Classes:
In engineering diagnostic scenarios, determining the likelihood of a failure is critical rather than relying solely on a hard categorical decision.
Example comparison of two machines:
Machine A: Estimated fault probability of
Machine B: Estimated fault probability of
At a standard classification decision threshold of , both Machine A and Machine B receive the identical predicted label of "faulty".
Despite having the same predicted label, their underlying operational risk profiles differ substantially.
Probability estimations provide granular risk gradients that allow maintenance teams to prioritize which machines to inspect first.
The operational and financial cost of an undetected fault significantly affects downstream decisions and threshold selection.

Limitations of Standard Linear Regression for Classification:
Linear regression fits an unconstrained line or hyperplane of the form .
Plain linear predictions produce outputs on the real number line , which routinely fall below or exceed .
Probabilities must strictly obey Kolmogorov axioms and reside within the bounded range .
Logistic regression resolves this by passing a real-valued weighted linear score through a nonlinear mapping that squashes values into valid probabilities.
It serves as a simple, highly interpretable baseline statistical learning model with directly interpretable weights.
The Sigmoid Function and Mathematical Formulation
Definition and Functional Form:
The sigmoid (or standard logistic) function transforms any real-valued input score into a continuous probability value .
Mathematical equation:
: Any real-valued linear score or logit ().
: Calculated probability output ().
Base of the natural logarithm: Euler's number .

Step-by-Step Worked Sigmoid Calculation:
For a score of :
Reference Evaluations across Integer Scores:
Score : Score :
Score :
Score :
Score :
Monotonicity: The sigmoid function is strictly monotonically increasing; a higher score always produces a higher probability .
Impact of Feature Weights on the Sigmoid Curve:
Consider a univariate linear model without bias: , where is the input feature and is the learned feature weight.
Positive Weight ():
The probability rises monotonically as increases.
Magnitude of Positive Weight ():
Larger positive values of (e.g., comparing against ) create a steeper, more abrupt transition from to .
Negative Weight ():
The probability decreases monotonically as increases (e.g., reflects the curve horizontally across ).

Mathematical Derivation of Odds and Log Odds
Definition and Formulation of Odds:
Odds quantify the ratio of the probability that an event occurs to the probability that it does not occur.
Mathematical expression:
: Probability of the primary target event (e.g., "faulty").
: Probability of the complementary alternative outcome (e.g., "non-faulty").
Interpretation: An odds value of indicates that four faulty cases occur for every single non-faulty case ().
Worked Example Calculating Odds and Recovering Probability:
Illustrative cohort distribution of total machines:
Faulty machines:
Non-faulty machines:
Total machines:
Calculating probability of a fault:
Calculating odds of a fault:
Recovering probability algebraically from odds:
Log Odds (Logit Function):
Taking the natural logarithm of the odds maps bounded odds values in onto the entire real line , centered at zero.
Mathematical definition:
Correspondence Table between Probability, Odds, and Log Odds:
When : ,
When : ,
When : ,
Invertibility between Sigmoid and Log Odds:
The sigmoid function and the logit function are mathematical inverses of each other:
Demonstration:
Given :
Re-applying the sigmoid transformation to :
Binary Logistic Regression Modeling and Interpretation
Model Formulation and Probabilistic Interpretation:
Binary (binomial) logistic regression addresses problems with two mutually exclusive outcomes:
: Positive outcome (e.g., inspection confirms a fault)
: Negative outcome (e.g., inspection finds no fault)
The model directly outputs a conditional probability estimate:
The probability of the alternative class is the complement:
The term "binomial" signifies the underlying two-outcome Bernoulli/binomial trial structure.
The probabilistic estimation always occurs prior to assigning a final categorical decision.
Linear Predictor and Complete Model Equation:
The internal linear predictor (score ) combines the feature variables linearly:
Predicted probability:
Variable definitions:
: Measured numeric features for an individual sample.
: Model weights (coefficients) estimated from training data.
: Intercept (bias), representing the baseline log-odds score when all features equal zero ().
Running Industrial Case Study:
Feature definitions:
: Scaled temperature measurement
: Scaled vibration measurement
Target : Inspection confirms a mechanical fault
Target : Inspection confirms no fault (healthy)
Fitted Parameter Specification:
Worked Example for a Specific Machine (, ):
Step 1: Compute linear score :
Step 2: Compute predicted probability via sigmoid transformation:
Step 3: Classification at default threshold :
Decision rule: Predict class if , else predict class .
Because , the model predicts "Faulty".
Decision Thresholding Mechanics:
Classification is decoupled from probability estimation; altering threshold changes class assignments without altering calculated probabilities.
Scenario evaluation for :
Threshold Classified as Faulty.
Threshold Classified as Non-faulty.
Lowering the decision threshold flags more instances as faulty, increasing detection sensitivity at the cost of more false alarms.
Quantitative Interpretation of Coefficients (Odds Ratios):
Direction of weights:
Positive weight (): Increases in the feature increase the linear score and probability .
Negative weight (): Increases in the feature decrease the linear score and probability .
Multiplicative Effect on Odds:
For weight , a 1-unit increase in (holding all other features fixed) adds to the log odds score .
In terms of odds, this exponentiates the odds by :
A 1-unit increase in scaled temperature multiplies the odds of a machine fault by approximately .
Critical Statistical Caveat: Regression coefficients represent statistical associations within the training distribution, not proven causal mechanisms.
Model Training, Log Loss, and Regularization
Optimization Objective:
Training adjusts weights and bias to make the observed ground-truth labels maximally probable under the model.
The model should output for confirmed faults () and for non-faults ().
Log Loss (Binary Cross-Entropy Loss):
Used to evaluate probabilistic predictions against discrete binary outcomes.
Piecewise definition:
If true label :
If true label :
Combined single-equation form:
Loss characteristics:
Correct and confident predictions ( when ) incur minimal loss approaching .
Incorrect and confident predictions ( when ) incur extreme, asymptotically infinite penalties.

Worked Log Loss Comparison:
Consider two distinct machines that are both verified faults ():
Machine 1 Prediction:
Machine 2 Prediction:
Average Log Loss across the two instances:
Conceptual Iterative Training Process:
Step 1: Initialize model parameters (weights and intercept ) with arbitrary baseline values.
Step 2: Compute predicted probabilities for every instance across the training dataset.
Step 3: Compute the average log loss over all training examples.
Step 4: Iteratively adjust parameter values to decrease the loss objective, repeating until convergence.
L2 Regularization (Ridge Penalty):
Unconstrained optimization can cause weights to grow excessively large, especially when features are correlated or data is linearly separable, leading to overfitting.
Total training objective with L2 regularization:
The hyperparameter controls penalization intensity on weight magnitudes.
Scikit-Learn Parameterization:
The scikit-learn library parameterizes regularization via .
Smaller values correspond to larger values (stronger regularization).
Impact of Regularization Strength on Parameter Magnitudes:
Consider a synthetic fitted model optimizing Average Log Loss on identical training data:
When : Learned weight
When : Learned weight
When : Learned weight

Regularization and Probability Curve Softening:
Stronger penalties shrink learned weights toward zero, flattening the slope of the sigmoid curve.
This softening prevents extreme, overly confident probabilities near or .
In symmetric single-feature setups, the threshold point remains centered at , but the transition becomes significantly less steep.
Excessive regularization causes severe underfitting; optimal penalization must be selected via validation or cross-validation.

Multiclass Logistic Regression via Softmax
Formulation of Multiclass Problems:
Used when an instance belongs to exactly one of mutually exclusive categorical classes.
Running machine health diagnosis scenario ( classes):
Class 0 (Healthy): No diagnosed fault.
Class 1 (Bearing fault): Primary fault isolated to the bearing assembly.
Class 2 (Cooling fault): Primary fault isolated to the cooling subsystem.
The Softmax Function Formulation:
Generalization of the logistic function to multiple classes.
For class :
Individual linear class score:
Exponentiation () guarantees that all numerator values remain strictly positive.
Normalization by the shared sum of exponentiated scores ensures that all class probabilities sum to exactly ().
Step-by-Step Softmax Transformation Process:
Step 1 (Score Calculation): Compute linear score for each class.
Step 2 (Exponentiation): Calculate for each class.
Step 3 (Normalization): Compute the denominator sum and divide each by this sum.
Worked Softmax Calculation Example:
Input class scores:
Healthy (): Score
Bearing fault (): Score
Cooling fault (): Score
Exponentiating scores:
Computing normalizer denominator:
Resulting probabilities:
Healthy:
Bearing fault:
Cooling fault:
Total probability:
Final decision: Predict "Healthy" based on the largest probability (
Cross-Class Coupling Effect:
Because all classes share the identical denominator sum, altering a single score alters the probabilities of all classes.
Numerical example:
Baseline scores produce probabilities .
Increasing only the Healthy score from to (scores ):
New denominator:
Healthy probability rises to
Bearing fault probability drops to
Cooling fault probability drops to
Multiclass Training Loss:
Evaluated using categorical cross-entropy loss:
Only the predicted probability assigned to the true ground-truth class directly enters the loss computation for that instance.
Equivalence of Two-Class Softmax to the Sigmoid Function:
For two classes ( and ):
In a two-class setting, classification depends strictly on the difference between the two linear scores ().
Multiclass vs. Multilabel Classification:
Multiclass Classification:
Classes are mutually exclusive; each instance belongs to exactly one class.
Architecture: Softmax normalization across class scores.
Multilabel Classification:
Multiple target categories can simultaneously be present on a single instance (e.g., a machine experiencing both a bearing fault and a cooling fault concurrently).
Architecture: Independent binary logistic regression models, applying one sigmoid activation per label.
Decision Boundaries and Regional Geometries
Decision Boundary Mechanics:
A decision boundary is the geometric hypersurface in feature space that separates regions assigned to different categorical classes.
At the default threshold of , the boundary occurs precisely where:
For a two-feature linear model:
Note on linearity: Although the sigmoid activation function is nonlinear and produces a curved probability surface over the input space, the resulting decision boundary in feature space is a straight line.
Single-Feature Decision Boundary (Point):
Given model:
Boundary condition ():
The boundary consists of a single scalar threshold point at .
Two-Feature Linear Decision Boundary (Line):
Given model:
Decision boundary at threshold ():
Regional evaluation:
Test coordinate : Score (Class 0 region)
Test coordinate : Score (Class 1 region)
Threshold Alterations and Boundary Translation:
Changing the classification threshold shifts the decision boundary parallel to itself without rotating it:
At :
At :
Lowering the classification threshold to translates the line toward the origin, classifying a larger area of the feature space as Class 1.
Multiclass Linear Decision Boundaries (Convex Polygons):
Multiclass softmax partitions the feature space into piecewise-linear convex polygonal decision regions based on which class score is highest.
Illustrative three-class scoring model:
Healthy:
Bearing fault:
Cooling fault:
Pairwise boundaries are established by equating scores:
Healthy vs. Bearing fault boundary:
Healthy vs. Cooling fault boundary:
Bearing vs. Cooling fault boundary:
Nonlinear Decision Boundaries via Basis Expansion:
Standard logistic regression is intrinsically a linear classifier with respect to its inputs.
To produce nonlinear or curved decision boundaries, explicit nonlinear transformations (such as polynomial basis expansions) must be applied to the original features.
Example: Quadratic circular boundary model:
Decision boundary equation ():
Represents a circle with radius centered at the origin:
Inside circle (): Predicted as Class 0.
Outside circle (): Predicted as Class 1.
Comparative Analysis: Logistic Regression vs. Support Vector Classifiers
Direct Comparison Matrix:
Learning Goal:
Logistic Regression: Optimizes probability estimates by minimizing average log loss across all training samples.
Support Vector Classifier (SVC): Maximizes the geometric margin separating classes while penalizing margin violations using hinge loss.
Typical Output:
Logistic Regression: Continuous, well-calibrated class probabilities.
Support Vector Classifier (SVC): Uncalibrated decision scores and discrete categorical class labels.
Basic Decision Boundary:
Logistic Regression: Linear boundary in the space of the supplied features.
Support Vector Classifier (SVC): Linear boundary in the space of the supplied features for Linear SVM.
Handling Nonlinear Patterns:
Logistic Regression: Requires manual engineering of nonlinear features (e.g., polynomials, interactions).
Support Vector Classifier (SVC): Can map features implicitly into high-dimensional spaces via kernel functions (e.g., Radial Basis Function / RBF kernel).
Probability Estimation:
Logistic Regression: Probabilities are mathematically built into the model formulation.
Support Vector Classifier (SVC): Requires an explicit secondary post-processing calibration step (e.g., Platt scaling).
Common Requirements: Both model families require feature scaling, regularization tuning, and empirical validation splits. Neither algorithm consistently outperforms the other across all tasks.
Model Selection Guidelines:
Select Logistic Regression when:
Calibrated probability estimates are required for operational risk decisions.
Direct interpretability of individual feature weights is needed.
Select Linear SVM alongside Logistic Regression when:
The underlying class distributions appear linearly separable or mostly planar.
Select RBF Kernel SVM when:
The underlying class boundaries display complex nonlinear curvature and the dataset size is moderate.
Selection must be driven by empirical comparison using identical validation splits and task-aligned evaluation metrics.
Best Practices for Predictive Modeling Workflows
Reliable End-to-End Workflow Steps:
Step 1 (Data Splitting): Partition the dataset into training, validation, and test subsets before fitting any preprocessing components to prevent data leakage.
Step 2 (Feature Preprocessing & Model Fitting): Fit preprocessing transformations (such as standard scaling or min-max normalization) strictly on training data, then transform training and validation/test subsets. Fit model parameters using training data only.
Step 3 (Hyperparameter Tuning): Utilize validation splits or k-fold cross-validation to select regularization strength ( or ) and feature combinations.
Step 4 (Threshold Selection & Final Evaluation): Select the operational classification threshold based on application-specific utility functions, and evaluate final performance once on the hold-out test set.
Logistic Regression Strengths:
Produces direct, calibrated class probabilities.
Feature weights describe direct log-odds associations.
Computationally efficient, serving as an optimal baseline model.
L2 and L1 regularization mitigate overfitting on large feature sets.
Logistic Regression Limitations:
Probability calibration can degrade when evaluated on shifted, out-of-distribution data.
Multicollinearity among correlated features destabilizes weight estimates and obscures individual feature interpretation.
Cannot capture complex nonlinear interactions natively without explicit feature engineering.
Coefficients indicate statistical association, not causal mechanisms.
Model Evaluation Metrics and Classification Trade-Offs
Core Evaluation Metrics:
Accuracy: The proportion of overall correct classifications out of total predictions:
Precision: The proportion of positive predictions that are truly positive:
Recall (Sensitivity): The proportion of actual positive cases detected by the model:
Log Loss and Calibration: Measures assessing the accuracy of continuous predicted probabilities.
The Accuracy Paradox in Imbalanced Regimes:
In datasets where positive events (such as equipment faults) are rare, high accuracy alone is severely misleading.
A naive classifier that systematically predicts "non-faulty" for every machine will achieve high raw accuracy while failing completely to identify any actual faults.
Worked Confusion Matrix Evaluation:
Inspection evaluation cohort of total machines:
True Positives (Actual Faulty, Flagged Faulty):
False Negatives (Actual Faulty, Not Flagged):
False Positives (Actual Non-faulty, Flagged Faulty):
True Negatives (Actual Non-faulty, Not Flagged):
Computed Performance Metrics:
Precision:
Recall:
Accuracy:
Contrast with Naive Baseline:
A trivial baseline that always predicts "non-faulty" achieves accuracy ( true non-faulty machines out of ), but has a recall of , detecting zero faulty machines.
Synthesis of Conceptual Foundations
Sigmoid Transformation: Converts a single real-valued scalar score into a valid binary class probability .
Log Odds Transformation: Provides mathematical grounding and physical interpretability to the linear score .
Softmax Transformation: Extends the binary sigmoid formulation to multiclass probability distributions over mutually exclusive classes.
Decision Boundary Geometry: Determined jointly by the feature representations, parameter weights, and chosen probability threshold .
Generalization Pipeline: Disciplined data splitting, feature scaling, regularization, and threshold tuning govern whether a model successfully generalizes to unseen real-world environments.