-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathd2_clustering.m
45 lines (32 loc) · 1.06 KB
/
d2_clustering.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
%clear;
numOfSamples = 5000;
if ~exist('numOfSamples')
numOfSamples = 50;
end
setparam;
%% Load data
fprintf(stdoutput, 'Loading data ... ');
s_modalities = 2;
d_modalities = [3, 3];
filename='../total.txt';
db = loaddata(numOfSamples, s_modalities, d_modalities, filename);
%%
global statusIterRec;
max_stride = max(cellfun(@(x) max(x.stride), db));
kantorovich_prepare(max_stride);
matlabpool('open', num_of_cores); % start parallel workers
[clusters, labels] = d2clusters(db, 6);
matlabpool('close');
save clusters.dat clusters IDX labels
n = size(statusIterRec,1);
%h = figure;
%plot((1:n)', statusIterRec(:,1),'-or', ...
% (1:n)', statusIterRec(:,2),'-dg', ...
% (1:n)', statusIterRec(:,3),'-+b');
%plot((1:n)', statusIterRec(:,1),'-or', ...
% (1:n)', statusIterRec(:,2),'-dg');
%err = sqrt(kantorovich(bufferc{1}.supp, bufferc{1}.w, bufferc{2}.supp, bufferc{2}.w)) ...
% /norm(bufferc{2}.supp,'fro');
%print(h, '-dpdf', ['centroid_sphALL' num2str(numOfSamples) '.pdf']);
fprintf('%d %d %f %f', numOfSamples, num_of_cores, ctime(1), ctime(2));
%err