forked from sckangz/LMVSC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runlmv.m
55 lines (38 loc) · 1.44 KB
/
runlmv.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
% This code runs the LMVSC algorithm on Caltech7 dataset and records its
% performance. The results are output in *.txt format.
% Notice: The dataset is organized in a cell array with each element being
% a view. Each view is represented by a matrix, each row of which is a
% sample.
% The core of LMVSC is encapsulated in an independent matlab function.
% Visit lmv.m directly, if you want to learn the details of its
% implementation.
clear;
addpath('./datasets');
load('Caltech101-7.mat');
X=data;
y=labels;
nv=length(X);
ns=length(unique(y));
% Parameter 1: number of anchors (tunable)
numanchor=[ns 50 100];
% Parameter 2: alpha (tunable)
alpha=[.01 1 100];
for j=1:length(numanchor)
% Perform K-Means on each view
parfor i=1:nv
rand('twister',5489);
[~, H{i}] = litekmeans(X{i},numanchor(j),'MaxIter', 100,'Replicates',10);
end
for i=1:length(alpha)
fprintf('params:\tnumanchor=%d\t\talpha=%f\n',numanchor(j),alpha(i));
tic;
% Core part of this code (LMVSC)
[F,ids] = lmv(X',y,H,alpha(i));
% Performance evaluation of clustering result
result=ClusteringMeasure(ids,y);
t=toc;
fprintf('result:\t%12.6f %12.6f %12.6f %12.6f\n',[result t]);
% Write the evaluation results to a text file
dlmwrite('Caltech.txt',[alpha(i) numanchor(j) result t],'-append','delimiter','\t','newline','pc');
end
end