1日の推奨摂取量から栄養素を可視化する
Wolfram Knowledgebasesには37,000種類以上の"Food"実体および1,000項目以上の"FoodType"実体についての詳細な特性と栄養情報だけでなく,176項目の栄養素の1日の推奨摂取量も含まれている.この克明なデータ集合を使えば,事実上,どんな食事の栄養素含有量でも計算することができ,簡単なプロットを使って直感的に可視化することもできる.
In[1]:=
EntityValue["Nutrient", "EntityCount"]
Out[1]=
1日2000kcalのダイエットに基づいた栄養素の推奨摂取量のリストを取得する
In[2]:=
allDailyValues =
Append[DeleteMissing[
EntityValue["Nutrient", "DailyValue", "EntityAssociation"]],
Entity["Nutrient", "Energy"] ->
Quantity[2000, ("LargeCalories")/("Days")]]*Quantity[1, "Days"]
Out[2]=
栄養素に食物特性をマップする.
In[3]:=
propertyNutrientRules = {EntityProperty["Food",
"AbsoluteSodiumContent"] -> Entity["Nutrient", "Sodium"],
EntityProperty["Food", "AbsoluteTotalCarbohydratesContent"] ->
Entity["Nutrient", "TotalCarbohydrates"],
EntityProperty["Food", "AbsoluteTotalFatContent"] ->
Entity["Nutrient", "TotalFat"],
EntityProperty["Food", "AbsoluteTotalFiberContent"] ->
Entity["Nutrient", "TotalFiber"],
EntityProperty["Food", "AbsoluteIronContent"] ->
Entity["Nutrient", "Iron"],
EntityProperty["Food", "AbsoluteTotalCaloriesContent"] ->
Entity["Nutrient", "Energy"]};
EntityGroupとEntityInstanceを使って典型的な朝食を符号化する.
In[4]:=
breakfast = EntityGroup[{
EntityInstance[Entity[
"Food", {
EntityProperty["Food", "CookingMethod"] -> Entity[
"CookingMethod", "HardBoiled"],
EntityProperty["Food", "FoodType"] -> ContainsExactly[{
Entity["FoodType", "Egg"]}],
EntityProperty[
"Food", "AddedFoodTypes"] -> ContainsExactly[{}]}],
Quantity[2, "Servings"]],
EntityInstance[Entity[
"Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{
Entity["FoodType", "Bacon"]}],
EntityProperty[
"Food", "AddedFoodTypes"] -> ContainsExactly[{}]}],
Quantity[3, "Slices"]],
EntityInstance[Entity[
"Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{
Entity["FoodType", "HashBrown"]}],
EntityProperty[
"Food", "AddedFoodTypes"] -> ContainsExactly[{}]}],
Quantity[1, "Servings"]],
EntityInstance[Entity[
"Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{
Entity["FoodType", "OrangeJuice"]}],
EntityProperty[
"Food", "AddedFoodTypes"] -> ContainsExactly[{}]}],
Quantity[2, "Servings"]]
}];
6つの主な栄養素について,1日の推奨摂取量の50%,100%(緑で表示),150%を示す放射状にネストした六角形で示す栄養バランスグラフを構築する.
完全なWolfram言語入力を表示する
In[6]:=
compassPlot[breakfast]
Out[6]=
朝食に加え,昼食と夕食も指定する.
In[7]:=
lunch = EntityGroup[{
EntityInstance[Entity[
"Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{
Entity["FoodType", "PeanutButter"]}],
EntityProperty[
"Food", "AddedFoodTypes"] -> ContainsExactly[{}]}],
Quantity[2, "Tablespoons"]],
EntityInstance[Entity[
"Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{
Entity["FoodType", "Bread"]}],
EntityProperty[
"Food", "AddedFoodTypes"] -> ContainsExactly[{}]}],
Quantity[2, "Slices"]],
EntityInstance[Entity[
"Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{
Entity["FoodType", "Jelly"]}],
EntityProperty[
"Food", "AddedFoodTypes"] -> ContainsExactly[{}]}],
Quantity[1, "Servings"]]
}];
In[8]:=
dinner = EntityGroup[{
EntityInstance[Entity[
"Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{
Entity["FoodType", "Spaghetti"]}],
EntityProperty[
"Food", "AddedFoodTypes"] -> ContainsExactly[{}]}],
Quantity[1, "Servings"]],
EntityInstance[Entity[
"Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{
Entity["FoodType", "Meatball"]}],
EntityProperty[
"Food", "AddedFoodTypes"] -> ContainsExactly[{}]}],
Quantity[3, "Items"]],
EntityInstance[Entity[
"Food", {
EntityProperty["Food", "BrandName"] -> Entity[
"FoodBrandName", "Bertolli"],
EntityProperty["Food", "FoodType"] -> ContainsExactly[{
Entity["FoodType", "Sauce"]}],
EntityProperty[
"Food", "AddedFoodTypes"] -> ContainsExactly[{}]}],
Quantity[1.5, "Servings"]],
EntityInstance[Entity[
"Food", {
EntityProperty["Food", "Flavor"] -> Entity[
"FoodFlavor", "Cola"],
EntityProperty["Food", "FoodType"] -> ContainsExactly[{
Entity["FoodType", "CarbonatedBeverage"]}],
EntityProperty[
"Food", "AddedFoodTypes"] -> ContainsExactly[{}]}],
Quantity[1, "USSodaCanVolumes"]]
}];
各食事後の栄養素摂取状況を累積して可視化する.
完全なWolfram言語入力を表示する
Out[9]=