PSALSA Example: Sources and Targets Tables as Inputs - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
8.10
1.1
Published
October 2019
Language
English (United States)
Last Update
2019-12-31
dita:mapPath
ima1540829771750.ditamap
dita:ditavalPath
jsj1481748799576.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

This example shows how to limit the vertices and edges used. Teradata recommends this technique if the original Vertices and Edges tables are large, but only a subset of the information is relevant. The function calculates the hubs and authorities for the nodes specified in the Sources and Targets tables (user_source_nodes and product_target_nodes).

Input

As in PSALSA Example: Product Recommendation for Similar Users:
  • Vertices: user_product_nodes, which has customer names
  • Edges: women_apparel_log, which reflects customer shopping patterns

SQL Call

SELECT * FROM PSALSA (
  ON user_product_nodes AS Vertices PARTITION BY nodename
  ON women_apparel_log AS Edges PARTITION BY username
  ON user_source_nodes AS Sources PARTITION BY username
  ON product_target_nodes AS Targets PARTITION BY product
  USING
  SourceKey ('username')
  TargetKey ('product')
  EdgeWeight ('frequency')
  MaxHubNum (2)
  MaxAuthorityNum (2)
  TeleportProb (0.15)
  RandomWalkLength (500)
) AS dt ORDER BY username, hub_score DESC, authority_score DESC;

Output

Based on the output, the retailer recommends pajamas to Sandra, who has no purchase history for them, but recommends nothing to Susan, who has bought all the items (see the PSALSA Example: Product Recommendation for Similar Users input). The *_score results vary with every run.

 username hub_username hub_score authority_product authority_score     
 -------- ------------ --------- ----------------- ------------------- 
 sandra   sally            0.364 NULL                             NULL
 sandra   stephanie        0.088 NULL                             NULL
 sandra   NULL              NULL pajamas           0.21348314606741572
 susan    sally            0.228 NULL                             NULL
 susan    sandra           0.168 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.