mirror of
https://github.com/CartoDB/crankshaft.git
synced 2024-11-01 10:20:48 +08:00
adds sql tests for nonspatial kmeans
This commit is contained in:
parent
49a317ae8e
commit
20104c2df9
@ -1,10 +1,37 @@
|
||||
\pset format unaligned
|
||||
\set ECHO all
|
||||
SELECT count(DISTINCT cluster_no) as clusters from cdb_crankshaft.cdb_kmeans('select * from ppoints', 2);
|
||||
SELECT
|
||||
count(DISTINCT cluster_no) as clusters
|
||||
FROM
|
||||
cdb_crankshaft.cdb_kmeans('select * from ppoints', 2);
|
||||
clusters
|
||||
2
|
||||
(1 row)
|
||||
SELECT count(*) clusters from (select cdb_crankshaft.CDB_WeightedMean(the_geom, value::NUMERIC), code from ppoints group by code) p;
|
||||
SELECT
|
||||
count(*) clusters
|
||||
FROM (
|
||||
SELECT
|
||||
cdb_crankshaft.CDB_WeightedMean(the_geom, value::NUMERIC),
|
||||
code
|
||||
FROM ppoints
|
||||
GROUP BY code
|
||||
) p;
|
||||
clusters
|
||||
52
|
||||
(1 row)
|
||||
SELECT
|
||||
cluster_label,
|
||||
cluster_center,
|
||||
silhouettes,
|
||||
inertia,
|
||||
rowid
|
||||
FROM cdb_crankshaft.CDB_KMeansNonspatial(
|
||||
'select unnest(Array[1, 1, 10, 10]) as col1, unnest(100, 100, 2, 2) as col2 from ppoints',
|
||||
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
|
||||
(4 rows)
|
||||
|
@ -1,6 +1,31 @@
|
||||
\pset format unaligned
|
||||
\set ECHO all
|
||||
|
||||
SELECT count(DISTINCT cluster_no) as clusters from cdb_crankshaft.cdb_kmeans('select * from ppoints', 2);
|
||||
-- spatial kmeans
|
||||
SELECT
|
||||
count(DISTINCT cluster_no) as clusters
|
||||
FROM
|
||||
cdb_crankshaft.cdb_kmeans('select * from ppoints', 2);
|
||||
|
||||
SELECT count(*) clusters from (select cdb_crankshaft.CDB_WeightedMean(the_geom, value::NUMERIC), code from ppoints group by code) p;
|
||||
-- weighted mean
|
||||
SELECT
|
||||
count(*) clusters
|
||||
FROM (
|
||||
SELECT
|
||||
cdb_crankshaft.CDB_WeightedMean(the_geom, value::NUMERIC),
|
||||
code
|
||||
FROM ppoints
|
||||
GROUP BY code
|
||||
) p;
|
||||
|
||||
-- nonspatial kmeans
|
||||
SELECT
|
||||
cluster_label,
|
||||
cluster_center,
|
||||
silhouettes,
|
||||
inertia,
|
||||
rowid
|
||||
FROM cdb_crankshaft.CDB_KMeansNonspatial(
|
||||
'select unnest(Array[1, 1, 10, 10]) as col1, unnest(100, 100, 2, 2) as col2 from ppoints',
|
||||
Array['col1', 'col2']::text[],
|
||||
2);
|
||||
|
Loading…
Reference in New Issue
Block a user