InputTable
DROP 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, '-0.06944,0.080352,0.045963,0.006985,-0.000496');
INSERT INTO input_table_udt values(2, '-0.025461,0.045302,-0.028107,0.031248,0.00077');
INSERT INTO input_table_udt values(3, '-0.028107,0.016781,-0.023147,-0.068779,-0.07936');
INSERT INTO input_table_udt values(4, '-0.030091,0.027611,-0.047616,-0.025461,0.029595');
| id |
array_col |
| 1 |
-0.06944,0.080352,0.045963,0.006985,-0.000496 |
| 2 |
-0.025461,0.045302,-0.028107,0.031248,0.00077 |
| 3 |
-0.028107,0.016781,-0.023147,-0.068779,-0.07936 |
| 4 |
-0.030091,0.027611,-0.047616,-0.025461,0.029595 |
Output: kmeans_model_udt (Generated using TD_KMeans)
| td_clusterid_kmeans |
array_col |
td_size_kmeans |
td_withinss_kmeans |
id |
td_modelinfo_kmeans |
| 0 |
-0.06944,0.080352,0.045963,0.006985,-0.000496 |
1 |
0.00000000000000E 000 |
NULL |
NULL |
| 1 |
-0.0278863333333333,0.029898,-0.0329566666666667,-0.0209973333333333,-0.0163316666666667 |
3 |
1.21668890066667E-002 |
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 : 1.21668890066667E-02 |
| NULL |
NULL |
NULL |
NULL |
NULL |
Between_SS : 8.65080482533333E-03 |
| NULL |
NULL |
NULL |
NULL |
NULL |
Method for InitialCentroids: Random |
Query
SELECT id, td_clusterid_kmeans, td_distance_kmeans, cast(array_col as Varchar(100)) as array_col FROM TD_KMeansPredict (
ON input_table_udt as InputTable
ON kmeans_model_udt as ModelTable DIMENSION
USING
OutputDistance('true')
Accumulate('array_col')
)as dt order by 1;
Output
| id |
td_clusterid_kmeans |
td_distance_kmeans |
array_col |
| 1 |
0 |
0.00000000000000E 000 |
-0.06944,0.080352,0.045963,0.006985,-0.000496 |
| 2 |
1 |
5.73474200155896E-002 |
-0.025461,0.045302,-0.028107,0.031248,0.00077 |
| 3 |
1 |
8.07712350723394E-002 |
-0.028107,0.016781,-0.023147,-0.068779,-0.07936 |
| 4 |
1 |
4.85197898708466E-002 |
-0.030091,0.027611,-0.047616,-0.025461,0.029595 |