Mercurial > hg > sfx-subgrouping
comparison code/treeLinkFeatures.m @ 32:4bdcab1e821c
tidy up directory
author | DaveM |
---|---|
date | Wed, 15 Mar 2017 11:33:55 +0000 |
parents | phase2/treeLinkFeatures.m@55813e99c6cf |
children |
comparison
equal
deleted
inserted
replaced
31:55813e99c6cf | 32:4bdcab1e821c |
---|---|
1 function [linkList, featureList]= treeLinkFeatures(data, depthThresh, featureNames) | |
2 %% [linkList, featureList]= treeLinkFeatures(data, depthThresh, featureNames) | |
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 | |
5 % features are produced, which are the ranked features that can be used to | |
6 % separate the given dataset at that point. | |
7 % data is the nxm matrix of content, n is the number of samples and m is | |
8 % the number of features. | |
9 % depthThresh is a list of the range of tree depths to traverse from the | |
10 % aglomerative clustering tree. A single value of depthThresh, will assume | |
11 % 1:depthThresh. For analysis of a single layer of the tree, pass a list of | |
12 % two values, both of which are the layer to be analysed. | |
13 % feature names is the list of features, so that grown trees have suitable | |
14 % names. No feature names will result in the feature number being returned. | |
15 % featureList corresponds to the rows in linkList, with the form column 1 | |
16 % is the 5 most relevant features, column 2 is the depth and column 3 is a | |
17 % decision classification tree for the decision - perhaps this should be in | |
18 % the form of a struct instead? | |
19 | |
20 | |
21 | |
22 if(nargin < 3) | |
23 featureNames = 1:size(data,2); | |
24 end | |
25 if(nargin < 2) | |
26 depthThresh = 999; | |
27 end | |
28 | |
29 if (length(depthThresh) == 1) | |
30 depthThresh = 1:depthThresh; | |
31 end | |
32 | |
33 linkList = aglomCluster(data); | |
34 linkList = depthCheck(linkList); | |
35 listSize = size(data,1); | |
36 | |
37 % linkList(:,4) = 0; | |
38 featureList = cell(listSize-1,3); | |
39 currentRow = [2*listSize-1]; | |
40 | |
41 %% | |
42 while (~isempty(currentRow)) | |
43 if(currentRow(1) > listSize) | |
44 row = currentRow(1) - listSize | |
45 % rD = linkList(row,4); | |
46 if any(linkList(row,4)==depthThresh) | |
47 classList = traceLinkageToBinary(linkList, row); | |
48 featureList{row,1} = rfFeatureSelection(data(classList>0,:), classList(classList>0)); | |
49 featureList{row,2} = linkList(row,4); | |
50 featureList{row,3} = fitctree(data(classList>0,featureList{row,1}),classList(classList>0),'PredictorNames',featureNames(featureList{row,1})); | |
51 end | |
52 currentRow = [currentRow; linkList(row,1); linkList(row,2)]; | |
53 end | |
54 currentRow = currentRow(2:end); | |
55 save('partialResults.mat'); | |
56 end | |
57 | |
58 end |