Lawfare Group → Knowledge Institute → Lawfare Academy
← CS 230 — Mathematics, Statistics and Data for AI
Weeks 15–16
Decision metrics and a reproducible data report
Learning objectives
- Explain and trace the mechanisms in decision metrics and a reproducible data report.
- Apply the method to the worked example and changed-condition exercise.
- Identify assumptions, failure cases and the evidence needed to justify a result.
A metric is a choice about what counts as error. Accuracy weights every classification equally, which can obscure rare but important outcomes. A model that predicts no defects on a dataset with one percent defects achieves 99 percent accuracy while finding none. Compare a model with a baseline matched to the task and report class-specific behavior.
Thresholds convert scores into decisions. Changing a threshold often trades precision against recall. Select it using development data and operational costs, not by repeatedly optimizing on a final test set. If an alert requires manual review, capacity limits matter: a detector producing ten thousand alerts for a team that can examine fifty may be unusable even when its ranking looks good.
A reproducible report specifies the task, data grain, inclusion rules, split, transformations, metric definitions and uncertainty. Keep test labels reserved until choices are settled. If results prompt redesign, acknowledge that the test set has become development evidence and obtain a fresh final evaluation where possible. Present subgroup and time-period results when relevant, with denominators; a percentage without a count can hide fragile conclusions.
Worked reasoning The model correctly flags eight of twenty positives, so recall is only 40 percent. Eight of ten alerts are correct, giving 80 percent precision. Overall accuracy is 86 percent. A predictor that always chooses negative scores 80 percent accuracy here but zero recall; the chosen model improves detection, although whether it is useful depends on missed-event and review costs.
Extended teaching and laboratory
A confusion matrix describes counts at a chosen decision threshold. Accuracy, precision and recall summarize different denominators. Decision usefulness also requires costs, capacity and the consequences of false positives and false negatives. A high score on one metric does not establish a superior operational policy.
Threshold selection belongs in development, followed by evaluation on held-out data. Report the population and threshold with each matrix. A different prevalence or review process can change the practical value even if a reported aggregate score looks similar.
Worked problem System A has TP=30, FP=10, FN=20, TN=140. Each missed positive costs 100 units and each false alert costs 5. Compute accuracy, precision, recall and error cost.
Step-by-step reasoning 1. There are 200 cases. Accuracy=(30+140)/200=85%. Precision=30/40=75%; recall=30/50=60%.
- Miss costs total 20×100=2000. False-alert costs total 10×5=50. The stated error cost is 2050 units.
- An always-negative system has 150/200=75% accuracy and costs 50×100=5000. Accuracy alone hides the decision benefit.
- The cost calculation omits review labor for true alerts and intervention effects unless explicitly included. Do not label it total business profit.
Apply the idea
System A has TP=30, FP=10, FN=20, TN=140. Each missed positive costs 100 units and each false alert costs 5. Compute accuracy, precision, recall and error cost.
System B has TP=40, FP=40, FN=10, TN=110 under the same costs. Compare error costs and identify a capacity question.
Read the worked reasoning
B costs 10×100+40×5=1200, less than A’s 2050, despite lower accuracy of 75%. B generates 80 alerts versus A’s 40. If reviewers can handle only 50, the unconstrained cost comparison does not establish deployability. Evaluate a threshold or workflow under the actual capacity constraint.
Check understanding
Why reserve a final test set?
- To estimate performance after development choices are fixed
Feedback
Repeated adaptation to test results makes them development evidence.
- To tune every threshold repeatedly
Feedback
Threshold tuning belongs in development or validation.
- To ensure future data can never change
Feedback
A test estimates a specified setting, not all future environments.
Further reading
Study the complete on-site source sections below, then work the original example, changed-condition problem and transfer laboratory. Study scikit-learn Model Selection and Evaluation, especially classification metrics and cross-validation. Complete the mathematical exercises in the assigned sources before the final data report.