Supervised & Unsupervised Learning

Chapter 5
Classification and Probability Estimation

Graduate Program in Business Analytics
Supervised & Unsupervised Learning   •   Graduate

Classification and Probability Estimation

Introduction and context

Classification assigns an observation to one of a finite set of categories, such as fraud/not fraud, churn/not churn, or low/medium/high risk. Probability estimation goes further: it estimates the conditional probability of each outcome given observed predictors. This distinction is central to business analytics. A bank may need a yes/no lending decision, but it also needs a reliable default probability to price credit, allocate capital, and compare applicants consistently.

Classification is supervised learning because the training data contain an outcome label. Let x denote a vector of predictors and Y the class label. The central quantity is

P(Y = k | X = x)

where k identifies a class. A classifier converts these probabilities, or a directly estimated decision score, into an action. The conversion depends on the business objective, error costs, operational capacity, and governance requirements.

Learning objectives

By the end of this chapter, you should be able to:

  • distinguish classification, scoring, and probability estimation;
  • formulate binary and multiclass classification problems;
  • explain and fit logistic regression, discriminant analysis, naïve Bayes, and nearest-neighbor models;
  • evaluate discrimination, calibration, and decision performance;
  • select thresholds under asymmetric costs and operational constraints;
  • address class imbalance without contaminating validation results;
  • interpret limitations, ethical risks, and governance requirements.

1. The classification problem

Suppose a dataset contains observations (xi, yi), for i = 1, …, n. In binary classification, yi ∈ {0,1}. A model estimates p(x) = P(Y=1|X=x). A threshold rule predicts class 1 when p(x) ≥ t and class 0 otherwise, where t is selected for a stated purpose rather than automatically fixed at 0.5.

The confusion matrix records outcomes:

Actual 1Actual 0
Predicted 1True positive (TP)False positive (FP)
Predicted 0False negative (FN)True negative (TN)

Important measures include

Accuracy = (TP + TN)/(TP + TN + FP + FN)
Precision = TP/(TP + FP), Recall = TP/(TP + FN)

Recall is also sensitivity or true-positive rate. Specificity is TN/(TN+FP), and false-positive rate is FP/(FP+TN). The F1 score is the harmonic mean of precision and recall:

F1 = 2 × Precision × Recall/(Precision + Recall)

These metrics answer different questions. Accuracy can be misleading when the positive class is rare. Precision depends on prevalence as well as model quality, whereas the receiver operating characteristic (ROC) curve displays recall against false-positive rate over thresholds. The area under that curve (ROC-AUC) measures ranking discrimination, not probability accuracy. Precision–recall curves are often more informative for rare positive events.

Multiclass classification uses Y ∈ {1,…,K}. A model estimates one probability per class, with probabilities nonnegative and summing to one. Common decision rules choose the class with maximum estimated probability, although unequal costs may require a different rule.

2. Logistic regression

Binary logistic regression

Logistic regression models the log odds of the positive class as a linear function of predictors:

log[p(x)/(1 − p(x))] = β₀ + β₁x₁ + … + βpxp = βᵀx̃

Here p(x) is the conditional probability of class 1, β₀ is the intercept, βj is the coefficient for predictor xj, and x̃ includes an intercept term. Solving for probability gives the logistic function:

p(x) = 1/[1 + exp(−βᵀx̃)]

The model assumes a linear relationship between predictors and log odds, conditional independence is not required, and observations are typically treated as independent for maximum-likelihood estimation. Continuous predictors need not be normally distributed. Nonlinearity can be represented with transformations, splines, interactions, or carefully chosen features.

For a one-unit increase in xj, holding other predictors constant, the odds are multiplied by exp(βj). This interpretation applies to the specified scale and coding of the predictor; it is not a percentage-point change in probability. For example, βj=0.40 implies an odds ratio of approximately exp(0.40)=1.49.

The coefficients are usually estimated by maximizing the Bernoulli log-likelihood:

ℓ(β) = ∑ᵢ [yᵢ log pᵢ + (1−yᵢ) log(1−pᵢ)]

where pi=p(xi). Regularization can improve generalization. Ridge estimation adds λ∑j=1p βj² to the negative log-likelihood; lasso adds λ∑j=1p |βj|. The intercept is commonly excluded from penalization. λ is selected using training-only cross-validation.

Multinomial logistic regression

For K classes, choose a reference class, often class K. For k=1,…,K−1,

log[P(Y=k|x)/P(Y=K|x)] = βₖᵀx̃

The resulting softmax probabilities are

P(Y=k|x) = exp(βₖᵀx̃)/[1 + ∑r=1K−1 exp(βᵣᵀx̃)]

for nonreference classes; the reference probability is the reciprocal denominator. Coefficients are relative to the reference category, so interpretation requires care.

3. Discriminant analysis

Discriminant analysis models the distribution of predictors within each class. Bayes’ rule gives

P(Y=k|x) = [πₖ fₖ(x)]/[∑r=1K πᵣ fᵣ(x)]

where πk=P(Y=k) is the class prior and fk(x) is the class-conditional density. The classifier selects the class with the largest posterior probability, unless costs alter the decision.

Linear discriminant analysis

LDA assumes that predictors within each class follow multivariate normal distributions and that all classes share a covariance matrix Σ. The discriminant score, omitting terms common to all classes, is

δₖ(x) = xᵀΣ⁻¹μₖ − ½μₖᵀΣ⁻¹μₖ + log πₖ

where μk is the class mean. Equal covariance matrices produce linear decision boundaries. LDA can be effective with limited data and correlated continuous predictors, but covariance estimation becomes unstable when predictors are numerous relative to observations.

Quadratic discriminant analysis

QDA permits a separate covariance matrix Σk for each class. Its score is

δₖ(x) = −½ log|Σₖ| − ½(x−μₖ)ᵀΣₖ⁻¹(x−μₖ) + log πₖ

QDA creates quadratic boundaries and is more flexible, but estimates many more parameters. Regularized or shrinkage discriminant methods can stabilize covariance estimates. Priors should reflect the deployment population or an explicitly justified decision policy; inserting arbitrary priors changes both probabilities and classifications.

4. Naïve Bayes

Naïve Bayes applies Bayes’ rule while assuming conditional independence of predictors given the class:

P(Y=k|x) ∝ πₖ ∏j=1p P(Xj=xj|Y=k)

For continuous predictors, a Gaussian naïve Bayes model commonly estimates a class-specific mean and variance for every feature. For counts, multinomial or Poisson variants may be appropriate; for binary features, Bernoulli likelihoods are used.

The independence assumption is usually false, but classification can still perform well because the model may rank classes correctly even when its probabilities are poorly calibrated. Computation is fast, and the method is useful for high-dimensional text or screening applications. Zero estimated probabilities create instability, particularly with categorical features; Laplace smoothing replaces zero counts with a small positive allocation. Smoothing is a modeling choice and should be validated rather than assumed to improve every dataset.

5. Nearest-neighbor methods

The k-nearest-neighbor (k-NN) classifier stores the training observations. For a new point, it identifies the k closest observations and predicts the majority class. A simple probability estimate is

p̂k(x) = (number of class-1 observations among k neighbors)/k

This estimate is discrete and can be poorly calibrated, especially for small k. Distance is commonly Euclidean:

d(x,z) = √[∑j=1p (xj−zj)²]

This is appropriate only when feature scales and meanings justify it. Standardization using training-set means and standard deviations is often necessary; the same transformation must then be applied to validation and production data. Irrelevant variables, missing values, high dimensionality, and unequal feature scales can severely degrade performance. Larger k reduces variance but increases bias. Distance-weighted voting and approximate neighbor search may improve practical performance.

6. Probability quality: discrimination and calibration

A model can rank risky customers correctly while reporting probabilities that are too high or too low. Calibration asks whether among cases assigned probability 0.7, approximately 70% experience the event. Reliability diagrams group predictions into bins and compare mean predicted probability with observed event frequency.

The Brier score for binary outcomes is the mean squared probability error:

Brier = (1/n)∑ᵢ(p̂ᵢ−yᵢ)²

It lies between 0 and 1 for binary outcomes, with lower values better, although comparisons should consider the event prevalence and a suitable baseline. Log loss is

LogLoss = −(1/n)∑ᵢ[yᵢ log p̂ᵢ + (1−yᵢ)log(1−p̂ᵢ)]

and heavily penalizes confident incorrect predictions. Predictions must be clipped away from exactly 0 or 1 for numerical stability when calculating log loss.

Calibration methods include Platt scaling, which fits a logistic transformation of a model score, and isotonic regression, a flexible monotonic mapping. Calibration must use data separate from the data used to fit the base model, commonly through cross-validation or a dedicated calibration set. Calibration can vary across time, geography, and protected groups; it should therefore be monitored after deployment.

7. Thresholds, costs, and decisions

Probability estimation and action selection should be separated. Let CFP be the cost of a false positive and CFN the cost of a false negative, with correct decisions assigned zero cost. Predict positive when the expected cost of predicting positive is no greater than that of predicting negative:

CFP(1−p) ≤ CFN p

Thus the cost-minimizing threshold is

t* = CFP/(CFP + CFN)

This formula assumes calibrated probabilities, only these two error costs, no action cost, and equal consequences across cases. If intervention costs, capacity limits, abstention, or varying case-specific costs exist, expected utility should be calculated directly for each available action.

For example, if a false positive costs 2 units and a false negative costs 8 units, t*=2/(2+8)=0.20. A case with estimated risk 0.25 should be treated under the stated assumptions. This does not imply that 0.20 is universally optimal: the threshold may need adjustment for capacity, legal obligations, customer impact, or changing prevalence.

Thresholds should be selected on validation data and evaluated on untouched test data. Reporting a single accuracy value at a default threshold conceals the trade-off between errors. Decision curves, expected monetary value, and cost curves connect model outputs to organizational action.

8. Class imbalance and sampling design

Class imbalance occurs when one outcome is much less common than another. It is not itself a modeling error: if fraud is rare in the population, a valid model should reflect that prevalence. Problems arise when accuracy is optimized, minority examples are omitted, or the training sample does not represent deployment.

Useful practices include stratified splitting, class-specific metrics, class-weighted loss, careful oversampling, and threshold selection based on business costs. Random oversampling duplicates minority cases; undersampling discards majority cases. Synthetic methods such as SMOTE generate interpolated minority examples, but synthetic records must be created only inside training folds. Resampling before splitting causes leakage because information from validation observations influences training data.

Class weights alter the fitting objective and can improve minority recall, but the resulting scores may no longer represent population probabilities. If probabilities are required, recalibration using representative validation data may be necessary. When the deployment prevalence differs from training prevalence and class-conditional distributions are stable, prior-probability adjustment may help; the assumption should be tested rather than taken for granted.

9. Model development and validation workflow

A defensible workflow is:

  1. Define the decision, prediction horizon, positive class, and costs.
  2. Establish the unit of analysis and prevent outcome leakage.
  3. Split data chronologically when deployment is temporal; otherwise use an appropriate stratified split.
  4. Fit preprocessing, feature selection, resampling, and model parameters inside training folds.
  5. Compare a baseline with logistic regression, discriminant, naïve Bayes, and k-NN candidates where suitable.
  6. Evaluate discrimination, calibration, subgroup performance, and business cost.
  7. Calibrate probabilities when justified, using independent or cross-validated predictions.
  8. Select a threshold on validation data and confirm performance on a final test set.
  9. Document assumptions, versions, exclusions, and monitoring triggers.

Repeated cross-validation provides more stable estimates but does not replace a final untouched test set. Time-dependent problems require special attention to concept drift: relationships between predictors and outcomes can change even when the variables themselves appear stable.

10. Applied case: illustrative loan-retention intervention

Background and problem

A fictional retail bank wants to identify customers likely to close a deposit account within 60 days. The bank can contact only 15% of customers each week. A missed likely closure costs an estimated 120 monetary units in lost contribution; an unnecessary contact costs 8 units. The target is binary and the event rate is 6%.

Analysis

The analytics team creates a time-based training, validation, and test split. Predictors include tenure, balance trend, service complaints, digital activity, and recent rate changes. Variables recorded after closure or after the intervention decision are excluded. Because the event is rare, the team reports precision–recall curves, recall at the 15% capacity, calibration, and expected cost rather than accuracy alone.

A regularized logistic model is selected as a transparent baseline. A gradient-free comparison is made with LDA, naïve Bayes, and standardized k-NN. k-NN performs poorly because sparse, heterogeneous customer features make distances unreliable. Naïve Bayes ranks cases adequately but is overconfident. Logistic regression is calibrated with out-of-fold predictions and isotonic regression, then evaluated on the time-held-out test set.

Approach and decision rule

Under the simplified cost assumptions, the threshold is 8/(8+120)≈0.0625. However, capacity allows intervention for only 15% of customers. The bank therefore ranks calibrated risks and contacts the highest-risk customers up to capacity, checking expected value and fairness constraints. The threshold becomes an operational consequence of capacity and value, not merely a statistical convention.

Outcome and governance

In the illustrative evaluation, the intervention list captures substantially more closures than random selection, but performance declines in a new region. Investigation identifies a change in rate-plan policy and a shift in event prevalence. The bank updates the calibration layer, retrains after confirming label quality, and monitors subgroup recall, contact rates, complaints, and drift. It also provides an explanation of the principal factors associated with a risk score and prohibits use of protected attributes as unjustified proxies.

Learning points

The case demonstrates that a useful model must be temporally valid, calibrated, capacity-aware, and connected to expected value. A high AUC alone does not establish that an intervention is profitable or equitable.

11. Limitations, ethics, and governance

No classifier establishes causality. A high-risk customer may be unlikely to respond to an intervention, and targeting may alter future outcomes. Predictive accuracy can coexist with unfair allocation if historical labels reflect unequal treatment or if error rates differ across groups. Protected attributes may be needed for auditing even when they are excluded from prediction; legal requirements vary by jurisdiction.

Governance should address purpose limitation, data minimization, consent and lawful use, access control, retention, explainability appropriate to the decision, human review, appeal mechanisms, and documentation. Probability estimates should not be presented as facts. High-impact decisions require validation, monitoring, and a clear process for correcting data and model errors.

Contemporary practice increasingly uses ensembles, gradient boosting, deep learning, conformal prediction, and automated monitoring. These methods can improve predictive performance, but they do not remove the need for calibrated uncertainty, leakage control, cost-sensitive evaluation, and accountable decision design. In regulated settings, the simplest model that meets the performance and governance requirement is often preferable.

Best-practice checklist

  • Define the positive event and prediction horizon precisely.
  • Separate probability estimation from threshold-based action.
  • Use representative, leakage-free validation data.
  • Scale distance-based methods using training information only.
  • Evaluate calibration as well as ranking discrimination.
  • Treat resampling as part of the training pipeline.
  • Select thresholds from costs, capacity, and utility.
  • Examine subgroup and temporal performance.
  • Monitor prevalence, calibration, drift, and realized outcomes.
  • Preserve reproducible documentation and human accountability.

Chapter Summary

Classification predicts discrete outcomes, while probability estimation quantifies uncertainty about those outcomes. Logistic regression models linear log odds and provides an interpretable baseline; multinomial logistic regression extends it to multiple classes. LDA and QDA use class-conditional distributions, with shared and class-specific covariance assumptions respectively. Naïve Bayes uses conditional independence for computational simplicity, and k-NN estimates labels from local neighborhoods but is sensitive to scaling and dimensionality.

Discrimination and calibration are distinct. Confusion-matrix metrics, ROC-AUC, and precision–recall analysis assess ranking or classification behavior, whereas reliability diagrams, Brier score, and log loss assess probability quality. Thresholds should reflect error costs, operational capacity, and utility. Imbalance requires appropriate metrics and leakage-free resampling, not automatic distortion of population prevalence. Finally, responsible deployment requires temporal validation, fairness assessment, monitoring, documentation, and human governance.

Key Terms

Conditional probability: Probability of an outcome given predictors or information.

Classification: Assignment of an observation to one of several categories.

Calibration: Agreement between predicted probabilities and observed frequencies.

Confusion matrix: Table of predicted versus actual binary classes.

Discriminant analysis: Classification based on class-conditional predictor distributions.

False negative: A negative prediction when the actual class is positive.

False positive: A positive prediction when the actual class is negative.

Logistic regression: Model that represents log odds as a function of predictors.

Naïve Bayes: Bayesian classifier using conditional independence of predictors given class.

Nearest neighbor: Method that predicts using nearby training observations.

Precision: Proportion of predicted positives that are actual positives.

Prior probability: Pre-model probability assigned to a class.

Recall: Proportion of actual positives correctly identified.

Regularization: Penalty used to control model complexity.

ROC-AUC: Area under the curve of recall versus false-positive rate.

Sensitivity: Another name for recall.

Specificity: Proportion of actual negatives correctly identified.

Threshold: Cutoff converting a score or probability into an action.

Utility: Value associated with an action and its outcome.

Review Questions

Short Answer Questions

  1. Why can accuracy be misleading for a rare positive class?
  2. Interpret exp(βj) in binary logistic regression.
  3. What assumption distinguishes LDA from QDA?
  4. Why must predictors often be standardized for k-NN?
  5. Distinguish discrimination from calibration.

Long Answer Questions

  1. Explain how logistic regression estimates binary probabilities, including coefficient interpretation, estimation, and regularization.
  2. Compare LDA, QDA, naïve Bayes, and k-NN in terms of assumptions, flexibility, computational cost, and likely applications.
  3. Explain why probability calibration must be evaluated separately from ROC-AUC.
  4. Discuss how class imbalance can affect training, evaluation, and probability interpretation.
  5. Design a model-validation and monitoring plan for a credit-risk classifier.

Analytical / Application Questions

  1. A false positive costs 5 units and a false negative costs 45 units. Under the stated two-error-cost assumptions, calculate the cost-minimizing probability threshold and explain when it would not be appropriate.
  2. A fraud model has excellent ROC-AUC but poor precision at the investigation capacity of 2% of transactions. Propose an evaluation and threshold-selection strategy.
  3. A classifier is trained on data with a 20% event rate but deployed where the event rate is 5%. Explain which probability and decision issues should be investigated before deployment.

Multiple Choice Questions with Answers

Question 1

Which quantity does binary logistic regression model linearly?

A. The raw probability

B. The log odds

C. The squared error

D. The Euclidean distance

Correct Answer: B. The log odds

Question 2

If a false positive costs 2 units and a false negative costs 8 units, what threshold follows from the stated two-error-cost formula?

A. 0.20

B. 0.25

C. 0.50

D. 0.80

Correct Answer: A. 0.20

Question 3

Which measure primarily evaluates probability calibration?

A. ROC-AUC

B. Recall

C. Brier score

D. Specificity

Correct Answer: C. Brier score

Question 4

What covariance assumption produces linear boundaries in standard LDA?

A. Each class has a different covariance matrix

B. All classes share a covariance matrix

C. Covariance must be zero

D. Predictors must be binary

Correct Answer: B. All classes share a covariance matrix

Question 5

Why is feature scaling important for ordinary k-NN?

A. It changes the class labels

B. It prevents all missing values

C. Distance can otherwise be dominated by large-scale variables

D. It guarantees calibrated probabilities

Correct Answer: C. Distance can otherwise be dominated by large-scale variables

Question 6

What is the central simplifying assumption of naïve Bayes?

A. Equal class prevalence

B. Conditional independence of predictors given the class

C. Linear class boundaries

D. A binary target only

Correct Answer: B. Conditional independence of predictors given the class

Question 7

Which metric is often especially informative for rare positive events?

A. Precision–recall analysis

B. Training accuracy alone

C. Mean predictor value

D. R-squared

Correct Answer: A. Precision–recall analysis

Question 8

Where should SMOTE be applied in cross-validation?

A. Before the dataset is split

B. Only to the test set

C. Inside each training fold

D. After final test evaluation

Correct Answer: C. Inside each training fold

Question 9

A model with good ranking but overconfident probabilities has strong discrimination and weak what?

A. Specificity

B. Calibration

C. Prevalence

D. Feature scaling

Correct Answer: B. Calibration

Question 10

What does a threshold primarily do?

A. Convert a score or probability into an action or class

B. Guarantee causal effects

C. Remove sampling bias automatically

D. Estimate covariance matrices

Correct Answer: A. Convert a score or probability into an action or class

Supervised & Unsupervised Learning
Chapter 5 of 15