AI & Machine Learning Fundamentals

Chapter 10
Model Evaluation, Interpretation, and Decision Analytics

Advance Diploma in Artificial Intelligence and Machine Learning
AI & Machine Learning Fundamentals   •   Advance Diploma

Model Evaluation, Interpretation, and Decision Analytics

Introduction

A machine-learning model is not useful merely because it produces predictions. It must produce predictions that are accurate enough for the intended purpose, reliable under realistic conditions, understandable to relevant stakeholders, and capable of supporting defensible decisions. Model evaluation therefore extends beyond selecting a single performance score. It includes the design of evaluation data, selection of appropriate metrics, comparison with meaningful baselines, investigation of errors, assessment of probability quality, explanation of model behaviour, estimation of uncertainty, and translation of predictions into actions.

This chapter treats evaluation as a decision-oriented activity. A classifier used to screen patients, approve loans, detect fraud, or allocate public services may require different metrics and thresholds even when all tasks involve binary prediction. Similarly, a forecasting model may have a low average error but still be unacceptable if it fails during rare but costly events.

Learning Objectives

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

  • distinguish training, validation, test, and external evaluation data;
  • select metrics appropriate to the prediction task and its costs;
  • apply cross-validation and compare models with suitable baselines;
  • construct and interpret confusion matrices and error analyses;
  • explain calibration and assess the quality of predicted probabilities;
  • use interpretable and post-hoc explanation methods responsibly;
  • distinguish aleatoric from epistemic uncertainty;
  • design cost-sensitive thresholds and convert predictions into decisions;
  • identify limitations, fairness risks, leakage, and governance requirements in model evaluation.

1. Evaluation as a Chain from Prediction to Decision

A useful evaluation framework separates four objects:

  1. The data-generating situation: people, transactions, machines, or events in the real world.
  2. The predictive model: a function that maps features to a score, value, class, or probability.
  3. The decision rule: a rule that converts the model output into an action.
  4. The outcome and cost: what subsequently occurs and what the consequences are.

For a binary classifier, a model may output a score s(x) or an estimated probability p(x) = P(Y=1|X=x). A decision rule may classify an observation as positive when p(x) ≥ t, where t is a threshold. Changing the threshold changes the numbers of true positives, false positives, true negatives, and false negatives, even though the underlying model is unchanged.

This distinction is essential. A model can rank cases effectively but use poorly calibrated probabilities. It can have high accuracy but fail to identify a minority class. It can have excellent average performance but be unsafe for a particular subgroup or operating condition.

Evaluation datasets

  • Training set: used to estimate model parameters.
  • Validation set: used to choose algorithms, hyperparameters, features, and thresholds.
  • Test set: used once, or very sparingly, for an approximately unbiased final estimate.
  • External or prospective set: collected from a different institution, time period, geography, or operating environment to test generalisation.

The test set must not influence model development. Repeatedly examining test results and modifying the model effectively turns the test set into validation data, causing optimistic estimates.

Data leakage

Leakage occurs when information unavailable at prediction time enters training or evaluation. Examples include using a hospital discharge code to predict admission, calculating a feature using future observations, or imputing missing values before splitting the data. Leakage often produces impressive but invalid performance.

The correct practice is to split data according to the deployment situation and fit all learned preprocessing operations—such as scaling, imputation, feature selection, and dimensionality reduction—inside each training fold.

2. Classification Metrics and Their Meaning

For binary outcomes, let the actual class be positive or negative and the prediction be positive or negative.

Actual / PredictedPositiveNegative
PositiveTrue positive (TP)False negative (FN)
NegativeFalse positive (FP)True negative (TN)

The total number of observations is N = TP + TN + FP + FN.

Core metrics

Accuracy is the proportion of all predictions that are correct:

Accuracy = (TP + TN) / (TP + TN + FP + FN)

Accuracy is appropriate when classes and error costs are reasonably balanced. It can be misleading under class imbalance. If only 1% of transactions are fraudulent, always predicting “not fraud” gives 99% accuracy while detecting no fraud.

Precision, also called positive predictive value, measures how often predicted positives are truly positive:

Precision = TP / (TP + FP)

It matters when investigating a false alarm is expensive or disruptive.

Recall, also called sensitivity or true-positive rate, measures the proportion of actual positives detected:

Recall = TP / (TP + FN)

It matters when missing a positive case is dangerous, such as failing to identify a serious disease.

Specificity, or true-negative rate, is:

Specificity = TN / (TN + FP)

The false-positive rate is FPR = 1 - Specificity.

The F1 score is the harmonic mean of precision and recall:

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

It is useful when both precision and recall matter and a single summary is required. It should not be interpreted as a universal measure of model quality; it ignores true negatives and does not incorporate financial or social costs.

The balanced accuracy is:

Balanced accuracy = (Sensitivity + Specificity) / 2

It gives equal weight to each class and is often more informative than ordinary accuracy for imbalanced outcomes.

Worked example: a screening classifier

Suppose a model is evaluated on 1,000 cases with TP = 72, FN = 8, FP = 108, and TN = 812.

Accuracy = (72 + 812) / 1000 = 0.884 = 88.4%
Precision = 72 / (72 + 108) = 0.400 = 40.0%
Recall = 72 / (72 + 8) = 0.900 = 90.0%
Specificity = 812 / (812 + 108) ≈ 0.883 = 88.3%

Thus, the model detects most positive cases, but only 40% of people flagged by it are actually positive. Whether this is acceptable depends on the consequences of follow-up testing and missed cases.

Ranking metrics

When a model produces a continuous score, the threshold can be varied. The receiver operating characteristic (ROC) curve plots recall against false-positive rate. The area under the ROC curve (ROC-AUC) can be interpreted as the probability that a randomly selected positive case receives a higher score than a randomly selected negative case, subject to the usual handling of ties.

ROC-AUC is a ranking measure, not a measure of probability calibration and not a direct estimate of operational utility. With highly imbalanced data, the precision–recall curve can be more informative because it focuses on positive predictions. Average precision summarises the precision–recall relationship, but its exact computation depends on the convention used by the software.

Multiclass classification

For more than two classes, metrics may be averaged using:

  • Macro averaging: calculate a metric per class and give each class equal weight.
  • Micro averaging: pool decisions across classes before calculating the metric.
  • Weighted averaging: weight each class by its prevalence.

Macro averaging highlights performance on rare classes; weighted averaging reflects the observed population but can conceal poor minority-class performance. The averaging method must always be reported.

3. Regression and Forecasting Metrics

For regression, let yi be the observed value, ŷi the prediction, and n the number of observations.

The mean absolute error (MAE) is:

MAE = (1/n) ∑ᵢ₌₁ⁿ |yᵢ − ŷᵢ|

MAE is expressed in the same units as the target and treats errors linearly.

The mean squared error (MSE) is:

MSE = (1/n) ∑ᵢ₌₁ⁿ (yᵢ − ŷᵢ)²

The root mean squared error (RMSE) is:

RMSE = √MSE

RMSE has the target’s units but penalises large errors more strongly than MAE. This is appropriate when large errors are disproportionately costly, but it is sensitive to outliers.

The coefficient of determination, or R², is commonly defined as:

R² = 1 − [∑ᵢ₌₁ⁿ (yᵢ − ŷᵢ)²] / [∑ᵢ₌₁ⁿ (yᵢ − ȳ)²]

Here ȳ is the sample mean of observed targets. This definition compares the model with the constant mean predictor. R² can be negative when the model is worse than that baseline, and a high value does not necessarily indicate accurate predictions in practical units.

Percentage-based measures such as mean absolute percentage error can be unstable or undefined when actual values are zero or near zero. Alternatives include MAE, scaled errors, or domain-specific loss functions.

For time series, random splitting can leak future information. Evaluation should respect temporal order, using rolling or expanding-window validation. Forecast metrics should also be reported separately for important periods, such as peak demand or extreme weather.

4. Baselines, Cross-Validation, and Statistical Discipline

A model should be compared with a baseline that represents a plausible simple strategy. Examples include:

  • majority-class prediction for classification;
  • prior-period or seasonal-naïve forecasts for time series;
  • predicting the training mean or median for regression;
  • an existing production system;
  • a policy based on expert rules.

A complex model that barely outperforms a transparent baseline may not justify its cost, maintenance burden, or governance risk.

Cross-validation

In k-fold cross-validation, the data are divided into k approximately equal folds. Each fold is used once as validation data while the other k − 1 folds are used for training. The reported estimate is often the mean of the k validation scores:

CV mean = (1/k) ∑ⱼ₌₁ᵏ Scoreⱼ

The sample standard deviation of fold scores is:

s = √{[1/(k−1)] ∑ⱼ₌₁ᵏ (Scoreⱼ − CV mean)²}

Cross-validation reduces dependence on one arbitrary split, but it does not eliminate uncertainty or guarantee performance after deployment. Stratified folds preserve class proportions when appropriate. Grouped folds keep related observations—such as records from the same patient, customer, or machine—in a single fold. Time-series splits preserve chronology.

Hyperparameter tuning must occur within the training portion of each outer split when an unbiased estimate is required. This is called nested cross-validation. Reporting only the best fold score is poor practice; report the mean, variation, sample sizes, and evaluation design.

5. Error Analysis and Model Diagnostics

Aggregate metrics conceal structure. Error analysis examines individual errors and groups them by meaningful attributes:

  • class, region, language, age band, or device type;
  • input quality and missingness;
  • score or probability range;
  • operational context and time period;
  • error severity and downstream consequence.

A practical error-analysis workflow is:

  1. define the target and acceptable error types;
  2. inspect false positives and false negatives separately;
  3. identify recurring data, labelling, or modelling patterns;
  4. quantify patterns on a held-out set;
  5. formulate a corrective intervention;
  6. re-evaluate on untouched data.

Useful diagnostics include residual plots for regression, calibration plots for probabilities, confusion matrices by subgroup, and performance against data-shift indicators. Randomly inspecting examples is helpful for discovering issues, but claims about frequency require quantitative measurement.

Data quality problems may be more important than algorithm choice. Duplicate records, inconsistent labels, selection bias, missing-not-at-random data, and changes in the target definition can dominate observed performance.

6. Calibration and Probability Quality

A classifier can rank cases correctly while producing probabilities that are systematically too high or too low. A model is calibrated when, among cases assigned probability p, approximately a proportion p actually have the positive outcome. For example, among 1,000 cases assigned a probability near 0.7, approximately 700 should be positive if the model is well calibrated in that population.

Calibration is distinct from discrimination. Discrimination concerns ordering; calibration concerns numerical meaning.

Common tools include:

  • reliability diagrams, which compare predicted probability bins with observed frequencies;
  • the Brier score:
Brier score = (1/n) ∑ᵢ₌₁ⁿ (pᵢ − yᵢ)²

where yi is 0 or 1 and pi is the predicted probability;

  • calibration intercept and slope, often estimated using a validation model;
  • calibration methods such as Platt scaling or isotonic regression.

Calibration must be assessed on data not used to fit the calibration mapping. It may deteriorate when prevalence, measurement practice, or population characteristics change. A calibrated probability is not automatically a causal risk estimate and should not be interpreted outside the population and time period for which it was validated.

7. Interpretation and Explainability

Interpretability concerns how humans understand a model and its outputs. It has several levels:

  • Global interpretation: overall relationships and important variables.
  • Local interpretation: reasons for one prediction.
  • Example-based interpretation: similar cases or influential training examples.
  • Counterfactual interpretation: changes that could alter an outcome.

For inherently interpretable models, coefficients or decision rules can be useful, but interpretation depends on scaling, coding, interactions, collinearity, and the link function. In a logistic model, a coefficient describes change in log-odds while holding other included variables fixed; it is not automatically a causal effect.

Post-hoc tools include permutation importance, partial-dependence plots, individual conditional-expectation plots, and Shapley-value-based methods. Each has limitations. Permutation importance can be distorted by correlated variables. Partial dependence averages over combinations of features that may be unrealistic. Local explanations can be unstable, and an explanation of a model is not proof that the model is correct.

Explanations should be evaluated for fidelity, stability, completeness, and usefulness to the intended audience. They must not expose sensitive information or encourage inappropriate reliance. In regulated settings, explanations should be documented with the model version, data version, method, and known limitations.

8. Uncertainty Estimation

A prediction is not complete without an indication of uncertainty when decisions are sensitive to error.

  • Aleatoric uncertainty arises from inherent randomness or measurement noise and may not be reducible by collecting more of the same information.
  • Epistemic uncertainty arises from limited knowledge, sparse training data, model assumptions, or distribution shift and may be reduced by better data or modelling.

For regression, a prediction interval describes uncertainty about a future observation, whereas a confidence interval describes uncertainty about an estimated parameter or mean response. These are different quantities.

Methods include bootstrap resampling, ensembles, Bayesian models, quantile regression, conformal prediction, and distribution-shift monitoring. A nominal 90% prediction interval should achieve approximately 90% coverage under the conditions supporting its method, although finite samples and distribution changes can cause miscoverage.

Uncertainty estimates themselves require evaluation. Report coverage, interval width, and performance across subgroups and operating conditions. A narrow interval is not desirable if it fails to contain the true outcome.

9. Cost-Sensitive Evaluation and Decision Thresholds

The best threshold depends on consequences. Let the cost of a false positive be CFP, the cost of a false negative be CFN, and assume correct decisions have zero cost. The expected cost over a sample is:

Expected cost = CFP × FP + CFN × FN

If probabilities are well calibrated and the costs are the only consequences, classify as positive when:

p(x) > CFP / (CFP + CFN)

This threshold follows by comparing the expected cost of each action. If the positive action has expected cost CFP × (1−p), and the negative action has expected cost CFN × p, choose positive when the first is smaller. The formula assumes calibrated probabilities, known and constant costs, two actions, and no additional capacity or fairness constraints. Real decisions may also involve intervention benefits, fixed costs, resource limits, and unequal costs across groups.

Worked threshold example

Suppose a missed positive case costs 9 units and a false alarm costs 1 unit. The cost-only threshold is:

t = 1 / (1 + 9) = 0.10

A case with predicted probability 0.15 should be selected under this simplified rule because 0.15 exceeds 0.10. However, if only 100 investigations are available each day, the organisation may need a top-k rule, a queueing policy, or a second-stage assessment rather than a fixed threshold.

Decision analysis should report a range of plausible costs and perform sensitivity analysis. A recommendation that changes completely when a cost estimate moves slightly is fragile and should be presented cautiously.

10. Fairness, Governance, and Responsible Evaluation

Evaluation must consider whether performance and harms are distributed fairly. Relevant analyses may compare error rates, calibration, selection rates, and predictive values across protected or vulnerable groups. Common fairness criteria can conflict, particularly when base rates differ. No single metric resolves the ethical question of what treatment is justified.

Important governance practices include:

  • documenting intended use, exclusions, data provenance, and known limitations;
  • obtaining lawful authority and appropriate consent for data use;
  • minimising sensitive data while retaining information necessary to detect inequity;
  • auditing subgroup performance and intersectional groups;
  • controlling access to predictions and explanations;
  • providing human review, appeal, and correction mechanisms where decisions affect rights or opportunities;
  • monitoring drift, calibration, error rates, and realised outcomes after deployment.

Fairness cannot be repaired solely by changing a threshold if labels are biased, access to follow-up differs, or the deployment process creates unequal burdens. Evaluation should therefore include the complete sociotechnical system, not only the predictive algorithm.

11. Applied Case: Predictive Maintenance in a Manufacturing Plant

The following is an illustrative case.

Background

A plant operates 600 industrial pumps. Unexpected failure causes production losses, while unnecessary maintenance consumes labour and replacement parts. An engineering team develops a model that predicts whether a pump will fail within the next seven days using vibration, temperature, pressure, operating hours, and maintenance history.

Problem

The initial model reports 94% accuracy. Managers are tempted to deploy it immediately. However, only 4% of pump-week records contain a failure. A majority-class baseline that predicts “no failure” for every record achieves 96% accuracy. The model is therefore worse than the baseline by accuracy, despite identifying some failures.

Analysis

The team creates a time-based test set covering the most recent three months and reports recall, precision, false alarms per week, and expected maintenance cost. They discover that random cross-validation had allowed records from the same failure episode to appear in both training and validation folds, inflating performance. A grouped, time-aware evaluation gives a more realistic estimate.

Error analysis shows that failures following recent repairs are often missed because repair records are entered with delays. This is a data-process problem, not simply a modelling problem. The team also finds that vibration sensors on older pumps are noisier, producing more false alarms for that subgroup.

Approach and solution

The plant adopts a two-stage policy. The model ranks pumps by predicted failure risk, while a maintenance engineer reviews the highest-risk cases. A threshold is chosen using estimated downtime and inspection costs, subject to a weekly capacity of 30 inspections. The team calibrates probabilities on a temporally separate validation period and reports uncertainty for pumps with sparse historical data.

A monitoring dashboard tracks calibration, recall, false alarms, subgroup performance, sensor availability, and the proportion of recommended inspections completed. Maintenance staff can override recommendations, but overrides are logged for later analysis.

Outcome

The decision policy reduces unexpected downtime in a pilot period while keeping inspections within capacity. The result is not attributed solely to the model: improved repair-record timeliness and engineer review also contribute. Performance is reassessed after a seasonal change in operating conditions.

Learning points

  1. Accuracy can be inferior to a simple baseline under severe imbalance.
  2. Evaluation design must match deployment time and grouping structure.
  3. The operational decision rule is distinct from the predictive model.
  4. Data quality and workflow changes may yield larger benefits than algorithm replacement.
  5. Monitoring after deployment is part of evaluation, not an optional extra.

12. Best-Practice Evaluation Workflow

A defensible workflow is:

  1. Define the decision, prediction horizon, population, and consequences.
  2. Specify the target and identify what information is available at prediction time.
  3. Select a split strategy that reflects deployment, including groups or time.
  4. Establish simple and current-system baselines.
  5. Choose metrics linked to the decision, not merely popular metrics.
  6. Use cross-validation or a development-validation design without leakage.
  7. Reserve a final test or external set.
  8. Examine errors, subgroups, calibration, and uncertainty.
  9. Select thresholds or policies using explicit costs and capacity constraints.
  10. Document assumptions, limitations, and versioned results.
  11. Pilot with safeguards and monitor realised outcomes.
  12. Revalidate when data, prevalence, processes, or objectives change.

Challenges and Limitations

No evaluation score provides a complete guarantee of future performance. Samples may be unrepresentative, labels may be delayed or biased, and deployment can change human behaviour. Metrics can conflict, uncertainty estimates can be miscalibrated, and explanations can create false confidence. Cost estimates may be incomplete, especially when harms are social or long-term. External validation is valuable but may still fail to represent all future conditions.

Evaluation should therefore be treated as an evidence argument: what was measured, on whom, under which assumptions, with what uncertainty, and with what consequences? The strength of a model claim depends on the strength of that entire argument.

Chapter Summary

Model evaluation connects predictive performance with real-world decisions. Classification metrics such as precision, recall, specificity, F1, ROC-AUC, and precision–recall measures answer different questions and must be selected according to class balance and error consequences. Regression metrics such as MAE, RMSE, and R² differ in units and sensitivity to large errors.

Baselines establish whether complexity is justified. Cross-validation improves reliability when its folds respect groups, time, and preprocessing boundaries. Error analysis reveals data and subgroup problems hidden by aggregate scores. Calibration assesses whether predicted probabilities have trustworthy numerical meaning, while explainability methods provide conditional insight rather than proof of correctness. Uncertainty estimation communicates limitations, and cost-sensitive thresholds convert probabilities into actions. Finally, fairness, governance, monitoring, and human oversight are necessary because a model operates within a broader sociotechnical system.

Key Terms

Accuracy: Proportion of all predictions that are correct.

Calibration: Agreement between predicted probabilities and observed event frequencies.

Confusion matrix: Table of true and false positive and negative predictions.

Cross-validation: Repeated training and validation across partitions of development data.

Decision threshold: Cut-off used to convert a score or probability into an action or class.

Discrimination: Ability to distinguish or rank cases with different outcomes.

Epistemic uncertainty: Uncertainty caused by limited knowledge, data, or model assumptions.

External validation: Evaluation on data from a different setting, period, or population.

False negative: Actual positive case predicted as negative.

False positive: Actual negative case predicted as positive.

F1 score: Harmonic mean of precision and recall.

Leakage: Use of information unavailable at prediction time in model development or evaluation.

MAE: Mean absolute error, expressed in target units.

Precision: Proportion of predicted positives that are truly positive.

Recall: Proportion of actual positives detected.

ROC-AUC: Ranking-based area under the receiver operating characteristic curve.

Sensitivity analysis: Examination of how conclusions change under alternative assumptions.

Test set: Data reserved for final performance estimation.

Uncertainty: Quantified lack of confidence about a prediction or estimate.

Validation set: Data used to select models, hyperparameters, or decision policies.

Review Questions

Short Answer Questions

  1. Why can accuracy be misleading for an imbalanced classification problem?
  2. Distinguish precision from recall.
  3. What is the purpose of a baseline model?
  4. Explain the difference between discrimination and calibration.
  5. Distinguish aleatoric uncertainty from epistemic uncertainty.

Long Answer Questions

  1. Explain how cross-validation should be designed for grouped and time-dependent data. Include the consequences of ignoring these structures.
  2. Compare MAE, RMSE, and R² and discuss when each may be appropriate.
  3. Describe a complete error-analysis process for a deployed classification model.
  4. Explain how interpretability methods can assist decision-makers while still producing misleading conclusions.
  5. Discuss the governance requirements for evaluating a model used in a high-impact decision.

Analytical / Application Questions

  1. A fraud model identifies 90 fraud cases, misses 10, and incorrectly flags 180 legitimate transactions out of 1,000 cases. Calculate precision, recall, specificity, and accuracy if the remaining legitimate cases are true negatives. Interpret the trade-off.
  2. A medical screening model has calibrated probabilities. A false positive costs 2 units and a false negative costs 18 units. Derive the cost-only probability threshold and explain why a hospital might still choose a different operational policy.
  3. Design an evaluation plan for a predictive-maintenance model when machines generate repeated observations, failures are rare, and maintenance capacity is limited. Specify the data split, baseline, metrics, threshold policy, monitoring measures, and fairness or governance checks.

Multiple Choice Questions with Answers

Question 1

Which metric measures the proportion of predicted positive cases that are actually positive?

A. Recall

B. Precision

C. Specificity

D. Accuracy

Correct Answer: B. Precision

Question 2

A model has TP = 80 and FN = 20. What is its recall?

A. 20%

B. 50%

C. 80%

D. 90%

Correct Answer: C. 80%

Question 3

Which evaluation design is most appropriate when observations from the same patient appear repeatedly?

A. Random splitting without grouping

B. Grouped cross-validation

C. Training-set evaluation

D. Majority-class evaluation

Correct Answer: B. Grouped cross-validation

Question 4

What does calibration primarily assess?

A. Whether predicted probabilities correspond to observed frequencies

B. Whether features are normally distributed

C. Whether a model has the highest possible accuracy

D. Whether training is faster than testing

Correct Answer: A. Whether predicted probabilities correspond to observed frequencies

Question 5

Which metric is expressed in the same units as the regression target and uses absolute errors?

A. MSE

B. ROC-AUC

C. MAE

D. Brier score

Correct Answer: C. MAE

Question 6

If false negatives cost substantially more than false positives, which change is generally consistent with a cost-sensitive policy?

A. Use a lower positive-decision threshold

B. Ignore recall

C. Always predict the negative class

D. Remove the validation set

Correct Answer: A. Use a lower positive-decision threshold

Question 7

What is a major limitation of a high ROC-AUC score?

A. It proves that probabilities are calibrated

B. It directly measures financial benefit

C. It does not by itself specify a useful operating threshold or cost

D. It can only be calculated for regression

Correct Answer: C. It does not by itself specify a useful operating threshold or cost

Question 8

Which situation is an example of data leakage?

A. Fitting preprocessing within each training fold

B. Using future information unavailable at prediction time

C. Evaluating on an external dataset

D. Comparing with a simple baseline

Correct Answer: B. Using future information unavailable at prediction time

Question 9

What is epistemic uncertainty?

A. Irreducible randomness in an observation

B. Uncertainty caused by limited knowledge or data

C. The proportion of true negatives

D. A threshold selected from a confusion matrix

Correct Answer: B. Uncertainty caused by limited knowledge or data

Question 10

A baseline predicts the majority class in a dataset where 96% of cases are negative. What accuracy does this baseline achieve?

A. 4%

B. 50%

C. 94%

D. 96%

Correct Answer: D. 96%

AI & Machine Learning Fundamentals
Chapter 10 of 14