NETWORK.EMBED OpenBI
Coordinates for each node from the network's shape, to cluster with KMEANS.
Group: Networks. OpenBI’s own: DAX has no function of this name.
Syntax
NETWORK.EMBED ( <links>, <from>, <to> [, <weight>] [, <dimensions>] )
| Parameter | Type | Description |
|---|---|---|
links | Table | The rows that make the network, one link a row: a table of the model or a table expression, as the filters leave it. |
from | Expression evaluated for each row | One end of each row's link, such as a payer, a customer or a place. |
to | Expression evaluated for each row | The other end of each row's link. |
weight | Expression optional, evaluated for each row | How heavy each row's link is, such as an amount or a count; never negative. Left out, or given as the constant BLANK (), every row weighs 1. |
dimensions | Whole number optional | How many coordinates each node gets: from 1 to 20, and fewer than the nodes. 2 when left out. |
Returns
Table. A row a node, with the columns Node, D1, D2 and so on, one for each dimension.
Remarks
- The coordinates are the network's adjacency spectral embedding: nodes linked to the same nodes get coordinates close together, so a clustering of them finds groups of nodes that play the same part.
- The links are taken both ways, with their weights.
- Each dimension's sign is fixed so that its largest coordinate is positive: the same rows always give the same numbers.
- Feed the coordinates to
KMEANSorPCA.SCORES, or plot D1 against D2. - The network needs at least two nodes.
Compared with DAX
An OpenBI function: DAX has none like it, so a measure or query that uses it works in OpenBI only, not in Power BI or Analysis Services.
Examples
Two coordinates for each friend
Ann and Bo have the same neighbours, so they get the same place; D2 sets the two triangles apart.
EVALUATE
VAR Links =
DATATABLE (
"From", STRING, "To", STRING,
{
{ "Ann", "Bo" }, { "Ann", "Cy" }, { "Bo", "Cy" }, { "Cy", "Di" },
{ "Di", "Ed" }, { "Ed", "Fay" }, { "Di", "Fay" }, { "Fay", "Gus" }
}
)
RETURN
SELECTCOLUMNS (
NETWORK.EMBED ( Links, [From], [To] ),
"Node", [Node],
"D1", ROUND ( [D1], 3 ),
"D2", ROUND ( [D2], 3 )
)
| Node | D1 | D2 |
|---|---|---|
| Ann | 0.491 | 0.695 |
| Bo | 0.491 | 0.695 |
| Cy | 0.777 | 0.625 |
| Di | 0.893 | -0.308 |
| Ed | 0.635 | -0.506 |
| Fay | 0.745 | -0.652 |
| Gus | 0.271 | -0.316 |
Grouped with KMEANS
Three groups: the two triangles, and Gus on his own.
EVALUATE
VAR Links =
DATATABLE (
"From", STRING, "To", STRING,
{
{ "Ann", "Bo" }, { "Ann", "Cy" }, { "Bo", "Cy" }, { "Cy", "Di" },
{ "Di", "Ed" }, { "Ed", "Fay" }, { "Di", "Fay" }, { "Fay", "Gus" }
}
)
VAR Coordinates = NETWORK.EMBED ( Links, [From], [To] )
RETURN
SELECTCOLUMNS (
KMEANS ( Coordinates, 3, [Node], "D1", [D1], "D2", [D2] ),
"Node", [Key],
"Cluster", [Cluster]
)
| Node | Cluster |
|---|---|
| Ann | 1 |
| Bo | 1 |
| Cy | 1 |
| Di | 2 |
| Ed | 2 |
| Fay | 2 |
| Gus | 3 |
Related functions
KMEANS, PCA.SCORES, NETWORK.COMMUNITIES, NETWORK.LAYOUT, NETWORK.SIMILARITY.
Open Graph, OpenBI's graph library, does the work: strength, adjacency_spectral_embedding. See the OAX network functions and Open Graph.