annotate 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
rev   line source
DaveM@16 1 function [linkList, featureList]= treeLinkFeatures(data, depthThresh)
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@16 9
DaveM@16 10 if(nargin < 2)
DaveM@16 11 depthThresh = 9999999;
DaveM@16 12 end
DaveM@9 13 linkList = aglomCluster(data);
DaveM@16 14 linkList = depthCheck(linkList);
DaveM@10 15 listSize = size(data,1);
DaveM@9 16
DaveM@10 17 % linkList(:,4) = 0;
DaveM@10 18 featureList = cell(listSize-1,1);
DaveM@10 19 currentRow = [2*listSize-1];
DaveM@9 20
DaveM@12 21 %%
DaveM@15 22 while (~isempty(currentRow))
DaveM@16 23 if(currentRow(1) > listSize)
DaveM@11 24 row = currentRow(1) - listSize
DaveM@16 25 if(linkList(row,4) < depthThresh)
DaveM@16 26 classList = traceLinkageToBinary(linkList, row);
DaveM@16 27 featureList{row} = rfFeatureSelection(data(classList>0,:), classList(classList>0));
DaveM@16 28 currentRow = [currentRow(2:end); linkList(row,1); linkList(row,2)];
DaveM@16 29 end
DaveM@10 30 else
DaveM@10 31 currentRow = currentRow(2:end);
DaveM@10 32 end
DaveM@9 33 end
DaveM@9 34
DaveM@9 35 end