Say Cheese!
We think about it, talk about it, dream about it and sometimes even argue about it.
What is it?
Food!
March is National Nutrition Month, and I want to share with you how we can celebrate it with the Wolfram Language. We’ll explore ways to analyze and visualize the incredible amount of food and nutrition data available to you in Wolfram|Alpha.
Go Bananas with Images
Did you know that Wolfram|Alpha has nutritional data on 150 types of fruit?
Using the ImageCollage function, you can quickly create a colorful snapshot of the many fruits in the Wolfram Knowledgebase.
First, find all instances of FoodType that are within the FoodTypeGroup "Fruits":
Engage with the code in this post by downloading the Wolfram Notebook
✕
|
Next, get the image for each of these, and use DeleteMissing to remove any missing values from the list:
✕
|
Finally, use ImageCollage to create a vibrant collage of the fruit images:
✕
|
To produce the same type of image collage for different types of pasta, just replace each use of "fruit" or "Fruits" from the earlier code with "pasta" or "Pastas":
✕
|
✕
|
✕
|
Try these other food groups to create a whole gallery of Wolfram|Alpha image collages to celebrate National Nutrition Month:
- "Berries"
- "Breads"
- "Cheeses"
- "Legumes"
A Cloud of Carbs
These days, many people have questions about the “carbs” in their food. The Wolfram Language makes answering those questions informative and fun. A word cloud is the perfect way to quickly illustrate the relative carbohydrate content in different grains.
First, find all instances of FoodType that are within the BasicFoodGroup "Grains":
✕
|
Next, retrieve the relative carbohydrate content and names for all the food types included in the "Grains" EntityClass:
✕
|
Finally, use WordCloud to create a colorful and informative graphic. The larger the word, the greater the number of relative carbs!
✕
|
Try these other relative comparisons to create vibrant and educational word clouds:
- "fruits" and RelativeVitaminCContent
- "dairy" and RelativeCalciumContent
Navigating a World of Flavors
Many of us enjoy trying new foods and flavors from around the world. Wolfram|Alpha has nutritional data about the foods that sometimes travel many miles before arriving on our plates.
CompassPlot is a quick and easy function in the Wolfram Language for learning about the macronutrient content of exotic and delicious foods like these fruits:
✕
|
✕
|
You can use CompassPlot to check out "Fig", "Lychee", "Banana", "Jackfruit", "Coconut", "Tamarind" and "Durian"—the fruit famous (or infamous) for its pungent smell:
✕
|
CompassPlot is perfect for exploring the nutritional makeup of your favorite pasta. For example, let’s take a look at "Orecchiette" pasta:
✕
|
DId you know that “orecchiette” translates to “little ear”? This picture shows why that is:
✕
|
You can also use the Wolfram Language to analyze the protein and fat content of your favorite international meats and cheeses:
✕
|
✕
|
See how these compare with "Ricotta", "Bratwurst" and "Prosciutto".
Before we leave CompassPlot, let’s explore Native American cuisine by using the Wolfram Language to visualize the macronutrient profile of blue cornmeal:
✕
|
Even better, Wolfram|Alpha can give you an image of piki, the traditional bread of the Hopi made with blue cornmeal:
✕
|
Nutritional and Multidimensional
Just as foods are multidimensional—sweet, sour, salty, bitter and/or spicy—so is food data in Wolfram|Alpha.
Use the following Wolfram Language code to create a 3D graphic of the relative carbohydrate, protein and fiber content of a wide variety of crackers. Then, in a Wolfram Notebook, hover over the data points to find your favorite ones in the plot:
✕
|
✕
|
✕
|
Eat Healthy and Be Happy
I hope you enjoy celebrating food and National Nutrition Month via the Wolfram Language as much as I do, and bon appétit!
Sign up for Wolfram|Alpha Pro to access customizable settings, step-by-step solutions, increased computation time and more. |
Brava!
Perhaps in a future post you could expand on the various nutritional recommendations (DRI vs. DV, for example, if looking at it through a US lens, or DRV if looking at it through a European lens, etc.) and how to computationally explore a food, meal, or diet in those terms. (Diet is somewhat like sleep, in that it is universally of primary importance, and yet, many are unfortunately unaware of the poor quality of their experiences, largely, I think, because it has never been meaningfully quantified for them!)
And, along those lines, include “typical cost” data for these foods (I’m sure much easier said than done!) and then exhibit the use of the optimization functionality within Wolfram Language to explore meal planning/diet development from a computational point of view, constrained by the various definitions of “sufficient nutrition” and budget.
And, finally, it would be very interesting to be able to likewise computationally explore more subjective dimensions of food, beyond the usual gross categories of, for example, sweet, sour, salty, bitter, & umami: This would naturally overlap with the computational representation of recipes and cooking (perhaps even including the various underlying chemical transformations that cookery applies to foodstuffs), etc., etc., etc.
I, for one, am very excited to see what comes of the future of all things “computational food”!
Thanks for the comment! I definitely agree there are so many exciting possibilities that could come out of “computational food”.
We already have support for quite a few properties that may be useful in some of the projects you described, e.g. we have DV percent properties for many nutrients. Every day I discover new things we can do with what we have, and I’m always trying to strike a balance between what is computationally interesting and what practical applications the average user would have for the data. I just know the Wolfram community is going to come up with something super cool I haven’t even considered!
The subjective aspects of food are fascinating and present their own host of challenges to computation. Taste is of course a great example, as well as the most basic definition of what a food actually is (I’ve seen deep rifts form over the “is a hot dog a sandwich?” debate).