VectorDistance Example: Sparse I/O, Nondefault Thresholds | Teradata Vantage - VectorDistance Example: Sparse-Format Input and Output, Nondefault Thresholds - 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ā„¢

This example uses the MaxDistance syntax element to limit the output to target vectors within the specified distances for each measure.

SQL Call

SELECT * FROM VectorDistance (
  ON target_mobile_data as TargetTable PARTITION BY UserID
  ON ref_mobile_data as ReferenceTable DIMENSION
  USING
  TargetIdColumns ('UserID')
  TargetAttributeNameColumn ('Feature')
  TargetAttributeValueColumn ('value1')
  DistanceMeasure ('Cosine','Euclidean','Manhattan')
  MaxDistance (0.03,0.8,1.0)
) AS dt ORDER BY 1;

Output

Only UserID 2 and UserID 3 meet the threshold criteria.

 target_userid ref_userid type      distance             
 ------------- ---------- --------- -------------------- 
             2          5 manhattan                 0.73
             2          5 euclidean   0.5243090691567331
             2          5 cosine     0.02608922985452755
             3          5 manhattan                 0.67
             3          5 euclidean   0.4526588119102511
             3          5 cosine    0.024150544155866593

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