Bayesian Modeling for the Perfect Pizza
Bayesian Modeling for the Perfect Pizza
Join the DZone community and get the full member experience.Join For Free
Learn how to operationalize machine learning and data science projects to monetize your AI initiatives. Download the Gartner report now.
How do you check that your pizza’s done? You look at it.
But what if you’re mass producing pizza? You could have somebody look at every pizza. But people get tired. So you need more people. But then you have to train everyone and you might lose some consistency in what is The Best Pizza ™.
In Multivariate Bayesian cognitive modeling for unsupervised quality control of baked pizzas, Neto, Aguiar, Santos and Wangenheim propose using computers specifically trained to look at a pizza and say “Yup, perfect! Done.”
They improved on earlier research that focused on pizza toppings, cooking cheese, and baking bread. According to the authors, earlier research relied mostly on reducing color dimensions, even using grayscale to analyze the browning of bread, and thus could not achieve desired accuracy.
More importantly, nobody before seems to have applied scientific rigor to the baseline – when do humans think pizza is tastiest?
To that end, the authors performed a pizza baking experiment with three mozzarella pizzas. Each was baked in an electric oven for 40 minutes at 200°C and a picture was taken every 4 minutes.
These pictures were then sent to 68 untrained volunteers from the Mechanical Engineering department – seriously, an engineer untrained in deciding when pizza looks tastiest? – who had to rate images on a Hedonic scale from 1 to 5.
A Hedonic scale is basically a scale used to answer “How much I like this." It’s used in food science, there are even calibrated devices to measure these things called olfactometers.
The data said the best baking time for a mozzarella pizza at 200°C is in the 8 to 16 minute range. Which sounds strangely familiar as something reading the box might have told them.
But it’s interesting to think this sort of rigorous approach can be taken to deciding whether a pizza looks good or not.
The pizza scale
After the initial experiment in determining when pizza looks the tastiest, the authors performed another baking experiment to analyze how color values in the RGB space change when pizza is baked at 250°C. From what I understand, higher temperature means shorter baking times and thus quicker experiments.
Another three mozzarella pizzas were destroyed in the name of science.
There are four color elements you can observe when baking pizza: the background – discarded because it doesn’t matter – olives, sauce, cheese, and crust.
It seems that during the baking process, olives remain black the whole time, and the color of sauce doesn’t change significantly either. But cheese and crust do.
RGB color space mapping
Samples in that magic time range – 8 to 16 minutes – were averaged across the three pizzas to produce a graph of RGB value variation for cheese and crust over the whole baking process. The pixels that represent cheese and crust were chosen manually and troublesome pixels for the cheese were removed.
The problem with cheese is that it generally browns slower than the crust, but can be very quick around the edges.
Browning evolution during baking
Their Bayesian model used Mahalanobis distance to compare pizzas from the validation stage to the training set from the human subjects. Mahalanobis distance is a statistical measure that performs better than Euclidean distance when you have distinct covariances in the target patterns.
As expected, their experiment confirmed that pizza baked at 250°C will be done faster than pizza baked at 200°C – 7 to 16 minutes is the magic range according to their Bayesian model. The beginning of the interval was very similar for all pizzas, but the ending varied greatly.
The authors speculate this variability might have been caused by variances in cheese distribution on the pizza, which wouldn’t exist in a mass production environment because robots can spread cheese very precisely.
They also noticed cheese can fall below threshold values during baking, which they speculate might be the result of released grease being shiny and thus messing up RGB values.
Mahalanobis Distance during baking
The real question now is who is going to use this research to install a camera in my oven and make it beep when pizza is done, not when some nebulous timer runs out?
The world needs this! Home ovens that know when food is done regardless of the timer you set. Imagine the endless possibilities!
You should follow me on twitter, here.
Published at DZone with permission of Swizec Teller , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.