annotate phase2/treeLinkFeatures.m @ 27:f9fceb869865

update to range of depthThresh permitted
author DaveM
date Sun, 12 Mar 2017 19:56:52 +0000
parents 2a77dd12582f
children 7710e44f432a
rev   line source
DaveM@25 1 function [linkList, featureList]= treeLinkFeatures(data, depthThresh, featureNames)
DaveM@10 2 %% linkList = treeLinkFeatures(data)
DaveM@10 3 % given a dataset, a hierarchical cluster of the data is produced, and then
DaveM@10 4 % the data is traversed, such that, for each split in the data, a set of
DaveM@10 5 % features are produced, which are the ranked features that can be used to
DaveM@10 6 % separate the given dataset at that point.
DaveM@10 7
DaveM@9 8
DaveM@25 9 if(nargin < 3)
DaveM@25 10 featureNames = 1:size(data,2);
DaveM@25 11 end
DaveM@16 12 if(nargin < 2)
DaveM@19 13 depthThresh = 999;
DaveM@16 14 end
DaveM@27 15
DaveM@27 16 if (len(depthThresh) == 1)
DaveM@27 17 depthThresh = 1:depthThresh;
DaveM@27 18 end
DaveM@27 19
DaveM@9 20 linkList = aglomCluster(data);
DaveM@16 21 linkList = depthCheck(linkList);
DaveM@10 22 listSize = size(data,1);
DaveM@9 23
DaveM@10 24 % linkList(:,4) = 0;
DaveM@24 25 featureList = cell(listSize-1,3);
DaveM@10 26 currentRow = [2*listSize-1];
DaveM@9 27
DaveM@12 28 %%
DaveM@15 29 while (~isempty(currentRow))
DaveM@16 30 if(currentRow(1) > listSize)
DaveM@22 31 row = currentRow(1) - listSize;
DaveM@17 32 % rD = linkList(row,4);
DaveM@27 33 if any(linkList(row,4)==depthThresh)
DaveM@16 34 classList = traceLinkageToBinary(linkList, row);
DaveM@23 35 featureList{row,1} = rfFeatureSelection(data(classList>0,:), classList(classList>0));
DaveM@17 36 featureList{row,2} = linkList(row,4);
DaveM@24 37 featureList{row,3} = fitctree(data(classList>0,featureList{row,1}),classList(classList>0),'PredictorNames',featureNames(featureList{row,1}));
DaveM@16 38 end
DaveM@17 39 currentRow = [currentRow; linkList(row,1); linkList(row,2)];
DaveM@10 40 end
DaveM@17 41 currentRow = currentRow(2:end);
DaveM@9 42 end
DaveM@9 43
DaveM@9 44 end