TD_Silhouette Example | Silhouette | Teradata Vantage - Example: How to Use TD_Silhouette - Analytics Database

Database Analytic Functions

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-04-06
dita:mapPath
gjn1627595495337.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
jmh1512506877710
Product Category
Teradata Vantageā„¢

TD_Silhouette InputTable

 id clusterid c1 c2 
 -- --------- -- -- 
  1         1  1  1
  2         1  2  2
  3         2  8  8
  4         2  9  9

Example: TD_Silhouette Call Using SCORE

SELECT * FROM TD_Silhouette(
ON input_tbl as InputTable
USING
 IdColumn('id')
 ClusterIdColumn('clusterid')
 TargetColumns('c1','c2')
 OutputType('SCORE')
) as dt;

TD_Silhouette Output Using SCORE

silhouette_score 
---------------- 
     0.856410256

Example: TD_Silhouette Call Using SAMPLE_SCORES

SELECT * FROM TD_Silhouette(
ON input_tbl as InputTable
USING
 IdColumn('id')
 ClusterIdColumn('clusterid')
 TargetColumns('c1','c2')
 OutputType('SAMPLE_SCORES')
) as dt;

TD_Silhouette Output Using SAMPLE_SCORES

id clusterid a_i         b_i          silhouette_score 
-- --------- ----------- ------------ ---------------- 
 1         1 1.414213562 10.606601718      0.866666667
 4         2 1.414213562 10.606601718      0.866666667
 3         2 1.414213562  9.192388155      0.846153846
 2         1 1.414213562  9.192388155      0.846153846

Example: TD_Silhouette Call Using CLUSTER_SCORES

Output when OutputType is set to CLUSTER_SCORES.

SELECT * FROM TD_Silhouette(
ON input_tbl as InputTable
USING
 IdColumn('id')
 ClusterIdColumn('clusterid')
 TargetColumns('c1','c2')
 OutputType('CLUSTER_SCORES')
) as dt;

TD_Silhouette Output Using CLUSTER_SCORES

clusterid silhouette_score 
--------- ---------------- 
        1      0.856410256
        2      0.856410256

Example: TD_Silhouette Using TargetColumns and SCORE

SELECT * FROM TD_Silhouette(
ON input_tbl as InputTable
USING
 IdColumn('id')
 ClusterIdColumn('clusterid')
 TargetColumns('[2:3]')
 OutputType('SCORE')
) as dt;