WSRecommender/CFilter Example | Teradata Vantage - WSRecommender Example - 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ā„¢

Input

  • ItemTable: cfilter_sports:
     col1_item1 col1_item2 cntb 
     ---------- ---------- ---- 
     tennis     soccer        2
     soccer     soccer        2
     golf       baseball      1
     tennis     soccer        2
     soccer     soccer        2
     golf       baseball      1
     soccer     tennis        2
     basketball baseball      1
     soccer     tennis        2
     basketball baseball      1
     basketball baseball      1
     basketball baseball      1
     basketball baseball      1
     basketball baseball      1
     baseball   basketball    1
     baseball   basketball    1
     baseball   basketball    1
     baseball   basketball    1
     baseball   basketball    1
     baseball   basketball    1
     baseball   baseball      1
     baseball   golf          1
     baseball   baseball      1
     baseball   golf          1
     baseball   baseball      1
     baseball   baseball      1
     baseball   baseball      1
     baseball   baseball      1
     baseball   baseball      1
     baseball   baseball      1

    (This table is the same as cfilter_sports_out, output by CFilter Example.)

  • UserTable: new_players:
     sport      new_player preference 
     ---------- ---------- ---------- 
     lacrosse   player_e            8
     soccer     player_c            6
     golf       player_d            6
     tennis     player_d            5
     basketball player_a            9
     basketball player_b            3
     baseball   player_a            1
     baseball   player_b            2

SQL Call

SELECT * FROM WSRecommender (
  ON (
    SELECT * FROM WSRecommenderReduce (
      ON cfilter_sports AS ItemTable PARTITION BY col1_item1
      ON new_players AS UserTable PARTITION BY sport
      USING
      Item1 ('col1_item1')
      Item2 ('col1_item2')
      ItemSimilarityScore ('cntb')
      UserIDColumn ('new_player')
      UserItemColumn ('sport')
      UserPrefColumn ('preference')
    ) AS dt1
  ) PARTITION BY usr, col1_item2
) AS dt ORDER BY recommendation DESC, item;

Output

SELECT * FROM cfilter_sports_out ORDER BY 1,2,3;
 item       usr      recommendation     new_reco_flag 
 ---------- -------- ------------------ ------------- 
 baseball   player_d                6.0             1
 soccer     player_c                6.0             0
 tennis     player_c                6.0             1
 soccer     player_d                5.0             1
 baseball   player_a 4.4285712242126465             0
 baseball   player_b 2.4285714626312256             0
 basketball player_b                2.0             0
 golf       player_b                2.0             1
 basketball player_a                1.0             0
 golf       player_a                1.0             1
 golf       player_d                0.0             0
 tennis     player_d                0.0             0