<p><strong>Optimizing Nutrition on a Budget</strong></p><p>You are a data analyst working for nutrition counseling. Your client shared two datasets with you: One containing nutrition facts of various foods (kcal, protein, fat, carbs) per serving size; The other containing a list with food items and their local store prices (in $).</p><p>Your client is on a budget but still wants to improve their fitness goal. You were asked to create a budget friendly high protein meal. The meal should consist of four items:</p><ul><li><p><strong>one protein item</strong> (must be a high-protein (>25g proteins) and low-fat (<5g fats) source),</p></li><li><p><strong>one carbohydrate item</strong> (must be a low-carb source with <50g carbs), and</p></li><li><p><strong>two different vegetables</strong> (must be less than 100 kcal and ideally as much protein as possible).</p></li></ul><p>Clean and process the two datasets. Your client wants to know:</p><ol><li><p>What are the top 5 foods that offer the best value for money in terms of protein (i.e. with the highest protein per dollar ratio)?</p></li><li><p>Which 4 food items should they buy for their next meal to get a high protein on a tight budget?</p></li></ol><p><strong>Dataset:</strong> Nutrition facts and price list on KNIME Community Hub</p><p>---</p><p><strong>Solution:</strong></p><p>We start by reading both datasets using a <em>CSV Reader </em>each, and then cleaning the food prices dataset. We use a <em>Missing Value</em> node to filter out any food entries that have a missing price value. Then we clean the food names: First, an<em> Expression</em> node to remove underscores from the food names; Second, a <em>String Cleaner</em> node to remove leading or trailing whitespaces.This process is important as we will join the two datasets on the food item column but if the names are not the same they won’t match. Lastly, a <em>Column Renamer</em> node finalizes the data preparation by standardizing column names for consistency.</p><p>After cleaning the data, we merge the two datasets using a <em>Joiner</em> node. We perform an inner join based on the "Food Item" columns. </p><p>To calculate the protein-per-dollar ratio, we use an <em>Expression</em> node: We first calculate the protein per 100 grams by dividing each food item's protein content by its serving size; then we divide that value by the price per 100 grams. We then use a <em>Top k Row Filter</em> node to sort the results in descending order and generate a list of the top 5 food items that offer the best value for money in terms of protein.</p><p>We add another <em>Expression</em> node to calculate the cost per serving. Simply divide price per 100 grams by 100 to find price per gram and multiply that with the serving size. </p><p>Lastly, to put together our budget friendly meal, we use three <em>Expression Row Filter</em> nodes followed by a <em>Top k Row Filter</em> node each to do the following:</p><ul><li><p>The top branch finds the low fat, high protein items and picks the cheapest.</p></li><li><p>The middle branch finds the low carb items and picks the one with the lowest carbs.</p></li><li><p>The bottom branch finds all low calorie, high fiber items of type "Vegetables & Fungi" or "Fruits" and picks the two items with the highest protein content. </p></li></ul><p>Lastly, we use a <em>Concatenate</em> node to combine all these items in one table (basket), and calculate the basket’s total macros and price with a<em> GroupBy </em>node.</p><p></p>
Optimizing Nutrition on a Budget
You are a data analyst working for nutrition counseling. Your client shared two datasets with you: One containing nutrition facts of various foods (kcal, protein, fat, carbs) per serving size; The other containing a list with food items and their local store prices (in $).
Your client is on a budget but still wants to improve their fitness goal. You were asked to create a budget friendly high protein meal. The meal should consist of four items:
one protein item (must be a high-protein (>25g proteins) and low-fat (<5g fats) source),
one carbohydrate item (must be a low-carb source with <50g carbs), and
two different vegetables (must be less than 100 kcal and ideally as much protein as possible).
Clean and process the two datasets. Your client wants to know:
What are the top 5 foods that offer the best value for money in terms of protein (i.e. with the highest protein per dollar ratio)?
Which 4 food items should they buy for their next meal to get a high protein on a tight budget?
Dataset: Nutrition facts and price list on KNIME Community Hub
---
Solution:
We start by reading both datasets using a CSV Reader each, and then cleaning the food prices dataset. We use a Missing Value node to filter out any food entries that have a missing price value. Then we clean the food names: First, an Expression node to remove underscores from the food names; Second, a String Cleaner node to remove leading or trailing whitespaces.This process is important as we will join the two datasets on the food item column but if the names are not the same they won’t match. Lastly, a Column Renamer node finalizes the data preparation by standardizing column names for consistency.
After cleaning the data, we merge the two datasets using a Joiner node. We perform an inner join based on the "Food Item" columns.
To calculate the protein-per-dollar ratio, we use an Expression node: We first calculate the protein per 100 grams by dividing each food item's protein content by its serving size; then we divide that value by the price per 100 grams. We then use a Top k Row Filter node to sort the results in descending order and generate a list of the top 5 food items that offer the best value for money in terms of protein.
We add another Expression node to calculate the cost per serving. Simply divide price per 100 grams by 100 to find price per gram and multiply that with the serving size.
Lastly, to put together our budget friendly meal, we use three Expression Row Filter nodes followed by a Top k Row Filter node each to do the following:
The top branch finds the low fat, high protein items and picks the cheapest.
The middle branch finds the low carb items and picks the one with the lowest carbs.
The bottom branch finds all low calorie, high fiber items of type "Vegetables & Fungi" or "Fruits" and picks the two items with the highest protein content.
Lastly, we use a Concatenate node to combine all these items in one table (basket), and calculate the basket’s total macros and price with a GroupBy node.