InputTable
DROP TABLE table input_table_udt;
CREATE MULTISET TABLE input_table_udt(id INTEGER, array_col Vector) PRIMARY INDEX ( id );
INSERT INTO input_table_udt values(1, '1, 1');
INSERT INTO input_table_udt values(2, '2, 2');
INSERT INTO input_table_udt values(3, '8, 8');
INSERT INTO into input_table_udt values(4, '9, 9');
id |
array_col |
1 |
1.000000000000000,1.000000000000000 |
2 |
2.000000000000000,2.000000000000000 |
3 |
8.000000000000000,8.000000000000000 |
4 |
9.000000000000000,9.000000000000000 |
Output: kmeans_model_udt (Generated using TD_KMeans)
td_clusterid_kmeans |
array_col |
td_size_kmeans |
td_withinss_kmeans |
id |
td_modelinfo_kmeans |
0 |
1.500000000000000,1.500000000000000 |
2 |
1.000000000000000E 000 |
NULL |
NULL |
1 |
8.500000000000000,8.500000000000000 |
2 |
1.000000000000000E 000 |
NULL |
NULL |
NULL |
NULL |
NULL |
NULL |
NULL |
Converged: true |
NULL |
NULL |
NULL |
NULL |
NULL |
Number of Iterations: 2 |
NULL |
NULL |
NULL |
NULL |
NULL |
Number of Clusters: 2 |
NULL |
NULL |
NULL |
NULL |
NULL |
Total_WithinSS : 2.00000000000000E+00 |
NULL |
NULL |
NULL |
NULL |
NULL |
Between_SS : 9.80000000000000E+01 |
NULL |
NULL |
NULL |
NULL |
NULL |
Method for InitialCentroids: Random |
Query
SELECT * FROM TD_KMeansPredict (
ON input_table_udt as InputTable
ON kmeans_model_udt as ModelTable DIMENSION
USING
OutputDistance('true')
Accumulate('array_col')
)as dt;
Output
id |
td_clusterid_kmeans |
td_distance_kmeans |
array_col |
1 |
0 |
0.707106781 |
1.000000000000000,1.000000000000000 |
2 |
0 |
0.707106781 |
2.000000000000000,2.000000000000000 |
3 |
1 |
0.707106781 |
8.000000000000000,8.000000000000000 |
4 |
1 |
0.707106781 |
9.000000000000000,9.000000000000000 |