Difference between revisions of "Recipe/Estimation"

From Open Food Facts wiki
Jump to navigation Jump to search
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
The idea behind recipe estimation is that is possible to determine the recipe of a product based on the ingredients and nutritional values. It is based on the assumption that the amount of nutrients do not change during product creation process.
+
The idea behind [[Recipe/Definition|recipe]] estimation is that is possible to determine the recipe of a product based on the ingredients and nutritional values. It is based on the assumption that the amount of nutrients do not change during product creation process.
  
 
== Exploration ==
 
== Exploration ==
 
To illustrate the recipe estimation idea several examples will be explored by looking at some products.
 
To illustrate the recipe estimation idea several examples will be explored by looking at some products.
 +
 
=== Apple syrup ===
 
=== Apple syrup ===
 
Apple syrup is a product where apples are cooked, the water evaporates and one is left with a very thick syrup. An example is [https://world.openfoodfacts.org/product/8713326190967/appelstroop-de-nieuwe-band this product]. This product contains 67% of nutrients. As the product weight is 450 gram there are some 300 gram of nutrients.
 
Apple syrup is a product where apples are cooked, the water evaporates and one is left with a very thick syrup. An example is [https://world.openfoodfacts.org/product/8713326190967/appelstroop-de-nieuwe-band this product]. This product contains 67% of nutrients. As the product weight is 450 gram there are some 300 gram of nutrients.
Line 71: Line 72:
 
The Ciqual nutrients for apricots are 13.3% sugar and 1.4% fibre. The fibre implies that we need 138 gram of Ciqual apricots to explain the fiber. This amount of apricots would explain 18.3 gram of sugar in the apricot jam. The rest of the sugar (23.7 gram) in the jam, must come from one of the added sugars (sucre de canne or pectine de fruits). As fruit pectine is not defined in Ciqual, nor is Cane sugar, so cane use either brown or white sugar as a replacement. As brown sugar has 95.5% sugar, we would need 24.8 gram of sugar to account for the sugar in this apricot jam.
 
The Ciqual nutrients for apricots are 13.3% sugar and 1.4% fibre. The fibre implies that we need 138 gram of Ciqual apricots to explain the fiber. This amount of apricots would explain 18.3 gram of sugar in the apricot jam. The rest of the sugar (23.7 gram) in the jam, must come from one of the added sugars (sucre de canne or pectine de fruits). As fruit pectine is not defined in Ciqual, nor is Cane sugar, so cane use either brown or white sugar as a replacement. As brown sugar has 95.5% sugar, we would need 24.8 gram of sugar to account for the sugar in this apricot jam.
  
== Observations ==
 
=== Total nutrients ===
 
The first example used the total of the nutrients to calculate the weight of ingredient in stead of a single nutrient. Should this always be done?
 
 
=== Ingredient stand-ins ===
 
The various examples in the exploration part show that the ingredients do not necessarily have the same nutrients that were actually used for the product. The ingredients are only stand-ins (proxies) for the calculation. Any recipe should be interpreted in terms of ingredients used and not those that found on the packaging.
 
 
The question is what ingredient data should be used as starting point (Ciqual, OFF, FDA, ...).
 
 
=== Key ingredients ===
 
Not all ingredients play a determining role in the nutrients. Thus ingredients like flavours, additives, etc do not have to be taken into account.
 
 
=== Assumption violation ===
 
The assumption that the nutrients of the ingredients should be the same as the nutrients in the processed product, is not always true. For these categories not all nutrients can be used in the calculation. This is  the case for:
 
* Fermented products where the sugars have been transformed into acids (yoghurts, cheeses, beers)
 
 
=== Nutrient uncertainty ===
 
We do not know the exact nutrients that went into a product. This might mean that different nutrients imply different quantities. So what to use?
 
  
 
== Formalisation ==
 
== Formalisation ==
Line 114: Line 97:
  
 
=== Estimating ===
 
=== Estimating ===
The formalisation shows that a recipe can be represented as a simple multiplication. This multiplication can also be expressed as a matrix calculation. Seeing that both the product values and the nutritional values will have an uncertainty, the calculated recipe '''r''' will be an estimated recipe '''ř'''
+
The formalisation shows that a recipe can be represented as a simple multiplication. This multiplication can also be expressed as a matrix calculation.  
  
=== Statistical approach ===
+
Seeing that both the product values and the nutritional values will have an uncertainty, the calculation will be an estimation recipe <big>'''ř'''</big> for the real recipe <big>'''r'''</big>. We want <big>'''ř'''</big> to be as close as possible to be to the product <big>'''r'''</big>. This can be done by finding the [https://en.wikipedia.org/wiki/Least_squares least square fit] to the difference between the components of <big>'''ř'''</big> and <big>'''r'''</big>.
 +
 
 +
=== Statistical theory ===
 +
Finding the best recipe is an example of [https://en.wikipedia.org/wiki/Linear_regression linear regression]. It is a very specific case that needs to be solved. This warrants a separate page where the [[Recipe/Statistical theory|statistical theory]] is discussed.
 +
 
 +
== Observations ==
 +
=== Total nutrients ===
 +
The first example used the total of the nutrients to calculate the weight of ingredient in stead of a single nutrient. Should this always be done?
 +
 
 +
=== Ingredient stand-ins ===
 +
The various examples in the exploration part show that the ingredients do not necessarily have the same nutrients that were actually used for the product. The ingredients are only stand-ins (proxies) for the calculation. Any recipe should be interpreted in terms of ingredients used and not those that found on the packaging.
 +
 
 +
The question is what ingredient data should be used as starting point (Ciqual, OFF, FDA, ...).
 +
 
 +
=== Key ingredients ===
 +
Not all ingredients play a determining role in the nutrients. Thus ingredients like flavours, additives, etc do not have to be taken into account.
 +
 
 +
=== Assumption violation ===
 +
The assumption that the nutrients of the ingredients should be the same as the nutrients in the processed product, is not always true. For these categories not all nutrients can be used in the calculation. This is  the case for:
 +
* Fermented products where the sugars have been transformed into acids (yoghurts, cheeses, beers)
 +
 
 +
=== Nutrient uncertainty ===
 +
We do not know the exact nutrients that went into a product. This might mean that different nutrients imply different quantities. So what to use?
  
 +
=== Constraints ===
 +
There are a few constraints which might be useful:
 +
* The sum of the nutrients must be less than the product weight (also valid for a single ingredient);
 +
* Nutrients are never negative;
  
 +
=== Water ===
 +
The Ciqual data also has a listing for water percentage. With this percentage we are able to calculate the total weight of ingredients that were used. This in turn allows us to calculate the [[Recipe/Evaporation|evaporation]] that occurs during the product creation.
 
[[Category:Recipe]]
 
[[Category:Recipe]]

Latest revision as of 10:43, 21 January 2025

The idea behind recipe estimation is that is possible to determine the recipe of a product based on the ingredients and nutritional values. It is based on the assumption that the amount of nutrients do not change during product creation process.

Exploration

To illustrate the recipe estimation idea several examples will be explored by looking at some products.

Apple syrup

Apple syrup is a product where apples are cooked, the water evaporates and one is left with a very thick syrup. An example is this product. This product contains 67% of nutrients. As the product weight is 450 gram there are some 300 gram of nutrients.

How many apples are required before one has 300 gram of nutrients? We have no idea what kind of apples have been used, so we need to make an assumption for the apple variety. The Ciqual database has an entry for Apple, pulp, raw, which contains 13.3% nutrients, or 13.3 gram per 100 gram of raw apple pulp. This implies that 22.6 times as much apples must have been used, i.e. 2260 gram of raw apple pulp, more than 2 kilogram of apple pulp.

If one looks at specific apple varieties in the Ciqual database the nutrient fraction varies from 12-16%, so not much spread.

The Apple syrup product states that 7 kg of apples were used to create 450 grams of syrup. This implies 1.6 kg of apples for 100 g of syrup. A bit less than our example, implying that a more sugary apple variety has been used for this syrup. Also because the package probably indicates the amount of raw unpeeled, unprepared apples.

Tomato puree

The Ciqual database has an entry for Tomato puree, canned, which as 14.4% nutrients. Tomato puree is a single ingredient product: only tomatoes have been used. The Ciqual entry for Tomato, raw has 5.9% nutrients.

Using 100 gram of tomato puree, we have 14.4 gram of nutrients, which implies that 244 gram of Ciqual tomatoes must have been used.

Instead of using the total nutrients we could also use a more specific nutrient, like sugar. Sugar is the dominant nutrient in the Ciqual tomatoes (2.48%) and determines the carbohydrates (2.49%). This is not the case with the Ciqual tomato puree, which has 7.54% carbohydrates and 3.64% sugars. Basing the calculation on the carbohydrates we would have used 300 gram of tomatoes, but based on the sugars 141 gram of tomatoes.

Clearly no Ciqual tomatoes were used in Ciqual tomato puree.

Natural potato crisps

Potato crisps only have three ingredients: potatoes, oil (used to baked the potatoes in) and salt (added for taste. As the potatoes hardly contain fat and salt, the oil does not contain carbohydrates or salt, the determination of the recipe is very straightforward.

The Ciqual category for Potato, crisps, plain or flavoured has 51.1% carbohydrates, 34.4% fat, and 1.65% salt. The Ciqual category for New potato, raw has 15.9% carbohydrates.

With this we can derive the recipe for 100 gram Natural potato crisps:

  1. Potatoes (new, raw): 321 gram
  2. Sunflower oil: 34.4 gram
  3. Salt:1.65 gram

Mozzarella

In this example the Mozzarella from cow's milk category will be explored. In Ciqual this is indicated by Mozzarella cheese, from cow's milk. The Ciqual nutrients for this product are:

Caption text
Nutrient Percentage Required
Fat 17.7 354
Saturated fat 11.7
Carbohydrates 0.75
Sugars 0.7 19
Fibre 0
Proteins 16.5 500
Salt 0.6
Water 62.7

The ingredients for Mozzarella are basically milk, an enzyme and salt. The amount of enzyme is (probably) very small and does not have to be taken into account for the nutrients. The salt only comes from the added salt, so all nutrients must be explained from the milk.

If we use the Ciqual Milk, whole, pasteurised category we will use milk with 3.3% fat and 3.3% proteins. No sugars are listed, but Lactose is (3.2%), which is a kind of sugar.

With this we can calculate the amount of milk needed to explain the nutrients in Mozzarella. This is presented in the last column of the table. The values for fat and proteins are roughly similar: 300 - 500 grams of milk are required to have 100 gram of Mozzarella.

But the value for sugars is way off. This is because the sugars that went in are fermented and are no longer in the end product.

Apricot jams

The examples so far are very simple ones, in the sense that a single ingredient is responsible for a single nutrient. Most products are much more complicated and multiple ingredients will contribute to multiple nutrients.

A simple example of such a product category is Apricot Jams. The most important ingredients are Apricots and Sugar. This means that not all sugar in an apricot jam comes from the apricots, but also from the added sugar.

These products often indicate the amount of fruit that has been used. In this product this is 65%. This product contains 42% sugars and 1.8% fibre.

The Ciqual nutrients for apricots are 13.3% sugar and 1.4% fibre. The fibre implies that we need 138 gram of Ciqual apricots to explain the fiber. This amount of apricots would explain 18.3 gram of sugar in the apricot jam. The rest of the sugar (23.7 gram) in the jam, must come from one of the added sugars (sucre de canne or pectine de fruits). As fruit pectine is not defined in Ciqual, nor is Cane sugar, so cane use either brown or white sugar as a replacement. As brown sugar has 95.5% sugar, we would need 24.8 gram of sugar to account for the sugar in this apricot jam.


Formalisation

The discussion in the exploration paragraph shows the principles of the recipe calculation. For single ingredient products we use the ratio of the nutrient_fractionproduct / nutrient_fractioningredient to get the weight of the ingredient. These needs to extended to all ingredients and all nutrients.

Formal representation

If we have a product with N ingredients and want to calculate one of the nutrients of the product from the ingredients, we get the formula:

(1) pi = weight_producti = Σj=0N-1 nutrient_fractionij weight_ingredientj

in this formula we have

  • weight_producti - the weight of nutrient i in the product p;
  • nutrient_fractionij - the fraction of nutrient i for ingredient j;
  • weight_ingredientj - the weight of ingredient j;

The weights can be expressed in gram per 100 gram, so that we do the calculation for 100 gram of the processed product. But it can also be calculated for the total weight of a specific product.

Formula (1) is useful if we want to calculate the nutrients from ingredients. However sometimes we need to calculate the ingredients from the processed product. Rewriting the formula:

(2) rj = weight_ingredientj = Σi=0M-1 nutrient_fractionij weight_producti

in this formula we have

  • weight_ingredientj - the weight (recipe component r) of ingredient j;
  • nutrient_fractionij - the fraction of nutrient i for ingredient j;
  • weight_producti - the weight of nutrient i in the product;

Estimating

The formalisation shows that a recipe can be represented as a simple multiplication. This multiplication can also be expressed as a matrix calculation.

Seeing that both the product values and the nutritional values will have an uncertainty, the calculation will be an estimation recipe ř for the real recipe r. We want ř to be as close as possible to be to the product r. This can be done by finding the least square fit to the difference between the components of ř and r.

Statistical theory

Finding the best recipe is an example of linear regression. It is a very specific case that needs to be solved. This warrants a separate page where the statistical theory is discussed.

Observations

Total nutrients

The first example used the total of the nutrients to calculate the weight of ingredient in stead of a single nutrient. Should this always be done?

Ingredient stand-ins

The various examples in the exploration part show that the ingredients do not necessarily have the same nutrients that were actually used for the product. The ingredients are only stand-ins (proxies) for the calculation. Any recipe should be interpreted in terms of ingredients used and not those that found on the packaging.

The question is what ingredient data should be used as starting point (Ciqual, OFF, FDA, ...).

Key ingredients

Not all ingredients play a determining role in the nutrients. Thus ingredients like flavours, additives, etc do not have to be taken into account.

Assumption violation

The assumption that the nutrients of the ingredients should be the same as the nutrients in the processed product, is not always true. For these categories not all nutrients can be used in the calculation. This is the case for:

  • Fermented products where the sugars have been transformed into acids (yoghurts, cheeses, beers)

Nutrient uncertainty

We do not know the exact nutrients that went into a product. This might mean that different nutrients imply different quantities. So what to use?

Constraints

There are a few constraints which might be useful:

  • The sum of the nutrients must be less than the product weight (also valid for a single ingredient);
  • Nutrients are never negative;

Water

The Ciqual data also has a listing for water percentage. With this percentage we are able to calculate the total weight of ingredients that were used. This in turn allows us to calculate the evaporation that occurs during the product creation.