When Should a Probability Become an Action?
A probability is evidence, not a complete instruction. We need to decide how likely a sensor failure must be before an inspection is worth its cost.
12 sections · 3 questions · 2 coding challenges
The arrow keys move between sections too.
Separating Statistical Evidence From a Decision
BOTIE
Current threshold-tuning documentation makes that separation explicit: estimating scores and selecting a cutoff are distinct tasks. Our invented sensor costs show one simple expected-cost rule. They are teaching units, not an estimate of real maintenance costs or a recommendation for an operational safety system.
Sources for this history
Should We Inspect Every Sensor That Might Fail?
Botie's model assigns each greenhouse sensor a probability of failure. An inspection costs time, but missing a real failure also has a cost. A probability alone does not decide which action is preferable.
How large should the failure probability be before Botie inspects the sensor? That cutoff is our decision threshold. To choose it, we need to compare the consequences of inspecting with the consequences of leaving the sensor alone.
The probabilities and mistake costs are simplified teaching assumptions.
Step 1 of 3
Start with probabilities
The model supplies evidence about failure, not an inspection decision.
| Same sensor | Failure probability |
|---|---|
| Sensor 1 | 0.1 |
| Sensor 2 | 0.4 |
| Sensor 3 | 0.8 |
Sensor 1
- Failure probability
- 0.1
Sensor 2
- Failure probability
- 0.4
Sensor 3
- Failure probability
- 0.8
Step 2 of 3
Supply the consequence assumptions
Here a false alarm costs one unit and a missed failure costs four. Correct decisions cost zero in this simplified table.
| Mistake | Cost in the example |
|---|---|
| False alarm cost | 1 |
| Missed failure cost | 4 |
False alarm cost
- Cost in the example
- 1
Missed failure cost
- Cost in the example
- 4
Step 3 of 3
Choose the action with lower expected cost
Those assumptions give a cutoff of 0.2. The workshop includes the boundary as an inspect decision.
| Same sensor | Inspect? |
|---|---|
| Sensor 1 | 0 |
| Sensor 2 | 1 |
| Sensor 3 | 1 |
Sensor 1
- Inspect?
- 0
Sensor 2
- Inspect?
- 1
Sensor 3
- Inspect?
- 1
The decision needs consequences as well as probabilities
The costs determine a cutoff. The gate then turns each supplied probability into an action under that rule.
When is an inspection worth the cost?
A missed failure and an unnecessary inspection need not cost the same. Change one cost and see which supplied failure probabilities now justify acting.
BOTIE
Inspection decisions under the supplied costs
- 00
- 11
- 21
Follow the operations
1. Estimated failure probabilities
- 00.1
- 10.4
- 20.8
2. False-alarm cost
1
3. Missed-failure cost
4
4. Add
5
5. Divide
0.2
6. Threshold gate
- 00
- 11
- 21
7. Result
- 00
- 11
- 21
This assumes credible probabilities, nonnegative costs with a positive sum, and zero cost for correct decisions. Different cost tables require a different derivation.
1. Keep Probability and Action Separate
A probability describes an estimated frequency under similar circumstances. An action has consequences. Raising the threshold generally reduces positive decisions; lowering it generally increases them. Neither change requires retraining the score model.
The effect on false alarms and missed failures depends on the labelled data and the score ordering.
A conventional cutoff of one half is a convention, not a universal statement about the best decision.
2. Write Down the Cost Table
We will simplify the decision to inspect or leave alone. Correct decisions have zero cost. Inspecting a healthy sensor is a false alarm with cost one. Leaving a failed sensor alone is a miss with cost four.
For a failure probability p, inspection incurs the false-alarm cost only when the sensor is healthy. Leaving it alone incurs the missed-failure cost only when it fails.
Expected inspection cost = (1 - p) × 1
Expected leave-alone cost = p × 4These expectations assume that the estimated probability is suitable for this population and that the stated cost table describes the decision. Real inspections can have costs even when they are correct, which changes the table.
3. Find Where the Preferred Action Changes
The two expected costs are equal at the cutoff. Above it, a missed failure becomes more expensive in expectation than a false alarm. We choose inspection at equality as our stated tie rule.
(1 - p) × 1 = p × 4
1 = 5p
p = 0.2
General cutoff = false-alarm cost / (false-alarm cost + miss cost)The rule uses the relative costs. A larger missed-failure cost lowers the cutoff under these assumptions.
4. Choose and Test the Rule Without Reusing Final Answers
A cost-derived rule still needs evaluation. If we tune a threshold to a validation metric, we must keep the final test separate. Choosing the best cutoff on the final test and reporting that same result gives an optimistic estimate.
Calibration also matters: a score labelled as a probability must be credible for expected-cost arithmetic. A ranking alone can support threshold searches on validation data, but does not justify interpreting every score as a probability.
The workshop builds the cost-derived cutoff and applies it. The Python practice also evaluates a changed cost assumption.
5. Compare the Expected Cost of Each Action
Suppose the probability of a failure is trustworthy, a false inspection costs one unit, and a missed failure costs nine. Inspecting is costly only when the sensor is healthy under this simplified loss table. Not inspecting is costly when it is faulty.
Write those two expected costs and choose the smaller one. This explains why a halfway threshold is not a universal decision rule. Different costs, probability quality or capacity constraints change the decision.
Cost(inspect) = 1 × (1 - p)
Cost(do not inspect) = 9 × p
Inspect when 1 - p < 9p
p > 0.16. A Budget Can Prevent Acting on Every High-Risk Sensor
If Botie has two inspection slots, he may have to rank sensors and take the first two even when more exceed a cost threshold. The number of inspections is fixed, so the effective score cutoff changes with the incoming batch.
State how ties are handled and whether inspection costs or benefits vary by sensor. A top-k policy answers a different operational question from one fixed probability threshold.
Select two inspections reproducibly
The input order breaks equal-score ties in this small demonstration.
import numpy as np
risk = np.array([0.8, 0.6, 0.6, 0.2])
chosen = np.argsort(-risk, kind='stable')[:2]
print(chosen.tolist())
print((risk > 0.1).tolist())[0, 1]
[True, True, True, True]The cost threshold requests four inspections while the budget permits two. Evaluate the actual policy Botie will use.
Check yourself
Questions on Parts 1 to 6
Question 1 of 3
One half is always the best probability cutoff.
Try it with Botie
Build with Botie
Write and run Python