-
Notifications
You must be signed in to change notification settings - Fork 2
/
getNeighborhoodMeasures.m
71 lines (62 loc) · 2.21 KB
/
getNeighborhoodMeasures.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function [features,featureNames] = getNeighborhoodMeasures(groups,neigborhoodSize,maxNumClusters)
%GETNEIGHBORHOODRICHNESSMEASURES Summary of this function goes here
% Detailed explanation goes here
features=[];
featureNames={};
stats={'Total','Mean','Std','Median','Max','Min','Kurtosis','Skewness'};
numStats=length(stats);
n=min(neigborhoodSize,maxNumClusters);
numGroups=length(groups);
for i=1:numGroups
numClust=length(groups(i).clusters);
if numClust==0
featStats=zeros(1,numGroups*neigborhoodSize*numStats);
else
M=zeros(numClust,numGroups*neigborhoodSize);
for j=1:numClust
idx=0;
numRows=size(groups(i).absoluteClosest(j).idx,1);
if numRows>0
for k=1:neigborhoodSize
if k<=maxNumClusters && k<=numRows
val=groups(i).absoluteClosest(j).idx(1:k,1);
for kk=1:numGroups
idx=idx+1;
M(j,idx)=sum(val==kk)/k;
end
else
for kk=1:numGroups
idx=idx+1;
M(j,idx)=M(j,idx-numGroups);
end
end
end
end
end
if numClust==1
stArr=arrayfun(@(x) getFeatureStats(x),M','uni', 0);
featStats=zeros(1,numGroups*neigborhoodSize*numStats);
numVal=length(stArr);
for xx=1:numVal
val=stArr{xx};
for yy=1:numStats
ind=xx+numVal*(yy-1);
featStats(ind)=val(yy);
end
end
else
featStats=getFeatureStats(M);
end
end
features=[features featStats];
for st=1:numStats
for k=1:n
for kk=1:numGroups
featureNames=horzcat(featureNames,...
{[stats{st} 'PercentageClusters_G' num2str(kk) '_Surrounding_G' num2str(i)...
'_Neighborhood' num2str(k) ]});
end
end
end
end
end