1.1 - 8.10 - LocalClusteringCoefficient Example: WUN - Teradata Vantage

Teradata Vantage™ - Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.1
8.10
Release Date
October 2019
Content Type
Programming Reference
Publication ID
B700-4003-079K
Language
English (United States)

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 from the attachment in the left sidebar.