VectorDistance Example: Nondefault Thresholds - 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 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.