OpenBI Docs Buy

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>] )
ParameterTypeDescription
linksTableThe rows that make the network, one link a row: a table of the model or a table expression, as the filters leave it.
fromExpression
evaluated for each row
One end of each row's link, such as a payer, a customer or a place.
toExpression
evaluated for each row
The other end of each row's link.
weightExpression
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.
dimensionsWhole 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 KMEANS or PCA.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 )
    )
NodeD1D2
Ann0.4910.695
Bo0.4910.695
Cy0.7770.625
Di0.893-0.308
Ed0.635-0.506
Fay0.745-0.652
Gus0.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]
    )
NodeCluster
Ann1
Bo1
Cy1
Di2
Ed2
Fay2
Gus3

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.

Last updated · OpenBI Studio 0.3.78