one stop segmentation shop

This commit is contained in:
Stuart Lynn
2016-03-11 14:09:53 -05:00
parent fcf57289fc
commit 803781e08d
2 changed files with 77 additions and 20 deletions
+16
View File
@@ -25,3 +25,19 @@ AS $$
# TODO: use named parameters or a dictionary
return create_segment('table')
$$ LANGUAGE plpythonu;
CREATE OR REPLACE FUNCTION
cdb_create_and_predict_segment (
segment_name TEXT,
table_name TEXT,
column_name TEXT,
geoid_column TEXT DEFAULT 'geoid',
census_table TEXT DEFAULT 'block_groups'
)
RETURNS TABLE (the_geom geometry, geoid text, prediction Numeric )
AS $$
from crankshaft import segmentation
# TODO: use named parameters or a dictionary
return segmentation.create_and_predict_segment(segment_name,table_name,column_name,geoid_column,census_table,'random_forest')
$$ LANGUAGE plpythonu;