WOLFRAM

Say Cheese!

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
fruitFoodTypes =  EntityValue
&#10005


Next, get the image for each of these, and use DeleteMissing to remove any missing values from the list:

fruitImages = DeleteMissing
&#10005


Finally, use ImageCollage to create a vibrant collage of the fruit images:

Fruit image collage
&#10005


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":

pastaFoodTypes =  EntityValue
&#10005


pastaImages = DeleteMissing
&#10005


Pasta image collage
&#10005


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":

grains = EntityClass
&#10005


Next, retrieve the relative carbohydrate content and names for all the food types included in the "Grains" EntityClass:

grainNames =  DeleteMissing
&#10005


Finally, use WordCloud to create a colorful and informative graphic. The larger the word, the greater the number of relative carbs!

WordCloud
&#10005


Try these other relative comparisons to create vibrant and educational word clouds:

  • "fruits" and RelativeVitaminCContent
  • "dairy" and RelativeCalciumContent

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:

EntityValue
&#10005


EntityValue
&#10005


You can use CompassPlot to check out "Fig", "Lychee", "Banana", "Jackfruit", "Coconut", "Tamarind" and "Durian"—the fruit famous (or infamous) for its pungent smell:

EntityValue
&#10005


CompassPlot is perfect for exploring the nutritional makeup of your favorite pasta. For example, let’s take a look at "Orecchiette" pasta:

EntityValue
&#10005


DId you know that “orecchiette” translates to “little ear”? This picture shows why that is:

Orecchiette photo
&#10005


You can also use the Wolfram Language to analyze the protein and fat content of your favorite international meats and cheeses:

EntityValue
&#10005


EntityValue
&#10005


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:

EntityValue
&#10005


Even better, Wolfram|Alpha can give you an image of piki, the traditional bread of the Hopi made with blue cornmeal:

Piki photo
&#10005


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:

crackers =  EntityList
&#10005


crackersValues =  EntityValue
&#10005


Graphics3D
&#10005


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.

Comments

Join the discussion

!Please enter your comment (at least 5 characters).

!Please enter your name.

!Please enter a valid email address.

2 comments

  1. 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”!

    Reply
    • 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).

      Reply