annotate toolboxes/FullBNT-1.0.7/bnt/examples/static/dtree/test_zoo1.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 % Here the training data is adapted from UCI ML repository, 'zoo' data
wolffd@0 2
wolffd@0 3 dtreeCPD=tree_CPD;
wolffd@0 4
wolffd@0 5 % load data
wolffd@0 6 fname = fullfile(BNT_HOME, 'examples', 'static', 'uci_data', 'zoo', 'zoo1.data')
wolffd@0 7 data=load(fname);
wolffd@0 8 data=data';
wolffd@0 9
wolffd@0 10 data=transform_data_into_bnt_format(data, []);
wolffd@0 11
wolffd@0 12 % learn decision tree from data
wolffd@0 13 ns=2*ones(1,17);
wolffd@0 14 ns(13)=6;
wolffd@0 15 ns(17)=7;
wolffd@0 16 dtreeCPD1=learn_params(dtreeCPD,1:17,data,ns,[],'stop_cases',5); % a node with less than 5 cases will not be splitted
wolffd@0 17
wolffd@0 18 % evaluate on data
wolffd@0 19 [score,outputs]=evaluate_tree_performance(dtreeCPD1,1:17,data,ns,[]);
wolffd@0 20 fprintf('Accuracy in old training data %6.3f\n',score);
wolffd@0 21