comparison phase2/treeLinkFeatures.m @ 16:4a8ec6c461a0

adding depth checking for recursive tree - feature search - though has a bug where it sometimes get stuck in an infinite loop and I dont know why
author DaveM
date Thu, 16 Feb 2017 10:07:42 +0000
parents 0718e03cb36d
children c674bf769d82
comparison
equal deleted inserted replaced
15:0718e03cb36d 16:4a8ec6c461a0
1 function [linkList, featureList]= treeLinkFeatures(data) 1 function [linkList, featureList]= treeLinkFeatures(data, depthThresh)
2 %% linkList = treeLinkFeatures(data) 2 %% linkList = treeLinkFeatures(data)
3 % given a dataset, a hierarchical cluster of the data is produced, and then 3 % given a dataset, a hierarchical cluster of the data is produced, and then
4 % the data is traversed, such that, for each split in the data, a set of 4 % the data is traversed, such that, for each split in the data, a set of
5 % features are produced, which are the ranked features that can be used to 5 % features are produced, which are the ranked features that can be used to
6 % separate the given dataset at that point. 6 % separate the given dataset at that point.
7 7
8 8
9
10 if(nargin < 2)
11 depthThresh = 9999999;
12 end
9 linkList = aglomCluster(data); 13 linkList = aglomCluster(data);
14 linkList = depthCheck(linkList);
10 listSize = size(data,1); 15 listSize = size(data,1);
11 16
12 % linkList(:,4) = 0; 17 % linkList(:,4) = 0;
13 featureList = cell(listSize-1,1); 18 featureList = cell(listSize-1,1);
14 currentRow = [2*listSize-1]; 19 currentRow = [2*listSize-1];
15 20
16 %% 21 %%
17 while (~isempty(currentRow)) 22 while (~isempty(currentRow))
18 if(currentRow(1) > listSize) 23 if(currentRow(1) > listSize)
19 row = currentRow(1) - listSize 24 row = currentRow(1) - listSize
20 classList = traceLinkageToBinary(linkList, row); 25 if(linkList(row,4) < depthThresh)
21 featureList{row} = rfFeatureSelection(data(classList>0,:), classList(classList>0)); 26 classList = traceLinkageToBinary(linkList, row);
22 currentRow = [currentRow(2:end); linkList(row,1); linkList(row,2)]; 27 featureList{row} = rfFeatureSelection(data(classList>0,:), classList(classList>0));
28 currentRow = [currentRow(2:end); linkList(row,1); linkList(row,2)];
29 end
23 else 30 else
24 currentRow = currentRow(2:end); 31 currentRow = currentRow(2:end);
25 end 32 end
26 end 33 end
27 34