LocalClusteringCoefficient Example | Teradata Vantage - LocalClusteringCoefficient Example: WUN - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
9.02
9.01
2.0
1.3
Published
February 2022
Language
English (United States)
Last Update
2022-02-10
dita:mapPath
rnn1580259159235.ditamap
dita:ditavalPath
ybt1582220416951.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

This example treats the input graph as a weighted, undirected network (WUN).

Input

In the following figure, nodes represent countries, edges connect countries that trade with each other, and numbers on edges represent trade propensity.

Graph of Trading Partners
Graph of input for example of Machine Learning Engine function LocalClusteringCoefficient on weighted, undirected network

The graph in the figure is represented by the Vertices and Edges tables country and trade, respectively.

Vertices: country
countryid name
1 USA
2 China
3 UK
4 Japan
5 France
Edges: trade
fromid toid tradeweight
1 2 0.8
1 3 0.5
1 4 0.8
2 3 0.5
3 1 0.2
3 4 0.3
3 5 0.4
5 1 0.5

SQL Call

SELECT * FROM LocalClusteringCoefficient (
  ON trade as Edges PARTITION BY fromid
  ON country as Vertices PARTITION BY countryid
  USING
  TargetKey ('toid')
  EdgeWeight ('tradeweight') 
  Directed ('f') 
  Accumulate ('countryid', 'name')
) AS dt ORDER BY countryid;

Output

 countryid name   degree tri_cnt cc w_cc    
 --------- ------ ------ ------- -- ------- 
         1 usa         4       6  1 0.44642
         2 china       2       2  2 1.01569
         3 uk          4       6  1 0.44642
         4 japan       2       2  2 0.85667
         5 france      2       2  2 0.80615

Download a zip file of all examples and a SQL script file that creates their input tables.