-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSS_IdentifyBestOps.m
55 lines (40 loc) · 1.57 KB
/
SS_IdentifyBestOps.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
function SS_OutputBestOpsTxtFile
load('run_options.mat');
load('HCTSA_N.mat');
load('linkage_clusters_with_member_corrs.mat');
fprintf('Saving clustering information to %s \n',outTxtFileName);
fID = fopen(outTxtFileName,'w');
fprintf(fID,['Output from kmedoids clustering (k = %i) followed by ',...
'linkage clustering (corr_dist_threshold = %f)\n\n'],kmedoidsClusters.k,corr_dist_threshold);
autoChosenOps = [];
autoChosenIdxs = [];
for i = 1:length(linkageClusters)
dists = linkageClusters(i).memDists;
mems = linkageClusters(i).memIdxs;
kmedCentres = linkageClusters(i).kmedCentres;
ops = Operations(mems);
% Sort by increasing distance
[sortedDists sortIdx] = sort(dists);
sortedMems = mems(sortIdx);
sortedOps = ops(sortIdx);
kmCentreOps = Operations(kmedoidsClusters.CCi(kmedCentres));
kmCentreNames = {kmCentreOps.Name};
kmCentreKeys = {kmCentreOps.Keywords};
% Print all centres associated with cluster
fprintf(fID,'CLUSTER %i: ',i);
for j = 1:length(kmCentreNames)
fprintf(fID,'%s (%s), ',kmCentreNames{j},kmCentreKeys{j});
end
fprintf(fID,'\n');
% Print top 10 operations highly correlated with cluster centre
for j = 1:min(length(sortedOps),10)
fprintf(fID,'(%f) %s - %s\n',1-sortedDists(j),sortedOps(j).Name,...
sortedOps(j).Keywords);
end
autoChosenOps = [autoChosenOps sortedOps(1)];
autoChosenIdxs = [autoChosenIdxs sortedMems(1)];
fprintf(fID,'\n');
end
fclose(fID);
save('auto_chosen_ops.mat','autoChosenOps','autoChosenIdxs');
end