Prediction units and error costs
Quick answer
A prediction unit says what receives one prediction. A prediction time says when it is made. A target horizon or outcome window specifies when the outcome is assessed. An error cost expresses the consequence of a mistake. Defining these before training helps prevent mismatched labels, unavailable inputs and misleading success metrics.
Frame a dispatch-time prediction
For one dispatched parcel, predict whether it will miss its promised arrival time. Suppose dispatch is Monday 09:00 and promised arrival is Tuesday 09:00: a 24-hour horizon for this example. The label is 1 if actual arrival is later than the promise, 0 if arrival is on time. A parcel whose status is still unknown must not automatically be labeled 0. Record how cancellations and missing arrivals are treated; exclude unresolved cases from this tiny example.
Weight at dispatch and the promised time are eligible inputs. Actual arrival time is an outcome, and using it as an input leaks future information. The unit is a parcel dispatch, not a driver or a daily aggregate.
Calculate two different error costs
A false positive predicts late for an on-time parcel; a false negative predicts on time for a late parcel. Assume an unnecessary alert costs 2 fictional units, and a missed delay costs 8. Count each error type and multiply by its assigned cost.
actual = [0, 1, 1, 0]predicted = [1, 0, 1, 0]false_positives = 0false_negatives = 0for truth, guess in zip(actual, predicted): if truth == 0 and guess == 1: false_positives += 1 elif truth == 1 and guess == 0: false_negatives += 1print(false_positives)print(false_negatives)print(2 * false_positives + 8 * false_negatives)Expected output:
1110zip pairs corresponding elements. These two lists have equal lengths. The total cost is 2 + 8 = 10. The costs are hypothetical, not estimates of a real business.
Equal accuracy can hide different consequences
On actual labels [0, 1, 1, 0], predictor A gives [1, 1, 1, 1] and predictor B gives [0, 0, 0, 0]. Each gets two of four correct. A makes two false positives; B makes two false negatives. Under our stated costs, A costs 4 and B costs 16.
Accuracy is the fraction of correct predictions. Both have 50% accuracy here, yet their estimated costs differ. Real decisions may also need capacity limits, uncertainty and a human review option.
Common mistake
Avoid changing the target after seeing the model score, or assuming all errors cost the same. The chosen target and metric should reflect the actual decision and available feedback.
Practice and next steps
Specify one unit, horizon, eligible feature and outcome for predicting whether a fictional machine requires maintenance within 48 hours. Compare the consequences of a missed alert and a false alarm. Next, evaluate a simple baseline on held-out data.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Prediction units and error costs — knowledge check
Apply the concepts from this lesson to small fictional scenarios.
Which is the prediction unit in the dispatch example?
A parcel is dispatched Monday 09:00 and promised Tuesday 09:00. What is its horizon to the deadline?
Actual late=1, predicted late=0. Which error?
Two false positives at 2 units each and one false negative at 8 cost how much?
How should an unresolved parcel be treated in this toy task?