1.1 - 8.10 - PSALSA Example: Similar Users, No Edge Weight - 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 uses the syntax elements MaxHubNum and MaxAuthorityNum to output a maximum of two hub and two authority users.

Input

Vertices: users_vertex
userid username
1 John
2 Carla
3 Simon
4 Celine
5 Winston
6 Diana
Edges: users_edges
followers leaders likes
Carla Celine 7
Carla Diana 12
Celine Diana 4
John Carla 10
John Celine 5
John Diana 6
John Simon 2
Simon Diana 1
Winston Diana 10

The likes column is not used as edgeweight in this example.

SQL Call

SELECT * FROM PSALSA (
  ON users_vertex AS Vertices PARTITION BY username
  ON users_edges AS Edges PARTITION BY followers
  USING
  SourceKey ('followers ')
  TargetKey ('leaders ')
  MaxHubNum (2)
  MaxAuthorityNum (2)
  TeleportProb (0.15)
  RandomWalkLength (1000)
) AS dt ORDER BY followers;

Output

The output shows that the users John and Simon are similar to Carla. John is more similar, as he has a higher hub_score. The output varies with every run.

 followers hub_followers hub_score           authority_leaders authority_score     
 --------- ------------- ------------------- ----------------- ------------------- 
 carla     NULL                         NULL carla             0.12326043737574553
 carla     NULL                         NULL simon             0.09145129224652088
 carla     simon         0.08366533864541832 NULL                             NULL
 carla     john          0.41832669322709165 NULL                             NULL
 celine    NULL                         NULL celine             0.1854043392504931
 celine    NULL                         NULL carla             0.09072978303747535
 celine    carla          0.2075098814229249 NULL                             NULL
 celine    john          0.31225296442687744 NULL                             NULL
 john      celine        0.07240704500978473 NULL                             NULL
 john      carla         0.19373776908023482 NULL                             NULL
 simon     NULL                         NULL celine                          0.166
 simon     NULL                         NULL carla                           0.092
 simon     carla                       0.186 NULL                             NULL
 simon     john                        0.318 NULL                             NULL
 winston   NULL                         NULL celine                          0.184
 winston   NULL                         NULL carla                           0.096
 winston   carla                       0.186 NULL                             NULL
 winston   john                        0.308 NULL                             NULL

Download a zip file of all examples and a SQL script file that creates their input tables from the attachment in the left sidebar.