TD_KNN Regression Example | kNN | Teradata Vantage - Example: Using TD_KNN To Predict Weight Based on Height and Age - Teradata VantageCloud Lake

Lake - Analyze Your Data with ClearScape Analytics™

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2026-02-20
dita:mapPath
tcl1683670667798.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
tcl1683670667798

TD_KNN Input Table for Regression Example

Person_train
id height age weight
0 5 32 67
1 5.11 45 98
2 5.9 46 78
3 4.8 35 86
4 5.8 22 70
... ... ... ...

Example: TD_KNN SQL Call for Regression

SELECT * FROM TD_KNN(
ON person_test AS TestTable PARTITION BY ANY
ON person_train AS TrainingTable DIMENSION
USING
K(2)
ResponseColumn('weight')
InputColumns('height','age')
IDColumn('id')
ModelType('regression')
EmitNeighbors('true’)
EmitDistances('true')
) AS dt ;

TD_KNN Output Table for Regression

id prediction neighbor_id1 neighbor_dist1 neighbor_id2 neighbor_dist2
11 88 4 0.7 2 1.004
12 80 8 20.00 4 41.00