KRWG.ORG-The Region's Home Page
Mon November 19, 2012
Could Nate Silver Predict How Good Your Pumpkin Pie Will Be?
Originally published on Mon November 26, 2012 11:55 am
We've been hearing a lot recently about how algorithms can predict just about anything. They find long-lost friends on Facebook and guess which books we'll buy next on Amazon. Algorithms hit the big time this month, when New York Times blogger Nate Silver used mathematical models and statistics to correctly forecast the outcome of every state in the presidential election.
So what about food? Could these same math whizzes help us bake a better pumpkin pie or mix up a tastier batch of sweet potatoes this Thanksgiving? Lada Adamic, a computer scientist at the University of Michigan and Facebook, thinks it just might be possible.
Like Silver, Adamic loves big data sets and statistics. And at Facebook, she uses them to predict how memes spread on social networks and viral marketing influences decisions.
But Adamic is also an aspiring cook. So she and her team have come up with an algorithm to guess how successful a recipe will turn out. And the math works surprisingly well. It predicts with nearly 80 percent accuracy how many stars your mother's cranberry recipe will receive on allrecipes.com. Plus, it can recommend ingredient replacements to make your pie crust and potatoes more healthful.
She and her team took nearly 50,000 recipes and 2 million reviews from allrecipes.com and then hacked up an algorithm to extract out all the ingredients, cooking methods and nutritional profiles. With just these items, her algorithm could predict the recipe's rating with an accuracy of about 70 percent.
But the magic happened when Adamic built a "social network" for the ingredients. She looked at how often two ingredients appear in the same recipes. Those that frequently show up together — milk and butter, nutmeg and cinnamon, basil and rosemary — sit close to each other in the network, but those that rarely appear in the same dish, such as coconut and parsley, are far from each other.
Physicists at Harvard University performed a similar network analysis on ingredients' flavors, but Adamic took it a step further and integrated the data into a recipe prediction program.
Adamic's network analysis boosted the accuracy of her recipe recommendations by about 10 percent. But it also revealed a treasure-trove of information about the way Americans mix and match ingredients, which ones we like to leave out or throw in extra.
"The networks tell us about the flexibility of recipes, which ingredients are frequently swapped or modified," Adamic tells The Salt.
Spices and herbs are superflexible. We tend to add more than a recipe requests. Same goes for flavor enhancers, like soy sauce, lemon juice and Worcestershire sauce, as well as savory toppings, like mushrooms, bacon and cheese. On the flip side, we often cut back on fats, sugars and salt in dishes.
What about ingredient substitutions? Adamic created a network for that, too.
Her algorithm analyzed reviewers' recommendations for customizing recipes, such as "I replaced the butter in the frosting by sour cream, just to soothe my conscience about all the fatty calories" and "This is a great recipe, but using fresh tomatoes only adds a few minutes to the prep time." Then the mathematics stitched together little clusters or communities of interchangeable foods and spices.
The result is a list of recipe replacements more comprehensive and scientifically accurate than anything you'll find in the Joy of Cooking or online.
"One of the top things was substituting applesauce for vegetable oil," Adamic says. "We thought that this was ridiculous, but then we learned it was a basic health food trick."
Well-seasoned cooks have these substitution tricks at their fingertips, but for others, like Adamic, it's more challenging to experiment with recipes or customize them for flavor and nutritional profiles.
"I was having trouble moving beyond literally reading the recipe and then following it exactly," Adamic says. Then she remembered what she does best — write algorithms to analyze large amounts of information.
"In general, I just believe in data," she says. "There's all these recipes out there. So maybe we can just look at the data and automatically figure out how flexible the recipes are. Now I feel more comfortable using spices more freely."
Adamic hasn't had time to put her predictions and ingredient replacements into handy tables or charts on a website. But you can read more about how she built them on the arXiv.org.
So can these algorithms tell us what we should pick up at the grocery store this week to increase our chances of making the best turkey stuffing or pumpkin pie?
"I won't promise that," she says. "But if you give me two recipes with similar ingredients, I can tell you which one will be better."