import pandas as pd
# load dataset
df_food = pd.read_csv('food_nutrition.csv')
# show dataset
df_food
Name | Food Group | Calories | Fat (g) | Protein (g) | Carbohydrate (g) | Sugars (g) | Fiber (g) | Cholesterol (mg) | Saturated Fats (g) | Calcium (mg) | Iron, Fe (mg) | Magnesium (mg) | Vitamin C (mg) | Omega 3s (mg) | Sodium (mg) | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | Pillsbury Golden Layer Buttermilk Biscuits Art... | Baked Foods | 307.0 | 13.24 | 5.88 | 41.18 | 5.88 | 1.2 | 0.0 | 2.941 | NaN | 2.12 | NaN | NaN | NaN | 1059.0 |
1 | Pillsbury Cinnamon Rolls With Icing Refrigerat... | Baked Foods | 330.0 | 11.27 | 4.34 | 53.42 | 21.34 | 1.4 | 0.0 | 3.250 | 28.0 | 1.93 | NaN | 0.1 | NaN | 780.0 |
2 | Kraft Foods Shake N Bake Original Recipe Coati... | Baked Foods | 377.0 | 3.70 | 6.10 | 79.80 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 2182.0 |
3 | George Weston Bakeries Thomas English Muffins | Baked Foods | 232.0 | 1.80 | 8.00 | 46.00 | NaN | NaN | NaN | 0.308 | 180.0 | 1.40 | NaN | NaN | 79.0 | 345.0 |
4 | Waffles Buttermilk Frozen Ready-To-Heat | Baked Foods | 273.0 | 9.22 | 6.58 | 41.05 | 4.30 | 2.2 | 15.0 | 1.898 | 279.0 | 6.04 | 19.0 | 0.0 | 21.0 | 621.0 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
14159 | Cheese As Ingredient In Sandwiches | NaN | 359.0 | 28.73 | 20.65 | 4.57 | 2.40 | 0.0 | 90.0 | 16.492 | 959.0 | 0.47 | 29.0 | 0.0 | 29.0 | 1064.0 |
14160 | Breading Or Batter As Ingredient In Food | NaN | 201.0 | 1.39 | 6.32 | 39.64 | 0.68 | 1.6 | 19.0 | 0.336 | 47.0 | 2.57 | 14.0 | 0.0 | 3.0 | 246.0 |
14161 | Wheat Bread As Ingredient In Sandwiches | NaN | 263.0 | 3.96 | 11.45 | 45.29 | 5.18 | 5.4 | 0.0 | 0.716 | 161.0 | 3.12 | 56.0 | 0.1 | 2.0 | 464.0 |
14162 | Sauce As Ingredient In Hamburgers | NaN | 271.0 | 22.85 | 1.29 | 17.19 | 13.02 | 0.6 | 13.0 | 3.541 | 18.0 | 0.43 | 13.0 | 2.5 | 2.0 | 845.0 |
14163 | Industrial Oil As Ingredient In Food | NaN | 892.0 | 100.00 | 0.00 | 0.00 | 0.00 | 0.0 | 0.0 | 32.672 | 0.0 | 0.04 | 0.0 | 0.0 | 1698.0 | 0.0 |
14164 rows × 16 columns
# create a data dictionary which explains the meaning of each feature present
feature_dict = {'Name': 'Name of food',
'Food Group': 'Group of food (ex: fish, meats)',
'Calories': 'Amount of calories in serving size of 100g',
'Fat (g)': 'Amount of fat in grams in serving size of 100g',
'Protein (g)': 'Amount of protein in grams in serving size of 100g',
'Carbohydrate (g)': 'Amount of carbohydrate in grams in serving size of 100g',
'Sugars (g)': 'Amount of sugars in grams in serving size of 100g',
'Fiber (g)': 'Amount of fiber in grams in serving size of 100g',
'Cholesterol (mg)': 'Amount of cholesterol in milligrams in serving size of 100g',
'Saturated Fats (g)': 'Amount of saturated fats in grams in serving size of 100g',
'Calcium (mg)': 'Amount of calcium in milligrams in serving size of 100g',
'Iron, Fe (mg)': 'Amount of iron in milligrams in serving size of 100g',
'Magnesium (mg)': 'Amount of magnesium in milligrams in serving size of 100g',
'Vitamin C (mg)': 'Amount of vitamin C in milligrams in serving size of 100g',
'Omega 3s (mg)': 'Amount of omega 3s in milligrams in serving size of 100g',
'Sodium (mg)': 'Amount of sodium in milligrams in serving size of 100g'}
feature_dict
{'Name': 'Name of food', 'Food Group': 'Group of food (ex: fish, meats)', 'Calories': 'Amount of calories in serving size of 100g', 'Fat (g)': 'Amount of fat in grams in serving size of 100g', 'Protein (g)': 'Amount of protein in grams in serving size of 100g', 'Carbohydrate (g)': 'Amount of carbohydrate in grams in serving size of 100g', 'Sugars (g)': 'Amount of sugars in grams in serving size of 100g', 'Fiber (g)': 'Amount of fiber in grams in serving size of 100g', 'Cholesterol (mg)': 'Amount of cholesterol in milligrams in serving size of 100g', 'Saturated Fats (g)': 'Amount of saturated fats in grams in serving size of 100g', 'Calcium (mg)': 'Amount of calcium in milligrams in serving size of 100g', 'Iron, Fe (mg)': 'Amount of iron in milligrams in serving size of 100g', 'Magnesium (mg)': 'Amount of magnesium in milligrams in serving size of 100g', 'Vitamin C (mg)': 'Amount of vitamin C in milligrams in serving size of 100g', 'Omega 3s (mg)': 'Amount of omega 3s in milligrams in serving size of 100g', 'Sodium (mg)': 'Amount of sodium in milligrams in serving size of 100g'}
# see what food groups are in the dataset
df_food['Food Group'].unique()
array(['Baked Foods', 'Snacks', 'Sweets', 'Vegetables', 'American Indian', 'Restaurant Foods', 'Beverages', 'Fats and Oils', 'Meats', 'Dairy and Egg Products', 'Baby Foods', 'Breakfast Cereals', 'Soups and Sauces', 'Beans and Lentils', 'Fish', 'Fruits', nan, 'Grains and Pasta', 'Nuts and Seeds', 'Prepared Meals', 'Fast Foods', 'Spices and Herbs', 'Dairy and Egg Products '], dtype=object)
We'll use the machine learning method to train and learn the nutritional content of foods that are known as good foods to eat before or after a workout, and we will categorize the foods in a dataset into appropriate groups ('before work-out foods' and 'after work-out foods'). Doing so allows us to get the list of foods that are more suggested to eat before or after the workout.