load zoo; %load matlab data t = fitctree(trn_data,trn_lab,'PredictorNames', fields); %train a decision tree for classification view(t,'Mode','graph'); %visualize the tree t %for visualization allHandles=findall(groot,'Type','text') set(allHandles,'FontSize',24) pause; h = findall(groot,'Type','figure'); close(h); for i=1:6 clf(gcf); imshow(strcat(tst_names{i},'.png')); set(gcf,'Position',[0 0 700 700]+300); title(tst_names{i},'FontSize',40); pause; y=predict(t,tst_data(i,:)); %classify a test sample by tree t title(sprintf('%s is %s',tst_names{i},y{1}),'FontSize',40,'color', 'r'); pause; end