What is good food?
📖 Background
You and your friend have gotten into a debate about nutrition. Your friend follows a high-protein diet and does not eat any carbohydrates (no grains, no fruits). You claim that a balanced diet should contain all nutrients but should be low in calories. Both of you quickly realize that most of what you know about nutrition comes from mainstream and social media.
Being the data scientist that you are, you offer to look at the data yourself to answer a few key questions.
💾 The data
You source nutrition data from USDA's FoodData Central website. This data contains the calorie content of 7,793 common foods, as well as their nutritional composition. Each row represents one food item, and nutritional values are based on a 100g serving. Here is a description of the columns:
- FDC_ID: A unique identifier for each food item in the database.
- Item: The name or description of the food product.
- Category: The category or classification of the food item, such as "Baked Products" or "Vegetables and Vegetable Products".
- Calories: The energy content of the food, presented in kilocalories (kcal).
- Protein: The protein content of the food, measured in grams.
- Carbohydrate: The carbohydrate content of the food, measured in grams.
- Total fat: The total fat content of the food, measured in grams.
- Cholesterol: The cholesterol content of the food, measured in milligrams.
- Fiber: The dietary fiber content of the food, measured in grams.
- Water: The water content of the food, measured in grams.
- Alcohol: The alcohol content of the food (if any), measured in grams.
- Vitamin C: The Vitamin C content of the food, measured in milligrams.
import pandas as pd
df_food = pd.read_csv('nutrition.csv')
df_foodThe fruit with the highest Vitamin C content in the dataset is Acerola (West Indian Cherry), raw, containing 1677.6 mg of Vitamin C per serving.
Other Sources of Vitamin C Apart from Acerola, other common sources of Vitamin C include:
Citrus fruits like oranges, grapefruits, and lemons Berries such as strawberries, raspberries, and blueberries Kiwifruit Green and red peppers Tomatoes Green leafy vegetables like spinach and kale Broccoli Brussels sprouts 2. Analyzing the Relationship Between Calories and Water Content To understand the relationship between the calorie content and water content of food items, I will create a scatter plot and calculate a correlation coefficient. This will help us see if there's a noticeable trend or pattern in the data. Let's proceed with this analysis
The scatter plot illustrates the relationship between the calories and water content of food items. There is a strong negative correlation of approximately -0.90. This indicates that as the water content in food increases, its calorie content tends to decrease, and vice versa.
- Drawbacks of Specific Diets Drawbacks of a Zero-Carb Diet: Nutritional Deficiencies: Carbohydrates are a source of essential nutrients. Eliminating them can lead to deficiencies in fiber, vitamins, and minerals. Decreased Energy and Mood Changes: Carbs are the body's primary energy source. Without them, individuals might experience fatigue, weakness, and mood swings. Digestive Issues: Lack of dietary fiber from carbs can cause constipation or other digestive issues. Unsustainable in the Long Term: Such diets are often difficult to maintain, leading to potential weight regain. Ketosis Side Effects: Zero-carb diets can lead to a state called ketosis, which might cause bad breath, headache, dizziness, and irritability. Drawbacks of a Very High-Protein Diet: Kidney Damage in Susceptible Individuals: High protein intake can exacerbate existing kidney problems. Nutrient Imbalance: Overemphasis on protein can displace other essential nutrients, leading to imbalances. Digestive Issues: High protein consumption might lead to digestive discomfort, constipation, or diarrhea. Heart Health Risks: Some high-protein diets are high in saturated fats, which may increase the risk of heart disease. Bone Health Concerns: Long-term, very high protein intake is sometimes linked to poorer bone health.
- Linear Model Analysis Next, I'll create a linear model to test if the energy content from fat, protein, and carbohydrates aligns with the Cleveland Clinic's estimates (9 kcal/g for fat, 4 kcal/g for protein, and 4 kcal/g for carbohydrates). This requires extracting and converting these nutritional values to numeric for the analysis. Let's begin this step.
The linear model fitted to the nutritional data provides the following insights:
The coefficient for fat is approximately 8.80 kcal/g. The coefficient for protein is about 4.00 kcal/g. The coefficient for carbohydrates is around 3.80 kcal/g. These coefficients are close to the Cleveland Clinic's estimates (9 kcal/g for fat, 4 kcal/g for each of protein and carbohydrates), with a slight deviation for fat and carbohydrates. The intercept of the model is approximately 4.08 kcal, which might suggest a baseline caloric content independent of these three macronutrients.
The Mean Squared Error (MSE) of the model is 291.75 kcal². This value indicates the average squared difference between the estimated caloric values from the model and the actual caloric values in the dataset. A lower MSE would have indicated a better fit.
- Error Analysis of the Linear Model The error in the linear model could be attributed to several factors:
Variation in Food Composition: The actual caloric content of foods can vary based on factors like preparation methods, ripeness, and specific varieties, which are not captured in a simple linear model. Other Macronutrients: There are other components in food, like alcohol or certain types of fiber, that also contribute to caloric content but are not included in the model. Rounding and Measurement Errors: Nutritional data can have rounding or measurement errors, leading to inaccuracies. Metabolic Differences: The way different bodies metabolize food can affect the actual caloric value extracted from food, which isn't accounted for in a generic model.
💪 Competition challenge
Create a report that covers the following:
- Which fruit has the highest vitamin C content? What are some other sources of vitamin C?
- Describe the relationship between the calories and water content of a food item.
- What are the possible drawbacks of a zero-carb diet? What could be the drawbacks of a very high-protein diet?
- According to the Cleveland Clinic website, a gram of fat has around 9 kilocalories, and a gram of protein and a gram of carbohydrate contain 4 kilocalories each. Fit a linear model to test whether these estimates agree with the data.
- Analyze the errors of your linear model to see what could be the hidden sources of calories in food.
🧑⚖️ Judging criteria
This competition is for helping to understand how competitions work. This competition will not be judged.
✅ Checklist before publishing into the competition
- Rename your workspace to make it descriptive of your work. N.B. you should leave the notebook name as notebook.ipynb.
- Remove redundant cells like the judging criteria, so the workbook is focused on your story.
- Make sure the workbook reads well and explains how you found your insights.
- Try to include an executive summary of your recommendations at the beginning.
- Check that all the cells run without error