Health, Nutrition and Fitness with the Wolfram Language

by Keiko Hirayama and Jason Martinez

Introduction

The Wolfram Language contains an ever increasing assortment of data, tools, and guides for managing health, exercise and nutrition to improve and maintain diet and physical fitness.

Activities and Exercise in Data

Exercise Entities:

YogaPose and PilatesExercise were introduced in Mathematica version 12

Wolfram Knowledgebase was recently expanded to support analysis on various additional exercises

Updated PhysicalActivity dataset encompasses diverse sport/daily activities

New WeightTrainingExercise data collection includes detailed anatomical information

PhysicalActivity

PhysicalActivity dataset includes: ~900 entities and 12 properties

Source:

Compendium of Physical Activities: 
Ainsworth BE et al., Compendium of Physical Activities: a second update of codes and MET values. Medicine and Science in Sports and Exercise, 2011;43(8):1575-1581.

Type of Physical Activities:

entClass=ReverseSortBy[#->EntityList[#]&/@Drop[EntityClassList["PhysicalActivity"],-1],Length[#[[2]]]&];

dataset=Dataset[Association@@(entClass/.Rule[a_,b_]:>Rule[a,Length[b]])]

PieChart[Normal@dataset,ChartLabels->Callout[Automatic],ChartStyle->"Pastel",PlotRange->Full]

Sample Entities:

PhysicalActivity

Available properties:

EntityValue[(Entity["playing table tennis", Entity["PhysicalActivity","TableTennis"], "Entity[\"PhysicalActivity\", \"TableTennis\"]", "physical exercise"]),"Properties"]

%//Length

Metabolic Equivalent (MET)

The ratio of the work metabolic rate to the resting metabolic rate

One MET is defined as 1 Cal/kg/hour and is roughly equivalent to the energy cost of sitting quietly

EntityValue[EntityValue["PhysicalActivity","RandomEntities"],(EntityProperty["metabolic equivalent", EntityProperty["PhysicalActivity","MetabolicEquivalent"], "EntityProperty[\"PhysicalActivity\", \"MetabolicEquivalent\"]"]),"Dataset"]

Compare MET values across different activities

Row[{ListPlot[EntityValue["PhysicalActivity",(EntityProperty["metabolic equivalent", EntityProperty["PhysicalActivity","MetabolicEquivalent"], "EntityProperty[\"PhysicalActivity\", \"MetabolicEquivalent\"]"]),"Dataset"][SortBy[#&]],],Histogram[EntityValue["PhysicalActivity",(EntityProperty["metabolic equivalent", EntityProperty["PhysicalActivity","MetabolicEquivalent"], "EntityProperty[\"PhysicalActivity\", \"MetabolicEquivalent\"]"]),"Dataset"],]}]

PhysicalActivity

Personal Daily Activity Tracking

activityDataset=Dataset[{<|"Activity"->(Entity["sleeping", Entity["PhysicalActivity","Sleeping"], "Entity[\"PhysicalActivity\", \"Sleeping\"]", "physical activity"]),"Duration"->(Quantity[6, "h", hours, "Hours"])|>,<|"Activity"->(Entity["making beds", Entity["PhysicalActivity","MakingBed"], "Entity[\"PhysicalActivity\", \"MakingBed\"]", "physical activity"]),"Duration"->(Quantity[1, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["cooking with light effort", Entity["PhysicalActivity","CookingOrFoodPreparationStandingOrSittingOrInGeneralManualAppliance"], "Entity[\"PhysicalActivity\", \"CookingOrFoodPreparationStandingOrSittingOrInGeneralManualAppliance\"]", "physical activity"]),"Duration"->(Quantity[5, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["serving food", Entity["PhysicalActivity","ServingFoodSettingTableImpliedWalkingOrStanding"], "Entity[\"PhysicalActivity\", \"ServingFoodSettingTableImpliedWalkingOrStanding\"]", "physical activity"]),"Duration"->(Quantity[5, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["eating while sitting", Entity["PhysicalActivity","EatingSitting"], "Entity[\"PhysicalActivity\", \"EatingSitting\"]", "physical activity"]),"Duration"->(Quantity[30, "min", minutes, "Minutes"])|>,<|"Activity"->LinguisticAssistant,"Duration"->(Quantity[5, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["doing desk work", Entity["PhysicalActivity","SittingWritingDeskWorkTyping"], "Entity[\"PhysicalActivity\", \"SittingWritingDeskWorkTyping\"]", "physical activity"]),"Duration"->(Quantity[4, "h", hours, "Hours"])|>,<|"Activity"->(Entity["walking for pleasure on a work break", Entity["PhysicalActivity","WalkingForPleasureWorkBreak"], "Entity[\"PhysicalActivity\", \"WalkingForPleasureWorkBreak\"]", "physical activity"]),"Duration"->(Quantity[30, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["meeting while sitting", Entity["PhysicalActivity","SittingMeetingGeneralAndOrWithTalkingInvolved"], "Entity[\"PhysicalActivity\", \"SittingMeetingGeneralAndOrWithTalkingInvolved\"]", "physical activity"]),"Duration"->(Quantity[30, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["doing desk work", Entity["PhysicalActivity","SittingWritingDeskWorkTyping"], "Entity[\"PhysicalActivity\", \"SittingWritingDeskWorkTyping\"]", "physical activity"]),"Duration"->(Quantity[3.5, "h", hours, "Hours"])|>,<|"Activity"->(Entity["driving cars", Entity["PhysicalActivity","AutomobileDriving"], "Entity[\"PhysicalActivity\", \"AutomobileDriving\"]", "physical activity"]),"Duration"->(Quantity[10, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["watering plants", Entity["PhysicalActivity","WateringPlants"], "Entity[\"PhysicalActivity\", \"WateringPlants\"]", "physical activity"]),"Duration"->(Quantity[10, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["mowing the lawn", Entity["PhysicalActivity","MowingLawnGeneral"], "Entity[\"PhysicalActivity\", \"MowingLawnGeneral\"]", "physical activity"]),"Duration"->(Quantity[30, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity[neighborhood walking, Entity["PhysicalActivity","WalkingToNeighborsHouseOrFamilysHouseForSocialReasons"], "Entity[\"PhysicalActivity\", \"WalkingToNeighborsHouseOrFamilysHouseForSocialReasons\"]", "physical activity"]),"Duration"->(Quantity[30, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["light calisthenics", Entity["PhysicalActivity","CalisthenicsLightEffort"], "Entity[\"PhysicalActivity\", \"CalisthenicsLightEffort\"]", "physical activity"]),"Duration"->(Quantity[40, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["cooking with moderate effort", Entity["PhysicalActivity","CookingOrFoodPreparationModerateEffort"], "Entity[\"PhysicalActivity\", \"CookingOrFoodPreparationModerateEffort\"]", "physical activity"]),"Duration"->(Quantity[30, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["eating while sitting", Entity["PhysicalActivity","EatingSitting"], "Entity[\"PhysicalActivity\", \"EatingSitting\"]", "physical activity"]),"Duration"->(Quantity[30, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["clearing dishes from table", Entity["PhysicalActivity","WashDishesClearingDishesFromTableWalking"], "Entity[\"PhysicalActivity\", \"WashDishesClearingDishesFromTableWalking\"]", "physical activity"]),"Duration"->(Quantity[30, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["grocery shopping", Entity["PhysicalActivity","FoodShoppingWithOrWithoutAGroceryCartStandingOrWalking"], "Entity[\"PhysicalActivity\", \"FoodShoppingWithOrWithoutAGroceryCartStandingOrWalking\"]", "physical activity"]),"Duration"->(Quantity[50, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["putting away groceries", Entity["PhysicalActivity","PuttingAwayGroceries"], "Entity[\"PhysicalActivity\", \"PuttingAwayGroceries\"]", "physical activity"]),"Duration"->(Quantity[10, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["carrying laundry", Entity["PhysicalActivity","LaundryPuttingAwayClothesGatheringClothesToPack"], "Entity[\"PhysicalActivity\", \"LaundryPuttingAwayClothesGatheringClothesToPack\"]", "physical activity"]),"Duration"->(Quantity[5, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["vacuuming", Entity["PhysicalActivity","Vacuuming"], "Entity[\"PhysicalActivity\", \"Vacuuming\"]", "physical activity"]),"Duration"->(Quantity[60, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["organizing a room", Entity["PhysicalActivity","OrganizingRoom"], "Entity[\"PhysicalActivity\", \"OrganizingRoom\"]", "physical activity"]),"Duration"->(Quantity[4, "min", minutes, "Minutes"])|>,<|"Activity"->LinguisticAssistant,"Duration"->(Quantity[60, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["bathing while sitting", Entity["PhysicalActivity","BathingSitting"], "Entity[\"PhysicalActivity\", \"BathingSitting\"]", "physical activity"]),"Duration"->(Quantity[5, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["talking or texting while sitting", Entity["PhysicalActivity","SittingTalkingInPersonOnThePhoneComputerOrTextMessagingLightEffort"], "Entity[\"PhysicalActivity\", \"SittingTalkingInPersonOnThePhoneComputerOrTextMessagingLightEffort\"]", "physical activity"]),"Duration"->(Quantity[60, "min", minutes, "Minutes"])|>,<|"Activity"->(Entity["reading while reclining", Entity["PhysicalActivity","RecliningReading"], "Entity[\"PhysicalActivity\", \"RecliningReading\"]", "physical activity"]),"Duration"->(Quantity[60, "min", minutes, "Minutes"])|>}]

Record for 24 hours

activityDataset[All,#Duration&][UnitConvert[Total[#],"Hours"]&]

Daily activity pattern

DateListStepPlot[MapThread[List,{(DateObject["Minute: ""Wed 14 Oct 2020 00:00""GMT"-5.`, DateObject[{2020,10,14,0,0},"Minute","Gregorian",-5.`]])+#&/@Prepend[Drop[Accumulate[Normal@activityDataset[All,#Duration&]],-1],(Quantity[0, "min", minutes, "Minutes"])],Normal@activityDataset[All,#Activity["MetabolicEquivalent"]&]}]->Normal@activityDataset[All,#Activity&],PlotTheme->"Business",ImageSize->800]

Total caloric expenditure (Jason’s formula support)

bodyWeight=(Quantity[160, "lb", pounds, "Pounds"]);

activityDataset[All,Quantity[QuantityMagnitude[#Activity["MetabolicEquivalent"]UnitConvert[#Duration,"Hours"]UnitConvert[bodyWeight,"Kilograms"]],"Calories"]&][Total]

WeightTrainingExercise

WeightTrainingExercise data includes: ~90 entities and 23 properties

Type of Weight Training Exercises:

Dataset[<|#->RandomSample[EntityList[#],UpTo[15]]|>&/@{(EntityClass["free weight exercises", EntityClass["WeightTrainingExercise","FreeWeightExercises"], "EntityClass[\"WeightTrainingExercise\", \"FreeWeightExercises\"]", "weight training exercises"]),(EntityClass["body weight exercises", EntityClass["WeightTrainingExercise","BodyWeightExercises"], "EntityClass[\"WeightTrainingExercise\", \"BodyWeightExercises\"]", "weight training exercises"])}]

Available properties:

EntityValue[(Entity["bench press", Entity["WeightTrainingExercise","BenchPress"], "Entity[\"WeightTrainingExercise\", \"BenchPress\"]", "weight training exercise"]),"Properties"]

%//Length

MET

EntityValue[{(Entity["side plank", Entity["WeightTrainingExercise","SidePlank"], "Entity[\"WeightTrainingExercise\", \"SidePlank\"]", "weight training exercise"]),(Entity["high knee", Entity["WeightTrainingExercise","HighKnee"], "Entity[\"WeightTrainingExercise\", \"HighKnee\"]", "weight training exercise"]),(Entity["plank leg raise", Entity["WeightTrainingExercise","PlankLegRaise"], "Entity[\"WeightTrainingExercise\", \"PlankLegRaise\"]", "weight training exercise"]),(Entity["bicycle crunch", Entity["WeightTrainingExercise","BicycleCrunch"], "Entity[\"WeightTrainingExercise\", \"BicycleCrunch\"]", "weight training exercise"]),(Entity["reverse crunch", Entity["WeightTrainingExercise","ReverseCrunch"], "Entity[\"WeightTrainingExercise\", \"ReverseCrunch\"]", "weight training exercise"]),(Entity["inchworm", Entity["WeightTrainingExercise","Inchworm"], "Entity[\"WeightTrainingExercise\", \"Inchworm\"]", "weight training exercise"]),(Entity["frog hop", Entity["WeightTrainingExercise","FrogHop"], "Entity[\"WeightTrainingExercise\", \"FrogHop\"]", "weight training exercise"]),(Entity["donkey kick", Entity["WeightTrainingExercise","DonkeyKick"], "Entity[\"WeightTrainingExercise\", \"DonkeyKick\"]", "weight training exercise"]),(Entity["spiderman plank", Entity["WeightTrainingExercise","SpidermanPlank"], "Entity[\"WeightTrainingExercise\", \"SpidermanPlank\"]", "weight training exercise"]),(Entity["mountain climber", Entity["WeightTrainingExercise","MountainClimber"], "Entity[\"WeightTrainingExercise\", \"MountainClimber\"]", "weight training exercise"])},(EntityProperty["metabolic equivalent", EntityProperty["WeightTrainingExercise","MetabolicEquivalent"], "EntityProperty[\"WeightTrainingExercise\", \"MetabolicEquivalent\"]"]),"Dataset"][SortBy[#&]]

Calories per repetition

Dataset[EntityValue["WeightTrainingExercise",(EntityProperty["calories per repetition", EntityProperty["WeightTrainingExercise","CaloriesPerRepetition"], "EntityProperty[\"WeightTrainingExercise\", \"CaloriesPerRepetition\"]"]),"NonMissingEntityAssociation"]][SortBy[#&]]

Schematics: Illustrating start/end positions (created by Isabel Skidmore)

ImageCollage[DeleteMissing[EntityValue["WeightTrainingExercise",(EntityProperty["simplified schematic end position", EntityProperty["WeightTrainingExercise","SimplifiedSchematicEnd"], "EntityProperty[\"WeightTrainingExercise\", \"SimplifiedSchematicEnd\"]"])]],Background->White]

Text: Instructions, precautions, variations

EntityValue[(Entity["deadlift", Entity["WeightTrainingExercise","Deadlift"], "Entity[\"WeightTrainingExercise\", \"Deadlift\"]", "weight training exercise"]),{(EntityProperty["instructions", EntityProperty["WeightTrainingExercise","Instructions"], "EntityProperty[\"WeightTrainingExercise\", \"Instructions\"]"]),(EntityProperty["precautions", EntityProperty["WeightTrainingExercise","Precautions"], "EntityProperty[\"WeightTrainingExercise\", \"Precautions\"]"]),(EntityProperty["variations", EntityProperty["WeightTrainingExercise","Variations"], "EntityProperty[\"WeightTrainingExercise\", \"Variations\"]"])},"Dataset"]

WeightTrainingExercise

Available properties:

Anatomical information: Muscle groups and images, Sites of improved strength

EntityValue[(Entity["squat", Entity["WeightTrainingExercise","Squat"], "Entity[\"WeightTrainingExercise\", \"Squat\"]", "weight training exercise"]),{(EntityProperty["primary muscles", EntityProperty["WeightTrainingExercise","PrimaryMuscles"], "EntityProperty[\"WeightTrainingExercise\", \"PrimaryMuscles\"]"]),(EntityProperty["supporting muscles", EntityProperty["WeightTrainingExercise","SupportingMuscles"], "EntityProperty[\"WeightTrainingExercise\", \"SupportingMuscles\"]"])},"PropertyAssociation"]

GraphicsGrid[Partition[(Entity["squat", Entity["WeightTrainingExercise","Squat"], "Entity[\"WeightTrainingExercise\", \"Squat\"]", "weight training exercise"])[{,,,,,}],3],Frame->All,FrameStyle->Directive[Thick,LightGray]]

AnatomyPlot3D[{(Entity["quadriceps femoris", Entity["AnatomicalStructure","QuadricepsFemoris"], "Entity[\"AnatomicalStructure\", \"QuadricepsFemoris\"]", "anatomical structure"]),(Entity["gluteus maximus", Entity["AnatomicalStructure","GluteusMaximus"], "Entity[\"AnatomicalStructure\", \"GluteusMaximus\"]", "anatomical structure"]),(Entity["adductor magnus", Entity["AnatomicalStructure","AdductorMagnus"], "Entity[\"AnatomicalStructure\", \"AdductorMagnus\"]", "anatomical structure"]),(Entity["soleus", Entity["AnatomicalStructure","Soleus"], "Entity[\"AnatomicalStructure\", \"Soleus\"]", "anatomical structure"]),(Entity["skeleton of lower limb", Entity["AnatomicalStructure","SkeletonOfLowerLimb"], "Entity[\"AnatomicalStructure\", \"SkeletonOfLowerLimb\"]", "anatomical structure"])},PlotTheme->"Web"]

Lookup exercises by primary muscles or sites of improved strength:

EntityList[Entity["WeightTrainingExercise",{(EntityProperty["primary muscles", EntityProperty["WeightTrainingExercise","PrimaryMuscles"], "EntityProperty[\"WeightTrainingExercise\", \"PrimaryMuscles\"]"])->(Entity["gluteus maximus", Entity["AnatomicalStructure","GluteusMaximus"], "Entity[\"AnatomicalStructure\", \"GluteusMaximus\"]", "anatomical structure"])}]]

EntityList[Entity["WeightTrainingExercise",{(EntityProperty["sites of improved strength", EntityProperty["WeightTrainingExercise","SitesOfImprovedStrength"], "EntityProperty[\"WeightTrainingExercise\", \"SitesOfImprovedStrength\"]"])->(Entity["arm", Entity["AnatomicalStructure","Arm"], "Entity[\"AnatomicalStructure\", \"Arm\"]", "anatomical structure"])}]]

Summary

A curated collection of computable exercise data is accessible in the Wolfram Language:

PhysicalActivity dataset was updated to support computation of energy expenditure for diverse sport/daily activities

New WeightTrainingExercise data collection was added to encompass information like instructions, mechanics, muscles engaged, and variations

Health and Exercise in Formulas

Energy Expenditure formulas

Basal Metabolic Rate

Adjusting Calorie Counts and Comparing Exercises

Weight Training Exercises: Repetition and Weights

Calories Burned Lifting Weights

Weight lifting: One-Repetition Maximum

The one-repetition maximum formulas predict the maximum weight a person can lift one time based on a lesser weight they can lift several times.

Planning and Tracking Progress

Knowing how many calories you burn is just part of a proper diet. The Wolfram Language also provides tool for determining calorie budgets and measuring progress.

Tracking Progress

Nutrition

Nutrition Information

Table[EntityValue[foodtype,"EntityCount"],{foodtype,{"Food","FoodType"}}]

WordCloud[EntityValue[EntityClass["FoodType",{EntityProperty["FoodType","BasicFoodGroups"]->Entity["BasicFoodGroup","Vegetables"]}],{"Name","RelativeVitaminKContent"}]]

Wolfram Language Functionality

Recipes

dinner=EntityGroup[{EntityInstance[,Quantity[1,"Servings"]],EntityInstance[,Quantity[3,"Items"]],EntityInstance[,Quantity[1.5,"Servings"]],EntityInstance[,Quantity[1,"USSodaCanVolumes"]]}];

dinner[(EntityProperty["nutrition label", EntityProperty["Food","NutritionLabel"], "EntityProperty[\"Food\", \"NutritionLabel\"]"])]

Excel Functionality

Nutrition Tracker

Excel Data: Exercises

Conclusion

The Wolfram Language provides comprehensive data sources for both exercises and nutrition enhanced by a wide variety of fitness and health related formulas to allow you to more precisely calculate your diet and progress towards your health goals.