Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

3.4 Chapter 3 Summary and Exercises

A vessel-washing robot turns every idea from Chapter 2 into one working decision. A cost matrix says what each mistake costs. Sensors, fused with naive Bayes, turn readings into a belief. Expected cost turns the belief into a programme. Learning from labelled examples supplies the models, and the learning curve says when to stop collecting data and start building a better sensor.

The chapter on one page

Key concepts

ConceptMeaningIn this chapter
Cost matrix C(a,x)C(a,x)cost of action aa when the state is xxprogramme × vessel type, capturing under-cleaning, over-cleaning, damage
Blind decisionbest single action using only the priorstandard, 2.75 per vessel
Oraclea robot that always knows the true state1.85 per vessel
Value of perfect informationblind cost − oracle cost0.90 per vessel: the most any sensor could save
Naive Bayesposterior ∝ prior × one likelihood per sensorcamera ratio, weight, grease
Cost vs. accuracya sensor’s worth is the mistakes it prevents, not how often it is rightcamera 85% accurate but costlier than the scale at 72%
Informative but useless aloneevidence that never changes the decisionthe grease sensor on its own
Maximum-likelihood estimatethe parameters that make the data most probablefractions, means, spreads per vessel type
Laplace smoothingadd α\alpha pseudo-counts so nothing is “impossible”the greasy tumbler
Learning curvetest cost vs. training sizeflattens near 1.96
Confusion matrixhow often each true type is predicted as each type“other” recognised only about half the time

Important equations

EquationName
E[C(a)]=∑xP(x) C(a,x)\mathbb{E}[C(a)] = \sum_x P(x)\,C(a,x)expected cost of a programme
E[C⋆]=∑xP(x) min⁡aC(a,x)\mathbb{E}[C^\star] = \sum_x P(x)\,\min_a C(a,x)oracle cost
P(x∣z1,z2,z3)∝P(x) p(z1∣x) p(z2∣x) P(z3∣x)P(x \mid z_1, z_2, z_3) \propto P(x)\,p(z_1 \mid x)\,p(z_2 \mid x)\,P(z_3 \mid x)naive Bayes
a⋆=arg⁡min⁡a∑xP(x∣z) C(a,x)a^\star = \arg\min_a \sum_x P(x \mid z)\,C(a,x)decision after sensing
P^(x)=Nx/N,P^(z=1∣x)=Nx,1/Nx\hat{P}(x) = N_x / N, \quad \hat{P}(z{=}1 \mid x) = N_{x,1}/N_xmaximum-likelihood counts
P^(z=1∣x)=(Nx,1+α)/(Nx+2α)\hat{P}(z{=}1 \mid x) = (N_{x,1} + \alpha)/(N_x + 2\alpha)Laplace smoothing

Review questions

  1. Name the three kinds of mistakes in the washing robot’s cost matrix and give one example of each.

  2. Why is standard the best programme when the robot has no sensors, even though it is the best choice for only two of the five vessel types?

  3. What is an oracle, and why is its cost useful to an engineer choosing sensors?

  4. Explain in your own words why the camera alone is more accurate than the scale alone but leads to a higher average cost.

  5. The grease sensor alone does not reduce the average cost at all. Does that mean it measures nothing useful? Explain.

  6. What does “naive” mean in naive Bayes? Give an example from the kitchen where the assumption fails.

  7. Why must a learned model be tested on vessels it did not see during training?

  8. What goes wrong if a probability is estimated as exactly zero? How does Laplace smoothing help?

  9. What does it mean when a learning curve becomes flat? What should the engineer do next?

  10. Why is a mistake on an “other” item potentially more costly than its small probability suggests?

Numerical problems

Problem 1 · Festival week. During a festival the vessel mix changes to plate 0.25, tumbler 0.25, bowl 0.20, cooking vessel 0.25, other 0.05. Using the chapter’s cost matrix: (a) Compute the expected cost of each programme with no sensors. (b) What is the oracle cost? (c) What is the value of perfect information, and how does it compare with a normal week (0.90)?

Answer

(a) Quick rinse 4.80, standard 3.65, heavy degrease 4.00, gentle 5.85. Standard is still best, but only just ahead of heavy degrease. (b) Oracle: 0.25(2)+0.25(1)+0.20(2)+0.25(3)+0.05(2)=2.000.25(2) + 0.25(1) + 0.20(2) + 0.25(3) + 0.05(2) = 2.00. (c) 3.65−2.00=1.653.65 - 2.00 = 1.65 per vessel, almost double the normal 0.90. With more greasy cooking vessels, sensing is worth more.

Problem 2 · One sensor reading. With the normal prior, the grease sensor reports “greasy”. Its model is P(greasy∣x)=0.30,0.05,0.35,0.90,0.40P(\text{greasy} \mid x) = 0.30, 0.05, 0.35, 0.90, 0.40 for plate, tumbler, bowl, cooking vessel, other. (a) What is the probability that the grease sensor says “greasy” for a random vessel? (b) What is the posterior probability of cooking vessel? (c) Compute the expected cost of standard and heavy degrease under this posterior. Which does the robot choose?

Answer

(a) 0.40(0.30)+0.25(0.05)+0.20(0.35)+0.10(0.90)+0.05(0.40)=0.31250.40(0.30) + 0.25(0.05) + 0.20(0.35) + 0.10(0.90) + 0.05(0.40) = 0.3125. (b) 0.10×0.90/0.3125=0.2880.10 \times 0.90 / 0.3125 = 0.288. (c) The posterior is plate 0.384, tumbler 0.040, bowl 0.224, cooking 0.288, other 0.064. Standard: 2(0.384+0.040+0.224)+8(0.288)+5(0.064)≈3.922(0.384 + 0.040 + 0.224) + 8(0.288) + 5(0.064) \approx 3.92. Heavy degrease: 4(0.648)+3(0.288)+9(0.064)≈4.034(0.648) + 3(0.288) + 9(0.064) \approx 4.03. The robot still chooses standard, which is why the grease sensor alone never changes the decision.

Problem 3 · Smoothing. In a small training set, 5 of 12 bowls came out greasy and 0 of 3 “other” items came out greasy. (a) Give the plain counting estimates of P(greasy∣bowl)P(\text{greasy} \mid \text{bowl}) and P(greasy∣other)P(\text{greasy} \mid \text{other}). (b) Give the Laplace-smoothed estimates with α=1\alpha = 1. (c) Which estimate changed more, and why?

Answer

(a) Bowl 5/12≈0.4175/12 \approx 0.417; other 0/3=00/3 = 0. (b) Bowl (5+1)/(12+2)≈0.429(5+1)/(12+2) \approx 0.429; other (0+1)/(3+2)=0.20(0+1)/(3+2) = 0.20. (c) “Other” changed far more. With only 3 examples, the pseudo-counts are a large share of the data; with 12 examples they matter much less. Smoothing matters most exactly where data is scarce.

Problem 4 · Learning a weight model. Five labelled kadais weighed 850, 920, 1010, 780, and 940 g. Estimate the mean and standard deviation of the cooking-vessel weight model.

Answer

Mean =4500/5=900= 4500/5 = 900 g. Deviations: −50, 20, 110, −120, 40; squares sum to 31 000; s2=31000/4=7750s^2 = 31000/4 = 7750, so s≈88s \approx 88 g. (The chapter’s model used 250 g. Five kadais from one kitchen show far less variety than a whole city’s cooking vessels, a reminder that small samples can under-estimate spread.)

Problem 5 · Is a sensor worth buying? Section 3.2 found these average costs per vessel: no sensors 2.77, camera + scale 1.96, all three sensors 1.95. The family washes 60 vessels a day, and one cost unit is worth ₹0.50. (a) How much does camera + scale save per year compared with no sensors? (b) How much extra does the grease sensor save per year? (c) The grease sensor costs ₹2,000 and needs cleaning every week. Is it worth adding?

Answer

(a) (2.77−1.96)×60×365×0.50≈(2.77 - 1.96) \times 60 \times 365 \times 0.50 \approx ₹8,870 per year. (b) (1.96−1.95)×60×365×0.50≈(1.96 - 1.95) \times 60 \times 365 \times 0.50 \approx ₹110 per year. (c) No, not for this family. It would take about 18 years to pay back its price, before counting the weekly cleaning. For a restaurant with many greasy vessels the answer could be different.

Problem 6 · Rare but costly. “Other” items are 5% of the 60 vessels washed daily. In the confusion matrix of Section 3.3, about 9% of “other” items were predicted as cooking vessel, and so received heavy degrease. (a) How many “other” items does the robot wash in 30 days? (b) About how many of them receive heavy degrease by mistake? (c) Why might this number worry the family more than the robot’s 97% overall accuracy suggests?

Answer

(a) 60×30×0.05=9060 \times 30 \times 0.05 = 90 items. (b) 90×0.09≈890 \times 0.09 \approx 8 items a month. (c) Heavy degrease is the one programme that ruins non-stick coatings. A few such mistakes a month can destroy expensive tawas and pans, even though they barely dent the overall accuracy. Accuracy averages over all vessels; cost reveals which mistakes matter.

Mini-projects

  1. Your own kitchen’s cost matrix. Time how long each programme takes and estimate its water and electricity use. Look up the price of replacing a non-stick tawa. Build your own cost matrix in rupees and recompute the blind choice, the oracle cost, and the value of perfect information.

  2. The shiny-surface sensor. Add a fourth sensor, a reflectance reading that is high for glass and non-stick coatings, to the Section 3.2 simulation. Choose a sensible model for it, then measure how much it improves the cost and the “other” row of the confusion matrix.

  3. Moving to a restaurant. Create a restaurant vessel mix with large buckets and serving trays as new types. Collect a small labelled set, retrain with Laplace smoothing, and plot the learning curve. How many labelled examples does the installer need before switching the robot on?

Chapter 3 in one minute