Message Boards Message Boards

Cooking recipes with GPT-3, Dall-e and the Wolfram Language

5 Replies

@Isabel Skidmore I'm trying to figure out what is the best way to obtain the calories of this type of ingredients. Depending on the method I'm getting two different results:

Thanks in advance. Also feel free to give some feedback on best practices while working with food entities :)

enter image description here -- you have earned Featured Contributor Badge enter image description here Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

POSTED BY: Moderation Team

Love it! Thanks so much for your work on this. I downloaded the notebook to spend some more time with it.

POSTED BY: Gay Wilson

Hi @Jofre Espigule-Pons! This is such a cool post, well done!

The way that I would probably approach calculating calories per item for most foods is by using an EntityInstance of the food and using the property "AbsoluteTotalCaloriesContent". Sometimes this can give you Missing since we don't always have every pairing hooked up of quantity and nutrition that is out there. "Items" is usually a good bet, and using "Grams" is even better if you can figure out the mass of any ingredient used. Many baking recipes will include it in the ingredient text like "1 cup (120g) flour", or you can use "AbsoluteMass" to find it like this:

 EntityInstance[Entity[
  "Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{
Entity["FoodType", "Flour"]}], 
    EntityProperty["Food", "AddedFoodTypes"] -> ContainsExactly[{}]}],
   Quantity[1, "Cups"]]["AbsoluteMass"]

Because of the way Food works, you will usually be getting an average for entities when using the type of EntityProperty["Food", ...] -> ... constructs like above. This can lead to some inconsistencies, since various properties are generated from more or less complete sets of data. Properties that only rely on item mass will use every item mass data point, whereas properties that rely on both item mass and calories will only use data points that have both an item mass and a calorie value, so you will often be getting a value averaged from a smaller set of data points.

Below I have an example of how I would go about deconstructing these averaged values a bit, which may show you why you are getting things somewhat inconsistently or different from how you would expect.

Let me know if you have more questions or you think of anything thing else you'd like me to show you. I think you are using Food data extremely well and I'm sure I could learn some best practices from you :-)

POSTED BY: Isabel Skidmore

Hi Isabel! Thank you for your kind words and for sharing your approach to calculating calories per item. Your expertise is truly valuable. :-)

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract