Entity Exploration
More Playing with Amusement Parks

This notebook has several examples of the kinds of work that may be done with entities. As an example, I focus on the Amusement Park group of entities and explore several types of questions. As an activity, we went through this notebook as a group as a follow up to “Playing with Amusement Parks.” The following examples have some notes of explanation, but not step-by-step. These are meant to be ideas that could be applied to other types of entities too.

Getting Started & Review
How do we get information about amusement parks?

Download the set of entities. You may put a semi-colon ; at the end of the code to suppress the output.

allparks=EntityList["AmusementPark"]

You can count the number of entities by checking the length of the list.

Length[allparks]

For working with entities, especially when setting things up, it is often easier to work with a smaller subset of the data.

parks=RandomSample[allparks,20]

The ctrl + = construct allows you to call up a single entity or copy/past from the list of entities.

LinguisticAssistant

We can ask for available properties as below.

(Entity["Knott's Berry Farm", Entity["AmusementPark","KnottsBerryFarm::BuenaPark::1940"], "Entity[\"AmusementPark\", \"KnottsBerryFarm::BuenaPark::1940\"]", "amusement park"])["Properties"]

Or you can ask for the properties for the set directly.

EntityValue["AmusementPark","Properties"]

Let’s check a few properties for this amusement park.

(Entity["Knott's Berry Farm", Entity["AmusementPark","KnottsBerryFarm::BuenaPark::1940"], "Entity[\"AmusementPark\", \"KnottsBerryFarm::BuenaPark::1940\"]", "amusement park"])["Area"]

(Entity["Knott's Berry Farm", Entity["AmusementPark","KnottsBerryFarm::BuenaPark::1940"], "Entity[\"AmusementPark\", \"KnottsBerryFarm::BuenaPark::1940\"]", "amusement park"])["NumberOfRides"]

(Entity["Knott's Berry Farm", Entity["AmusementPark","KnottsBerryFarm::BuenaPark::1940"], "Entity[\"AmusementPark\", \"KnottsBerryFarm::BuenaPark::1940\"]", "amusement park"])["StandardRides"]

It looks like the rides themselves are entities. More with this later.

GeoGraphics
Where are these amusement parks located?

In the first part “Playing with Amusement Parks” I outline step-by-step directions for creating a map of our list of amusement parks along with detailed tooltips. A copy of the result of that activity is below. (Note that this may take a while to evaluate, since the information within the tooltips will need to be downloaded.) See “Playing with Amusement Parks” for details about how this works.

GeoGraphics[{Red,PointSize[Large],DeleteMissing[Tooltip[Point[#["Position"]],
Column[{
Style[#["Name"],14,Bold],
If[city=DeleteMissing[{#["City"]["Name"]},1,2];city=={},Nothing,First[city]],
First[#["Country"]]["Name"],
If[img=DeleteMissing[{#["Image"]},1,2];img=={},Nothing,First[img]]
}]
]&/@parks,1,2]}]

TimelinePlot
When did these amusement parks open?

Among the properties for amusement parks there is data with dates. When did these amusement parks open? Which ones are oldest or newest? We can use TimelinePlot for this.

TimelinePlot[Through[parks["OpeningDate"]]]

However, in this plot we cannot tell which points are for which parks. Let’s organize our data with AssociationMap.

AssociationMap[#["OpeningDate"]&,parks]

Now the timeline plot will have useful labels and we can answer our question about which is the oldest and newest. Note that TimelinePlot automatically ignores missing data.

TimelinePlot[AssociationMap[#["OpeningDate"]&,parks]]

Some of these parks are quite old. Are they still open?

TimelinePlot[AssociationMap[#["ClosingDate"]&,parks]]

In my list, some that are not that old are apparently closed. We can create date intervals for each park indicating the time span they were open.

Map[Interval[{#["OpeningDate"],#["ClosingDate"]}]&,parks]

There is a lot of missing data here, especially since many of the amusement parks do not have a closing date. TimelinePlot does not automatically handle this when the missing data is in an interval. The following produces a blank timeline.

TimelinePlot[Map[Interval[{#["OpeningDate"],#["ClosingDate"]}]&,parks]]

We can use DeleteMissing to help here. Note that it needs level specifications to get to the missing data.

TimelinePlot[DeleteMissing[Map[Interval[{#["OpeningDate"],#["ClosingDate"]}]&,parks],1,2]]

Again we cannot tell which interval goes with which amusement park. We can use Tooltip with our data.

TimelinePlot[DeleteMissing[Map[Tooltip[Interval[{#["OpeningDate"],#["ClosingDate"]}],#["Name"]]&,parks],1,3]]

If we replace #[“Name”] in the tooltip with the Column developed for the tooltip in the GeoGraphics example, we have something more elaborate.

TimelinePlot[DeleteMissing[Map[Tooltip[Interval[{#["OpeningDate"],#["ClosingDate"]}],
Column[{
Style[#["Name"],14,Bold],
If[city=DeleteMissing[{#["City"]["Name"]},1,2];city=={},Nothing,First[city]],
First[#["Country"]]["Name"],
If[img=DeleteMissing[{#["Image"]},1,2];img=={},Nothing,First[img]]
}]]&,parks],1,3]]

Wait! In my original timeline, one of the parks was opened in 1869.

LinguisticAssistant["OpeningDate"]

This one did not show up in my TimelinePlot with intervals. It has missing data for the closing date.

LinguisticAssistant["ClosingDate"]

Could that park still be open? Or is it just missing data?

LinguisticAssistant["Status"]

Let' s look up more information about it. The article is quite long, so StringTake will limit it to 1, 755 characters.

StringTake[WikipediaData["Cedar Point Amusement Park"],1755]

Growing up in Southern California, Six Flags Magic Mountain is the go-to place for roller coasters around here. I did not know about Cedar Point. It sounds like quite a place!

WikipediaData["Cedar Point Amusement Park","ImageList"]

Data Comparison
Do amusement parks with more area have more rides?

We an also consider entity data in other ways. Suppose you want to see if there is a relationship among two sets of numerical data.

EntityValue["AmusementPark","Properties"]

Make ordered pairs of data with park area as the first coordinate and number of rides as the second.

{#["Area"],#["NumberOfRides"]}&/@parks

List plot will ignore the missing data and plot what it can.

ListPlot[{#["Area"],#["NumberOfRides"]}&/@parks]

Label the axes and use Tooltip to display information about each park.

ListPlot[Tooltip[{#["Area"],#["NumberOfRides"]},Column[{#["Name"],#["Country"]}]]&/@parks,AxesLabel->{"Area","Number of Rides"}]

The park list I have seems to show a trend that amusement parks with a larger area have more rides. Does this trend continue to be true if we consider more parks?

moreparks=RandomSample[allparks,200];
ListPlot[Tooltip[{#["Area"],#["NumberOfRides"]},Column[{#["Name"],#["Country"]}]]&/@moreparks,AxesLabel->{"Area","Number of Rides"}]

Note that if we use AssociationMap to organize our data, ListPlot will automatically label the points with the name of the amusement park.

ListPlot[AssociationMap[{#["Area"],#["NumberOfRides"]}&,parks],AxesLabel->{"Area","Number of Rides"}]

With more data points, labels are created for some of the points and the rest have a tooltip.

ListPlot[AssociationMap[{#["Area"],#["NumberOfRides"]}&,moreparks],AxesLabel->{"Area","Number of Rides"}]

Amusement park entities do not have as many numerical properties as many other sets of entities, but this is just an example for what could be done. One could also apply various statistical techniques on such data to evaluate correlations and strengths of relationships.

Manipulate Property Viewer
How can we quickly see more information about amusement parks?

Using Manipulate, we can create an interactive display of information for the parks in our list. In the example below, the user will be able to select an amusement park from our list “parks” and choose to see the area, owner, slogan, or country of the park.

Manipulate[
pk[prop],
{pk,parks},
{prop,{"Area","Owner","Slogan","Country"}}
]

If we want to make all properties available, we can replace our list of property choices with the entire list of properties.

Manipulate[
pk[prop],
{pk,parks},
{prop,EntityValue["AmusementPark","Properties"]}
]

Another way to learn more about each amusement park is using WikipediaData. We can make a viewer that show an image of the park along with its Wikipedia article.

Manipulate[
Column[{pk["Image"],WikipediaData[pk["Name"]]}],
{pk,parks},ContentSize->{600,300}
]

Organizing Data for Display
How can we organize property data in a table?

Suppose you have several data values you would like to organize in a chart. Let’s find all amusement parks owned by Six Flags.

sixflagsparks=Select[allparks,(#["Owner"]=={"SixFlags"})&]

We can collect data for all of these parks.

{#["Name"],#["OpeningDate"]["Year"],#["NumberOfRides"]}&/@sixflagsparks

That data may be displayed in a Grid.

data={#["Name"],#["OpeningDate"]["Year"],#["NumberOfRides"]}&/@sixflagsparks;
Grid[data,Alignment->Left,Dividers->All]

With a little more work, we can add labels by prepending the data list with a list of labels and style the grid and text. I also sorted the data by year opened.

data=SortBy[{#["Name"],#["OpeningDate"]["Year"],#["NumberOfRides"]}&/@sixflagsparks,#[[2]]&];
Style[Grid[Prepend[data,Style[#,Bold]&/@{"Name","Opened","Rides"}],Alignment->Left,Dividers->{None,{None,Thick,{Black}}},Spacings->{Automatic,1}],FontFamily->"Arial",14]

Another approach is to organize the data as a list of associations.

data=Map[<|"Name"->#["Name"],"Opened"->#["OpeningDate"]["Year"],"Rides"->#["NumberOfRides"]|>&,sixflagsparks]

This allows us to display the data using Dataset.

Dataset[data]

This time I sorted the data by number of rides from most to least.

Dataset[Reverse[SortBy[data,#[[3]]&]]]

Amusement Park Rides
Which amusement park rides are the most intense?

Earlier I discovered that amusement park rides are their own category of entities.

LinguisticAssistant["StandardRides"]

For my son’s fourth birthday, we were able to go to Knott’s Berry Farm and my husband and I rode GhostRider and found it to be quite intense. What can we look up about these rides?

EntityValue["AmusementParkRide","Properties"]

Let’s check the maximum g-force.

(Entity["GhostRider", Entity["AmusementParkRide","KnottsBerryFarm::GhostRider"], "Entity[\"AmusementParkRide\", \"KnottsBerryFarm::GhostRider\"]", "amusement park ride"])["MaximumGforce"]

That certainly explains some of what we were feeling. How fast were we going?

(Entity["GhostRider", Entity["AmusementParkRide","KnottsBerryFarm::GhostRider"], "Entity[\"AmusementParkRide\", \"KnottsBerryFarm::GhostRider\"]", "amusement park ride"])["MaximumSpeed"]

What other amusement park rides have a large maximum g-force? How does a value of 3.1 g compare?

EntityValue[EntityClass["AmusementParkRide",{"MaximumGforce"->TakeLargest[10]}],"MaximumGforce","EntityAssociation"]

GhostRider doesn’t even make the top 10. (Actually, you have to view a little more than 300 rides organized by g-force to see it.) Let’s make this top 10 list a group of rides to explore.

largeG=EntityList[EntityClass["AmusementParkRide",{"MaximumGforce"->TakeLargest[10]}]]

Let' s look at the list a little more clearly.

Dataset[AssociationMap[#["MaximumGforce"]&,largeG]]

12 g! What can we learn about Flip Flap Railway?

LinguisticAssistant/@EntityValue["AmusementParkRide","Properties"]

All that is there besides the name and maximum g-force is the year it opened and closed. This was over 100 years ago. Let’s check WikipediaData.

Pane[WikipediaData["Flip Flap Railway"],{600,300},Scrollbars->True]

Sounds brutal! Where are these roller coasters on the map?

GeoGraphics[{Red,PointSize[Large],DeleteMissing[Tooltip[Point[#["Position"]],
Column[{
Style[#["Name"],14,Bold],
If[city=DeleteMissing[{#["City"]["Name"]},1,2];city=={},Nothing,First[city]],
First[#["Park"]]["Name"],
Row[{If[city=DeleteMissing[{First[#["Park"]]["City"]["Name"]},1,2];city=={},Nothing,Row[{First[city],", "}]],First[First[#["Park"]]["Country"]]["Name"]}],
If[img=DeleteMissing[{#["Image"]},1,2];img=={},Nothing,First[img]]
}]
]&/@largeG,1,2]}]

Do roller coasters that have a high maximum g-force also have a large maximum speed?

ListPlot[Tooltip[{#["MaximumGforce"],#["MaximumSpeed"]},#["Name"]]&/@largeG,AxesLabel->{"Max g-Force","Max Speed"}]

Let’s look at more rides. We’ll find the top 20 by speed and top 20 by g-force and put them together in a set.

bigrides=Union[EntityList[EntityClass["AmusementParkRide",{"MaximumGforce"->TakeLargest[20]}]],
EntityList[EntityClass["AmusementParkRide",{"MaximumSpeed"->TakeLargest[20]}]]]

How many are in the list?

Length[bigrides]

So, only one ride is in the top 20 for both. That makes me think that maybe large g-force does not mean fast speeds. I’m sure there is a physics lesson in here somewhere.

ListPlot[Tooltip[{#["MaximumGforce"],#["MaximumSpeed"]},#["Name"]]&/@bigrides,AxesLabel->{"Max g-Force","Max Speed"}]

Which ride has the most intensity? That probably depends on what gets to you most. From the graph above, I’m curious about Ring Racer. It looks like it could have made the list for both values.

Intersection[EntityList[EntityClass["AmusementParkRide",{"MaximumGforce"->TakeLargest[20]}]],
EntityList[EntityClass["AmusementParkRide",{"MaximumSpeed"->TakeLargest[20]}]]]

What property values are listed?

LinguisticAssistant/@EntityValue["AmusementParkRide","Properties"]

Apparently, Ring Racer was only open a few months. Let’s see.

WikipediaData["Ring Racer"]

I think I'll stick with GhostRider and below . . .

Other Entities
What other entity groups are there to work with?

Evaluating EntityValue without any arguments will show a list of all of the available groups of entities to work with.

EntityValue[]

Each one has its own set of properties.

EntityValue["ZIPCode","Properties"]

EntityValue["CatBreed","Properties"]

Let’s take a look at oceans.

oceans=EntityList["Ocean"]

How many entities are in this list?

Length[oceans]

What properties are available?

LinguisticAssistant["Properties"]

What is its polygon?

(Entity["Atlantic Ocean", Entity["Ocean","AtlanticOcean"], "Entity[\"Ocean\", \"AtlanticOcean\"]", "ocean"])["Polygon"]

Use Graphics to display the polygon.

Graphics[(Entity["Atlantic Ocean", Entity["Ocean","AtlanticOcean"], "Entity[\"Ocean\", \"AtlanticOcean\"]", "ocean"])["Polygon"]]

Can you see it? How is that the Atlantic Ocean? We can also use GeoGraphics directly.

GeoGraphics[(Entity["Atlantic Ocean", Entity["Ocean","AtlanticOcean"], "Entity[\"Ocean\", \"AtlanticOcean\"]", "ocean"])]

We can style the polygon to see it together.

GeoGraphics[{Red,Polygon[(Entity["Atlantic Ocean", Entity["Ocean","AtlanticOcean"], "Entity[\"Ocean\", \"AtlanticOcean\"]", "ocean"])]}]

Sometimes GeoListPlot will work as well.

GeoListPlot[(Entity["Arafura Sea", Entity["Ocean","ArafuraSea"], "Entity[\"Ocean\", \"ArafuraSea\"]", "ocean"])]

Where is that?

GeoListPlot[(Entity["Arafura Sea", Entity["Ocean","ArafuraSea"], "Entity[\"Ocean\", \"ArafuraSea\"]", "ocean"]),GeoRange->"Country"]

Additional Comments

Choose some category from the EntityValue list and play! See what you can learn and discover. Try to create some interesting visualizations to go with your work.

Remember that large data sets take will take longer and images especially can take a long time to load.

Recommended sets of entities include Country, Pokemon (all images take a while to download), Element, Planet

For larger sets, you may want to use “SampleEntities” to get a smaller group to work with and explore. The entities in the sample are always the same.

EntityValue["AmusementPark","SampleEntities"]

Addendum: My “parks” List

I wanted to save my list of parks that I used for this activity since it worked rather well.

parks={(Entity["Caribbean Bay", Entity["AmusementPark","CaribbeanBay::KyonggiDo"], "Entity[\"AmusementPark\", \"CaribbeanBay::KyonggiDo\"]", "amusement park"]),(Entity["Excelsior Amusement Park", Entity["AmusementPark","ExcelsiorAmusementPark::Excelsior::1925"], "Entity[\"AmusementPark\", \"ExcelsiorAmusementPark::Excelsior::1925\"]", "amusement park"]),(Entity["Sandcastle Waterpark", Entity["AmusementPark","SandcastleWaterpark::WestHomestead::1989"], "Entity[\"AmusementPark\", \"SandcastleWaterpark::WestHomestead::1989\"]", "amusement park"]),(Entity["Wet 'n' Wild Gold Coast ", Entity["AmusementPark","WetnWildWaterWorld::Queensland::1984"], "Entity[\"AmusementPark\", \"WetnWildWaterWorld::Queensland::1984\"]", "amusement park"]),(Entity["Tama Tech", Entity["AmusementPark","TamaTech::qs52h"], "Entity[\"AmusementPark\", \"TamaTech::qs52h\"]", "amusement park"]),(Entity["Ålandsparken", Entity["AmusementPark","Aolandsparken::Maarianhamina::1984"], "Entity[\"AmusementPark\", \"Aolandsparken::Maarianhamina::1984\"]", "amusement park"]),(Entity["Nicco Park", Entity["AmusementPark","NiccoPark::WestBengal::1991"], "Entity[\"AmusementPark\", \"NiccoPark::WestBengal::1991\"]", "amusement park"]),(Entity["Chinese Culture and Movie Center", Entity["AmusementPark","ChineseCultureAndMovieCenter::TaipeiHsien::1974"], "Entity[\"AmusementPark\", \"ChineseCultureAndMovieCenter::TaipeiHsien::1974\"]", "amusement park"]),(Entity["Huis Ten Bosch", Entity["AmusementPark","HuisTenBosch::Sasebo::1992"], "Entity[\"AmusementPark\", \"HuisTenBosch::Sasebo::1992\"]", "amusement park"]),(Entity["World Waterpark", Entity["AmusementPark","WorldWaterpark::Edmonton::1986"], "Entity[\"AmusementPark\", \"WorldWaterpark::Edmonton::1986\"]", "amusement park"]),(Entity["Alton Towers Waterpark", Entity["AmusementPark","CaribaCreek::Staffordshire::2003"], "Entity[\"AmusementPark\", \"CaribaCreek::Staffordshire::2003\"]", "amusement park"]),(Entity["Magic Mountain", Entity["AmusementPark","MagicMountainGlenelg::SouthAustralia::1982"], "Entity[\"AmusementPark\", \"MagicMountainGlenelg::SouthAustralia::1982\"]", "amusement park"]),(Entity["Drayton Manor", Entity["AmusementPark","DraytonManorThemePark::Staffordshire::1949"], "Entity[\"AmusementPark\", \"DraytonManorThemePark::Staffordshire::1949\"]", "amusement park"]),(Entity["Soak City", Entity["AmusementPark","SoakCity::d2583"], "Entity[\"AmusementPark\", \"SoakCity::d2583\"]", "amusement park"]),(Entity["Michigan's Adventure", Entity["AmusementPark","MichigansAdventure::MuskegonMI::1956"], "Entity[\"AmusementPark\", \"MichigansAdventure::MuskegonMI::1956\"]", "amusement park"]),(Entity["Yerevan Water World", Entity["AmusementPark","YerevanWaterWorld::8mdgr"], "Entity[\"AmusementPark\", \"YerevanWaterWorld::8mdgr\"]", "amusement park"]),(Entity["Jolly Roger", Entity["AmusementPark","JollyRoger::678zr"], "Entity[\"AmusementPark\", \"JollyRoger::678zr\"]", "amusement park"]),(Entity["Cedar Point", Entity["AmusementPark","CedarPoint::Sandusky::1870"], "Entity[\"AmusementPark\", \"CedarPoint::Sandusky::1870\"]", "amusement park"]),(Entity["Walt Disney Studios Park", Entity["AmusementPark","WaltDisneyStudiosPark::SeineEtMarne::2002"], "Entity[\"AmusementPark\", \"WaltDisneyStudiosPark::SeineEtMarne::2002\"]", "amusement park"]),(Entity["Wannado City", Entity["AmusementPark","WannadoCity::Sunrise::2004"], "Entity[\"AmusementPark\", \"WannadoCity::Sunrise::2004\"]", "amusement park"])};

Abby Brown
CT@TP: Computational Thinking at Torrey Pines High School
www.abbymath.com/CT
San Diego, CA
February 2019