运行 2015 芝加哥马拉松的数据
2015年 10 月 11日芝加哥马拉松吸引了 45,000 名选手来到芝加哥. 37,000 以上的选手完成了比赛,并且每位选手的表现都被准确记录下来. 使用含有该数据的实体库研究并可视化选手的特征和其表现.
从 ResourceObject 加载该马拉松的一个实体库.
In[1]:=
marathonEntityStore = ResourceData[
ResourceObject[
Association[
"Name" -> "2015 Chicago Marathon Data",
"UUID" -> "7dc77972-cfc3-48dc-8d08-0292c6d2a929",
"ResourceType" -> "DataResource", "Version" -> "1.0.0",
"Description" -> "2015 Chicago Marathon participant data",
"ContentSize" -> Quantity[1990.2215919999999`, "Megabytes"],
"ContentElements" -> {"Content"}]]]
Out[1]=
注册该部分数据库.
In[2]:=
PrependTo[$EntityStores, marathonEntityStore];
提取选手的总人数,并采用隐式定义的实体类,提取男性和女性的参加人数.
In[3]:=
EntityValue["ChicagoMarathon2015", "EntityCount"]
Out[3]=
In[4]:=
Table[EntityValue[
EntityClass["ChicagoMarathon2015", "Gender" -> gender],
"EntityCount"], {gender, {Entity["Gender", "Male"],
Entity["Gender", "Female"]}}]
Out[4]=
随机选定五名选手.
In[5]:=
RandomEntity["ChicagoMarathon2015", 5]
Out[5]=
查看特定选手所存储的属性.
In[6]:=
Entity["ChicagoMarathon2015", "Runner145"]["PropertyAssociation"]
提取选手的国籍记录,并创建包含常见国籍的表格.
In[7]:=
nationalityTallies =
Reverse[SortBy[
Tally[EntityValue["ChicagoMarathon2015",
EntityProperty["ChicagoMarathon2015", "Country"]]], Last]];
显示完整的 Wolfram 语言输入
Out[8]//TraditionalForm=
可视化从所有国家到芝加哥的测地路径.
In[9]:=
With[{chicago =
Entity["City", {"Chicago", "Illinois", "UnitedStates"}]},
GeoGraphics[{Darker[Green],
GeoPath[{chicago, #} & /@ nationalityTallies[[All, 1]],
"Geodesic"]},
GeoRange -> "World",
GeoProjection -> "Robinson",
GeoCenter -> chicago]]
Out[9]=
构建显示美国参赛者住址的美国地图热图.
显示完整的 Wolfram 语言输入
Out[12]=
从分割均值找出每个变化的选手数目.
In[13]:=
allkm = Table[
Normal[allTimeSplits[[i]][2 ;;, "Time"]], {i,
Length[allTimeSplits]}];
In[13]:=
allsplitbins = DeleteMissing[Transpose[allkm], 2];
In[13]:=
meanall = Table[N[Mean[allsplitbins[[i]]]], {i, Length[allsplitbins]}]
Out[13]=
In[13]:=
marathondistances = (allTimeSplits[[1]])[All, "Split"] // Normal
Out[13]=
In[13]:=
differencesall = Table[{marathondistances[[i + 1]],
allsplitbins[[i]] - meanall[[i]]},
{i, Length[allsplitbins]}];
In[13]:=
allHistograms =
Histogram[#2, {60}, PlotLabel -> NumberForm[#1, {3, 1}]] & @@@
differencesall;
生成每个分割的直方图.
In[14]:=
Grid[Partition[allHistograms, UpTo[3]]]
Out[15]=
绘制选手分割和均值间的不同的平滑内核分布图.
显示完整的 Wolfram 语言输入
Out[17]=