NETWORK.PREDICT OpenBI
Likely links: pairs of nodes that are not linked but should be, by the neighbours they share or a hierarchical random graph, best first.
Group: Networks. OpenBI’s own: DAX has no function of this name.
Syntax
NETWORK.PREDICT ( <links>, <from>, <to> [, <method>] [, <top>] )
| 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. |
method | Text optional | "adamic-adar" (when left out), "jaccard" or "common", from the neighbours two nodes share; or "hrg", from a hierarchical random graph that matches the network's shape. |
top | Whole number optional | How many likely links to keep, the best first: 100 when left out, 0 for every one. |
Returns
Table. A row a pair of nodes not linked, the most likely first, with the columns Rank, From, To, Score and Shared.
Remarks
- Only pairs that are not linked are scored: links the network is likely missing, or that will likely appear, such as two accounts that are one person's or two firms about to trade.
- Adamic-Adar adds 1 / ln(neighbours) over the neighbours two nodes share, so a rare shared contact counts more; Jaccard is shared / (all the neighbours of either); common is the number shared. These score only pairs with a neighbour in common.
- hrg fits hierarchies of groups within groups to the network, many of them, and scores each pair not linked by how likely they make a link between the two, from 0 to 1: it can score pairs with no neighbour in common. Its random choices are fixed, so the same rows give the same scores, in whatever order they come. It takes up to 500 nodes.
- Shared is the number of neighbours the two have in common. From and To are in the nodes' order, the smaller value first; the links are taken both ways. Among pairs as likely, the one with more neighbours shared comes first, then the nodes' order.
- In a network of two kinds of node, such as customers and products, the shared-neighbour methods pair nodes of the same kind (customers alike, products bought together); hrg can also pair a customer with a product.
- Rows where an end is blank, or where both ends are the same node, add no link; the end that is there still counts as a node.
- Nodes are compared the way OAX compares values: text without regard to case, and 1 and 1.0 are the same node. A node written two ways is shown with the spelling whose characters sort first by code (ALICE before Alice); a column of the model keeps one spelling of each text, the first it loaded.
- In a measure, the table is the rows the filters leave, so the network follows the slicers and the page: a visual measures the network of the rows in view.
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
Accounts that should be linked
Liv and Ola share both of Liv's contacts, who share with nobody else: the likeliest missing link. Kim and Per, the square's other corners, come next.
EVALUATE
VAR Shared =
DATATABLE (
"Account", STRING, "Shares with", STRING,
{
{ "Ann", "Bo" }, { "Ann", "Cy" }, { "Bo", "Cy" }, { "Cy", "Di" }, { "Di", "Ed" }, { "Ed", "Fay" },
{ "Di", "Fay" }, { "Fay", "Gus" }, { "Wim", "Xi" }, { "Xi", "Yan" }, { "Yan", "Zoe" }, { "Zoe", "Wim" },
{ "Wim", "Yan" }, { "Xi", "Zoe" }, { "Zoe", "Ola" }, { "Ola", "Per" }, { "Per", "Liv" }, { "Liv", "Kim" },
{ "Kim", "Ola" }
}
)
RETURN
NETWORK.PREDICT ( Shared, [Account], [Shares with], BLANK (), 5 )
| Rank | From | To | Score | Shared |
|---|---|---|---|---|
| 1 | Liv | Ola | 2.88539008177793 | 2 |
| 2 | Kim | Per | 2.3529342675158 | 2 |
| 3 | Ann | Di | 0.910239226626837 | 1 |
| 4 | Bo | Di | 0.910239226626837 | 1 |
| 5 | Cy | Ed | 0.910239226626837 | 1 |
Customers who buy alike
Jaccard: Liv and Per share both their beers.
EVALUATE
VAR Baskets =
DATATABLE (
"Customer", STRING, "Product", STRING,
{
{ "Ola", "Pils" }, { "Ola", "IPA" }, { "Kari", "Pils" }, { "Kari", "IPA" }, { "Kari", "Stout" },
{ "Per", "Stout" }, { "Per", "Cider" }, { "Liv", "Cider" }, { "Liv", "Stout" }, { "Nils", "Pils" }
}
)
RETURN
NETWORK.PREDICT ( Baskets, [Customer], [Product], "jaccard", 5 )
| Rank | From | To | Score | Shared |
|---|---|---|---|---|
| 1 | Liv | Per | 1 | 2 |
| 2 | Cider | Stout | 0.666666666666667 | 2 |
| 3 | IPA | Pils | 0.666666666666667 | 2 |
| 4 | Kari | Ola | 0.666666666666667 | 2 |
| 5 | Nils | Ola | 0.5 | 1 |
Related functions
NETWORK.SIMILARITY, NETWORK.COMMUNITIES, NETWORK.NODES.
Open Graph, OpenBI's graph library, does the work: hrg_init, hrg_predict, hrg_destroy. See the OAX network functions and Open Graph.