In this post, I will explore EntittyType and some new properties of the TaxonomicSpecies introduced in Mathematica version 14.0. This is a reply post where I will re-use the previous notebook.
The “Millions of Species Become Computable” example
The “Millions of Species Become Computable” example
The new release notes show a the use of an EntityProperty , “predators” in the section “Millions of Species Become Computable”.
I will replicate the example here. It uses the concept of implicit EntityClass i.e. we select all species entities that have the cheetah as a predator:
I will replicate the example here. It uses the concept of implicit EntityClass i.e. we select all species entities that have the cheetah as a predator:
In[]:=
EntityList@EntityClass"TaxonomicSpecies",->
Out[]=
,,,,,,,,,,,,,,,,,,
From version 13.3: EntityType
From version 13.3: EntityType
If we look closer to the “predator” EntityProperty we will see a hierarchical syntax:
In[]:=
Out[]//InputForm=
EntityProperty[TaxonomicSpecies -> Eukaryote -> Animal, Predators]
The EntityProperty object “predators” turns out use the syntax of the new EntityType function, introduced in version 13.3.
This entity syntax is named a child-entity type.
Unfortunately, the new expression wasn’t featured in the “What’s New in version 13.3” post on the Wolfram Blog and I completely missed it.
EntityType elaborates on the abstract entity types in previous Wolfram Language versions. It can help us navigate an entity’s hierachical structure.
This entity syntax is named a child-entity type.
Unfortunately, the new expression wasn’t featured in the “What’s New in version 13.3” post on the Wolfram Blog and I completely missed it.
EntityType elaborates on the abstract entity types in previous Wolfram Language versions. It can help us navigate an entity’s hierachical structure.
New in 14: TaxonomicSpecies
New in 14: TaxonomicSpecies
EntityType properties
EntityType properties
The entity type “TaxonomicSpecies” was introduced in version 14. What can we do with this and EntityType?
The EntityType expression has the following properties:
The EntityType expression has the following properties:
In[]:=
EntityType["TaxonomicSpecies"]["Properties"]
Out[]=
{ChildTypes,EntityCount,EntitySourceType,EntitySourceTypeTree,EntityStore,EntityTypeGraph,EntityTypeTree,ParentType}
The EntityType’s properties ChildTypes and ParentType can be used to navigate its hierarchical structure.
We can also create a visual of the structure with one of these properties: “EntitySourceType”, “EntitySourceTypeTree”, “EntityTypeGraph”, “EntityTypeTree”.
For example:
We can also create a visual of the structure with one of these properties: “EntitySourceType”, “EntitySourceTypeTree”, “EntityTypeGraph”, “EntityTypeTree”.
For example:
In[]:=
EntityType["TaxonomicSpecies"]["EntityTypeTree"]
Out[]=
Thre are only 3 out of 396 EntityTypes that have some hierachical structure in version 14.0:
◼
GeographicRegion
◼
Person
◼
TaxonomicSpecies
Note:
You can create a similar EntityTypeTree yourself using the ChildTypes property:
You can create a similar EntityTypeTree yourself using the ChildTypes property:
In[]:=
TreeMap[CanonicalName,#]&@NestTree[EntityValue[#,"ChildTypes"]&,EntityType["TaxonomicSpecies"],2]
Properties of the child-entity EntityType
Properties of the child-entity EntityType
The “predator” EntityProperty is based on this child-type EntityType:
In[]:=
EntityType["TaxonomicSpecies"->"Eukaryote"->"Animal"]
Out[]=
What can we do with this object?
For one, we can retrieve all child-entity type properties of the object as so:
For one, we can retrieve all child-entity type properties of the object as so:
In[]:=
EntityProperties@//Shallow
Out[]//Shallow=
,,,,,,,,,,93
This is not my preferred way of getting an entity’s properties, but there are some limitations with the EntityType expression (see the last section “My Observations”).
In the object’s property list you will find the “predator” EntityProperty which was used in the ”Millions of Species Become Computable” example.
In the object’s property list you will find the “predator” EntityProperty which was used in the ”Millions of Species Become Computable” example.
What else can we do with this object?
Not a whole lot, unfortunately.
The child-type EntityType object is an abstract concept (almost like a class) which represent a number of Entities.
We can retrieve the number of entities with the EntityType property “EntityCount”:
Not a whole lot, unfortunately.
The child-type EntityType object is an abstract concept (almost like a class) which represent a number of Entities.
We can retrieve the number of entities with the EntityType property “EntityCount”:
In[]:=
Out[]=
1534896
How do we find all entities associated with this object next?
Again, we are limited in the number of regular entity operations we can use, but we can create a class of the object first as so:
Again, we are limited in the number of regular entity operations we can use, but we can create a class of the object first as so:
In[]:=
EntityClass[#,All]&@@
Out[]=
Now we get its entities (randomly):
In[]:=
Out[]=
,,,,,,,,,
Another way is to get only random entities from the object direclty:
In[]:=
RandomEntity,10
Out[]=
,,,,,,,,,
Unfortunately, there are still some inconsistencies in the way we can and cannot use the EntityType.
Species taxonomy - shark week
Species taxonomy - shark week
Before I close with some observations on the entity framework, I want to share how we can compute a species taxonomy with the old (version 12) entity type Species.
Sharks are of the cartilaginous fishes species, which comprises of sharks and rays.
We will look for different species in the EntittyClass[“Sepcies”,”Fish”]:
Sharks are of the cartilaginous fishes species, which comprises of sharks and rays.
We will look for different species in the EntittyClass[“Sepcies”,”Fish”]:
In[]:=
Out[]=
,,
Sharks taxonomic graph
Sharks taxonomic graph
We found the Entity we need, now we can create the taxonomy of sharks up to level 2 (except for the individual species to keep the graph simple) as so:
In[]:=
NestGraph,,2,VertexLabels->Automatic,ImageSize->Large
Out[]=
We used the “child taxa” EntityProperty object (associated with the “cartilaginous fishes” entity) to create this graph.
Mackerel shark taxonomic tree
Mackerel shark taxonomic tree
Next, I would like to zoom in on the mackerel sharks species and create a taxonomic tree up to the individual species:
In[]:=
TreeMap[EntityProperty["Species","Name"],#]&@NestTreeEntityValue#,&,,3,ImageSize->Full
Out[]=
We can create an image collage of all mackerel shark species, among which is the Great White shark.
In[]:=
ChildTaxa=Flatten@#&;SetAttributes[ChildTaxa,Listable];NestListChildTaxa,,3[[4]];ImageCollage[EntityValue[%,"Image"]]
Observations on EntityType
Observations on EntityType
During my quick exploration, I discovered some inconsistencies or limitations, especially on how we can use EntityType. Below, I tried to summarize my observations:
1
.Make EntityValue[EntityType,”Properties”] equivalent to EntityProperties[EntityType]. According to the Wolfram Language & System Documentation Center, the EntityProperties[type] should be equivalent to EntityValue[type,”Properties”] . Unfortunately, the equivalence does not hold for the EntityType object. For example, if we wrap EntityValue around the EntityType[“TaxonomicSpecies” -> “Eukaryote” -> “Animal”] it will be equivalent to EntityType[“TaxonomicSpecies” -> “Eukaryote” -> “Animal”]][“Properties”] which is not the same and thus not consistent. This leads to all kinds of inconsistent or limitations on syntax.
2
.Will more entity types provided with a hierchical structure in future? For example aircraft:{ fixed wing, rotary wing, jet, propellor, sail, etc}?
3
.Why does the TaxonomicSpecies child-entity type hierarchy only have 2 levels? There are more categories in the taxonomy as properties which can be found by name in the entity framework e.g. phylum, taxon etc.
4
.What should be the correct EntityTypeName or CanonicalName for EntityType if it is of the child-entity type? For example EntityType[“TaxonomicSpecies” -> “Eukaryote” -> “Animal”]//EntityTypeName or EntityType[“TaxonomicSpecies” -> “Eukaryote” -> “Animal”]//Canonicalname is “Animal”. We need the hierarchical structure to create a new EntityClass or EntityProperty object, which requires a CanonicalName witht the type->child structure intact.
5
.Make the EntityClassCount an official property. At present, it is an undocumented property. Some entities can have a large number of classes and a count informs the user about the feasibility of downloading all classes. Also, it will improve consistency; we can count entities, entity-properties but not classes in the entity framework.
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
EntityType and Species Taxonomy in version 14
by Dave Middleton
Wolfram Community, STAFF PICKS, January 14, 2024
https://community.wolfram.com/groups/-/m/t/3103210
by Dave Middleton
Wolfram Community, STAFF PICKS, January 14, 2024
https://community.wolfram.com/groups/-/m/t/3103210
