1.1 - 8.10 - VectorDistance Example: Nondefault Thresholds - 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 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')
  TargetFeatureColumn ('Feature')
  TargetValueColumn ('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 from the attachment in the left sidebar.