Skip to content
0

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_food

💪 Competition challenge

Create a report that covers the following:

  1. Which fruit has the highest vitamin C content? What are some other sources of vitamin C?
  2. Describe the relationship between the calories and water content of a food item.
  3. What are the possible drawbacks of a zero-carb diet? What could be the drawbacks of a very high-protein diet?
  4. 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.
  5. 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

⌛️ Time is ticking. Good luck!

Data Preprocessing

#Load Data
df_food
#See data type of each column
df_food.info()
#See total null for every column
df_food.isnull().sum()

We found df_food data has some nulls which would not be great for analysis. Assumed that data with null value has value close to zero, so we could change the null value into '0.0'.

#fill all 'null' with 0.0
df_food_final = df_food.fillna('0.0')
df_food_final
#Check Whether there is null left
df_food_final.isnull().sum()
#Checking null and column type
df_food_final.info()