finalizes test query

This commit is contained in:
Andy Eschbacher 2018-01-09 15:06:44 -05:00
parent 18fbc2fa9e
commit 04f290cbad
2 changed files with 12 additions and 9 deletions

View File

@ -26,12 +26,12 @@ SELECT
inertia,
rowid
FROM cdb_crankshaft.CDB_KMeansNonspatial(
'SELECT unnest(Array[1, 1, 10, 10]) As col1, unnest(Array[100, 100, 2, 2]) As col2 FROM ppoints',
'SELECT unnest(Array[1, 1, 10, 10]) As col1, unnest(Array[100, 100, 2, 2]) As col2, unnest(Array[1, 2, 3, 4]) As cartodb_id',
Array['col1', 'col2']::text[],
2);
cluster_label|cluster_center|silhouettes|inertia|rowid
0|'{"col1":1,"col2":100}'||0|1
0|'{"col1":1,"col2":100}'||0|2
1|'{"col1":10,"col2":2}'||0|3
1|'{"col1":10,"col2":2}'||0|4
cluster_label|cc_col1|cc_col2|silhouettes|inertia|rowid
t|-1.0|1.0|1.0|0.0|1
t|-1.0|1.0|1.0|0.0|2
t|1.0|-1.0|1.0|0.0|3
t|1.0|-1.0|1.0|0.0|4
(4 rows)

View File

@ -20,12 +20,15 @@ FROM (
-- nonspatial kmeans
SELECT
cluster_label,
cluster_center,
cluster_label::int in (0, 1) As cluster_label,
cluster_center::json->>'col1' As cc_col1,
cluster_center::json->>'col2' As cc_col2,
silhouettes,
inertia,
rowid
FROM cdb_crankshaft.CDB_KMeansNonspatial(
'SELECT unnest(Array[1, 1, 10, 10]) As col1, unnest(Array[100, 100, 2, 2]) As col2 FROM ppoints',
'SELECT unnest(Array[1, 1, 10, 10]) As col1, ' ||
'unnest(Array[100, 100, 2, 2]) As col2, ' ||
'unnest(Array[1, 2, 3, 4]) As cartodb_id ',
Array['col1', 'col2']::text[],
2);