blob: 80f5d400fb9a745bdad653fdd36cdd9e734ab46b [file] [log] [blame]
DROP TABLE IF EXISTS dt_golf;
CREATE TABLE dt_golf (
id integer NOT NULL,
"OUTLOOK" text,
temperature double precision,
humidity double precision,
windy text,
class text
) ;
INSERT INTO dt_golf (id,"OUTLOOK",temperature,humidity,windy,class) VALUES
(1, 'sunny', 85, 85, 'false', 'Don''t Play'),
(2, 'sunny', 80, 90, 'true', 'Don''t Play'),
(3, 'overcast', 83, 78, 'false', 'Play'),
(4, 'rain', 70, 96, 'false', 'Play'),
(5, 'rain', 68, 80, 'false', 'Play'),
(6, 'rain', 65, 70, 'true', 'Don''t Play'),
(7, 'overcast', 64, 65, 'true', 'Play'),
(8, 'sunny', 72, 95, 'false', 'Don''t Play'),
(9, 'sunny', 69, 70, 'false', 'Play'),
(10, 'rain', 75, 80, 'false', 'Play'),
(11, 'sunny', 75, 70, 'true', 'Play'),
(12, 'overcast', 72, 90, 'true', 'Play'),
(13, 'overcast', 81, 75, 'false', 'Play'),
(14, 'rain', 71, 80, 'true', 'Don''t Play');
-- regression, grouping
DROP TABLE IF EXISTS train_output, train_output_summary;
SELECT tree_train('dt_golf'::text, -- source table
'train_output'::text, -- output model table
'id'::text, -- id column
'temperature::double precision'::text, -- response
'humidity, windy'::text, -- features
NULL::text, -- exclude columns
'gini'::text, -- split criterion
'class'::text, -- no grouping
NULL::text, -- no weights
10::integer, -- max depth
3::integer, -- min split
1::integer, -- min bucket
3::integer, -- number of bins per continuous variable
'cp=0.01' -- cost-complexity pruning parameter
);
SELECT _print_decision_tree(tree) from train_output;
SELECT tree_display('train_output', False);
SELECT pmml('train_output');
-------------------------------------------------------------------------
-- classification, grouping
DROP TABLE IF EXISTS train_output, train_output_summary;
SELECT tree_train('dt_golf'::text, -- source table
'train_output'::text, -- output model table
'id'::text, -- id column
'"OUTLOOK"'::text, -- response
'humidity, windy'::text, -- features
NULL::text, -- exclude columns
'gini'::text, -- split criterion
'class'::text, -- no grouping
NULL::text, -- no weights
10::integer, -- max depth
3::integer, -- min split
1::integer, -- min bucket
3::integer, -- number of bins per continuous variable
'cp=0.01' -- cost-complexity pruning parameter
);
SELECT _print_decision_tree(tree) from train_output;
SELECT tree_display('train_output', False);
SELECT pmml('train_output');
-------------------------------------------------------------------------