|
16 | 16 | % Optional: min number of clusters |
17 | 17 | % max number of clusters |
18 | 18 | % 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 | + |
20 | 30 | % Iterations |
21 | 31 | min_num = 1; |
22 | 32 | max_num = 10; |
|
61 | 71 | test_set = []; |
62 | 72 | covering = []; |
63 | 73 |
|
64 | | - h = waitbar(0,'Loading...','Name','Clustering'); |
| 74 | + if WAITBAR |
| 75 | + h = waitbar(0,'Loading...','Name','Clustering'); |
| 76 | + end |
65 | 77 |
|
66 | 78 | for i = min_num:step:max_num |
67 | 79 | % original code |
|
98 | 110 | % see if we already have the data |
99 | 111 | fn = fullfile(output_path, sprintf('clustering_%d_%s.mat', n,a)); |
100 | 112 | 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 |
102 | 116 | 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 |
105 | 121 | [res, res1st] = classif.cluster_cross_validation(n, 'Folds', 10, 'TestSet', test_set); |
106 | 122 | save(fn, 'res', 'res1st'); |
107 | 123 | end |
|
116 | 132 | classif.two_stage = 1; |
117 | 133 | fn = fullfile(output_path, sprintf('clustering_all_%d_%s.mat', n,a)); |
118 | 134 | 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 |
120 | 138 | 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 |
123 | 143 | res = classif.cluster(n); |
124 | 144 | save(fn, 'res'); |
125 | 145 | end |
126 | 146 | res3 = [res3, res]; |
127 | 147 | covering = [covering, res.coverage(feature_length)]; |
128 | | - waitbar(i/max_num); |
| 148 | + if WAITBAR |
| 149 | + waitbar(i/max_num); |
| 150 | + end |
129 | 151 | end |
130 | 152 |
|
131 | 153 | % remap the classes as to not invalidate mixed clusters |
|
152 | 174 | varargout{6} = res3; |
153 | 175 | varargout{7} = covering; |
154 | 176 | end |
155 | | - delete(h); |
| 177 | + if WAITBAR |
| 178 | + delete(h); |
| 179 | + end |
156 | 180 | end |
0 commit comments