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@9
|
15 linkList = aglomCluster(data);
|
DaveM@16
|
16 linkList = depthCheck(linkList);
|
DaveM@10
|
17 listSize = size(data,1);
|
DaveM@9
|
18
|
DaveM@10
|
19 % linkList(:,4) = 0;
|
DaveM@24
|
20 featureList = cell(listSize-1,3);
|
DaveM@10
|
21 currentRow = [2*listSize-1];
|
DaveM@9
|
22
|
DaveM@12
|
23 %%
|
DaveM@15
|
24 while (~isempty(currentRow))
|
DaveM@16
|
25 if(currentRow(1) > listSize)
|
DaveM@22
|
26 row = currentRow(1) - listSize;
|
DaveM@17
|
27 % rD = linkList(row,4);
|
DaveM@16
|
28 if(linkList(row,4) < depthThresh)
|
DaveM@16
|
29 classList = traceLinkageToBinary(linkList, row);
|
DaveM@23
|
30 featureList{row,1} = rfFeatureSelection(data(classList>0,:), classList(classList>0));
|
DaveM@17
|
31 featureList{row,2} = linkList(row,4);
|
DaveM@24
|
32 featureList{row,3} = fitctree(data(classList>0,featureList{row,1}),classList(classList>0),'PredictorNames',featureNames(featureList{row,1}));
|
DaveM@16
|
33 end
|
DaveM@17
|
34 currentRow = [currentRow; linkList(row,1); linkList(row,2)];
|
DaveM@10
|
35 end
|
DaveM@17
|
36 currentRow = currentRow(2:end);
|
DaveM@9
|
37 end
|
DaveM@9
|
38
|
DaveM@9
|
39 end |