RandomWalkSample Example | Teradata Vantage - RandomWalkSample 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

citvertices_2
id
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1013
1014
1015
1016
1017
1018
1019
1020
...
citedges_2
from_id to_id
1057 1003
1076 1046
1080 1035
1110 1092
1129 1101
1134 1001
1134 1054
1152 4015
1155 1046
1160 1005
1161 1080
1161 1035
1172 4210
1178 1177
1195 1046
1196 1119
1204 1073
1209 1189
1222 3283
1225 1072
... ....

Call

Specifying the Seed value in the SQL-GR call guarantees that the result is repeatable on the same cluster. However, the result can differ between clusters, as the sample graph is not deterministic.

SELECT * FROM RandomWalkSample (
  ON citvertices_2 AS Vertices PARTITION BY id
  ON citedges_2 AS Edges PARTITION BY from_id
  OUT TABLE VertexOutputTable (rw_vertices_15)
  OUT TABLE EdgeOutputTable (rw_edges_15)
  USING
  TargetKey ('to_id')
  FlyBackRate (0.15)
  SampleRate (0.15)
  Seed (1000)
) AS dt;

Output

 name             count 
 ---------------- ----- 
 vertices          1209
 edges              744
 sampled vertices   181
 sampled edges       99
SELECT * FROM rw_vertices_15;
 id_1 
 ---- 
 2047
 2178
 4204
 2286
 3006
 1164
 3272
 2083
 1225
 3261
 1287
 3328
 2270
 2303
 4124
 2258
 1059
 1035
 1304
 1002
 2038
 1128
 2073
 1306
 3258
 2204
 1188
 1231
 2147
 4210
 1126
 4110
 1322
 4013
 2219
 3229
 4102
 1046
 4160
 3043
 3050
 2009
 3228
 1175
 2301
 4169
 4104
 3221
 1262
 1063
 1268
 1250
 1083
 1203
 4209
 3038
 3046
 2192
 2197
 2275
 1122
 1072
 1088
 2263
 1027
 3178
 4106
 3246
 4239
 2228
 3251
 2289
 4083
 2168
 3250
 2229
 3312
 3196
 4243
 1249
 2065
 2232
 1161
 3154
 4107
 1244
 3059
 1290
 3163
 1173
 3125
 3297
 4094
 2207
 3256
 3292
 3291
 2040
 3027
 2027
 2262
 3068
 2184
 1004
 1309
 4009
 1166
 1121
 4045
 2264
 2271
 4149
 1101
 1124
 1292
 2058
 1200
 3166
 4044
 2299
 2149
 1316
 1193
 2063
 2248
 1211
 1302
 1074
 4222
 1008
 1264
 4072
 3055
 3252
 2011
 1208
 2076
 3235
 3034
 2253
 1080
 3189
 2290
 2001
 3310
 1020
 3307
 2293
 1137
 4208
 3090
 2138
 1191
 4170
 1192
 3150
 2260
 3028
 2026
 2109
 3184
 2108
 2004
 3089
 1028
 1142
 2298
 1172
 2002
 1017
 2064
 3301
 3212
 4242
 1034
 1260
 4085
 3233
 3045
 3096
 2300
SELECT * FROM rw_edges_15;
 source_1 target_1 
 -------- -------- 
     4107     4110
     2197     1292
     2229     2009
     2178     1166
     4208     3184
     4222     1101
     2286     2262
     3291     3292
     3261     1192
     3045     2004
     2264     2147
     3235     1260
     2064     2063
     1161     1080
     2038     1290
     1264     1101
     4044     1268
     4085     3184
     3163     2064
     3301     2293
     3310     2260
     1225     1072
     2147     1124
     1309     1203
     3258     1188
     4210     3154
     3312     2001
     2063     2064
     1322     1304
     4107     3212
     4208     2149
     3246     1002
     2263     1083
     4169     1002
     3252     3068
     2076     2004
     2064     1101
     1161     1035
     4013     3261
     4085     2149
     3163     1101
     3089     3328
     2258     1002
     1309     1121
     4210     1172
     2063     1101
     3212     2064
     4222     2293
     4169     3154
     3045     2076
     3228     2232
     2108     2064
     3328     3089
     1080     1035
     4209     3028
     2258     1080
     2047     1008
     4242     3292
     4208     2064
     4110     4107
     2109     2073
     4009     1287
     3272     2253
     4124     1002
     3328     2229
     3184     4208
     2149     1264
     3166     2197
     4170     4110
     3178     2258
     3212     2149
     4222     3250
     2065     2204
     1172     4210
     3196     2192
     2108     1124
     3221     1175
     3184     2108
     2293     1101
     4083     1128
     4242     3291
     3256     2147
     2253     1175
     2168     2064
     4124     3246
     3189     2264
     2232     1002
     2248     1306
     2168     2063
     2232     1172
     4208     4085
     2168     1101
     4085     2108
     3212     2108
     4204     2063
     3184     2064
     4160     1208
     1287     1046
     3184     2149

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