Skip to content

Commit 2e93961

Browse files
committed
fixes
1 parent 327bf6f commit 2e93961

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

clustering/cross_validation/results_clustering_parameters.m

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@
1616
% Optional: min number of clusters
1717
% max number of clusters
1818
% increment
19-
19+
20+
WAITBAR = 1;
21+
DISPLAY = 1;
22+
for i = 1:length(varargin)
23+
if isequal(varargin{i},'WAITBAR')
24+
WAITBAR = varargin{i+1};
25+
elseif isequal(varargin{i},'DISPLAY')
26+
DISPLAY = varargin{i+1};
27+
end
28+
end
29+
2030
% Iterations
2131
min_num = 1;
2232
max_num = 10;
@@ -61,7 +71,9 @@
6171
test_set = [];
6272
covering = [];
6373

64-
h = waitbar(0,'Loading...','Name','Clustering');
74+
if WAITBAR
75+
h = waitbar(0,'Loading...','Name','Clustering');
76+
end
6577

6678
for i = min_num:step:max_num
6779
% original code
@@ -98,10 +110,14 @@
98110
% see if we already have the data
99111
fn = fullfile(output_path, sprintf('clustering_%d_%s.mat', n,a));
100112
if exist(fn ,'file')
101-
fprintf('\nData for %d number of clusters (two-phase clustering) found. Loading data...\n', n);
113+
if DISPLAY
114+
fprintf('\nData for %d number of clusters (two-phase clustering) found. Loading data...\n', n);
115+
end
102116
load(fn);
103-
else
104-
fprintf('\nData for %d number of clusters (two-phase clustering) not found. Computing...\n', n);
117+
else
118+
if DISPLAY
119+
fprintf('\nData for %d number of clusters (two-phase clustering) not found. Computing...\n', n);
120+
end
105121
[res, res1st] = classif.cluster_cross_validation(n, 'Folds', 10, 'TestSet', test_set);
106122
save(fn, 'res', 'res1st');
107123
end
@@ -116,16 +132,22 @@
116132
classif.two_stage = 1;
117133
fn = fullfile(output_path, sprintf('clustering_all_%d_%s.mat', n,a));
118134
if exist(fn ,'file')
119-
fprintf('\nData for %d number of clusters (clustering using all the constraints) found. Loading data...\n', n);
135+
if DISPLAY
136+
fprintf('\nData for %d number of clusters (clustering using all the constraints) found. Loading data...\n', n);
137+
end
120138
load(fn);
121-
else
122-
fprintf('\nData for %d number of clusters (clustering using all the constraints) not found. Computing...\n', n);
139+
else
140+
if DISPLAY
141+
fprintf('\nData for %d number of clusters (clustering using all the constraints) not found. Computing...\n', n);
142+
end
123143
res = classif.cluster(n);
124144
save(fn, 'res');
125145
end
126146
res3 = [res3, res];
127147
covering = [covering, res.coverage(feature_length)];
128-
waitbar(i/max_num);
148+
if WAITBAR
149+
waitbar(i/max_num);
150+
end
129151
end
130152

131153
% remap the classes as to not invalidate mixed clusters
@@ -152,5 +174,7 @@
152174
varargout{6} = res3;
153175
varargout{7} = covering;
154176
end
155-
delete(h);
177+
if WAITBAR
178+
delete(h);
179+
end
156180
end

demo.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ function demo(set,user_path,varargin)
177177
data = data(:,[1,2,5]);
178178
cvErr = find(data(:,3) < 25);
179179
num_clusters = data(cvErr,1);
180-
error = execute_classification(project_path,sfiles(j).name,lfiles(i).name,num_clusters,varargin);
180+
error = execute_classification(project_path,sfiles(j).name,lfiles(i).name,num_clusters,varargin{:});
181181
end
182182
end
183183
end
@@ -326,7 +326,7 @@ function demo(set,user_path,varargin)
326326
if ~exist(output_path,'dir')
327327
mkdir(output_path);
328328
end
329-
[nc,res1bare,res2bare,res1,res2,res3,covering] = results_clustering_parameters(segmentation_configs,fullfile(project_path,'labels',lab_name(i).name),0,output_path,10,100,10);
329+
[nc,res1bare,res2bare,res1,res2,res3,covering] = results_clustering_parameters(segmentation_configs,fullfile(project_path,'labels',lab_name(i).name),0,output_path,10,100,10,'WAITBAR', WAITBAR, 'DISPLAY', DISPLAY);
330330
output_path = char(fullfile(project_path,'results',strcat(p,'_cross_validation')));
331331
if exist(output_path,'dir');
332332
rmdir(output_path,'s');

0 commit comments

Comments
 (0)