-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_serum.m
76 lines (70 loc) · 2.09 KB
/
demo_serum.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
% The code is written by Jie Wen,
% if you have any problems, please don't hesitate to contact me: wenjie@hrbeu.edu.cn
% If you find the code is useful, please cite the following reference:
% Jie Wen , Xiaozhao Fang, Yong Xu, Chunwei Tian, Lunke Fei,
% Low-Rank Representation with Adaptive Graph Regularization [J],
% Neural Networks, 2018.
% homepage: https://sites.google.com/view/jerry-wen-hit/home
clear all
clc
clear memory;
load('newIdea_spo.mat')
% %name = 'newIdea_spo';
data=spo_fea;
selected_class = 6;
lambda1 = 1e-4;
lambda2 = 1e-2;
lambda3 = 1e-1;
%
% %load(name)
% fea = double(data);
nnClass = 6; % The number of classes
% select_sample = [];
% % select_gnd = [];
% % for i = 1:selected_class
% % idx = find(gnd == i);
% % idx_sample = fea(idx,:);
% % select_sample = [select_sample;idx_sample];
% % %select_gnd = [select_gnd;gnd(idx)];
% % end
%
fea = data';
%fea = fea';
fea = fea./repmat(sqrt(sum(fea.^2)),[size(fea,1) 1]);
%gnd = select_gnd;
c = selected_class;
X = fea;
clear fea select_gnd select_sample idx
[m,n] = size(X);
% ---------- initilization for Z and F -------- %
options = [];
options.NeighborMode = 'KNN';
options.k = 10;
options.WeightMode = 'Binary'; % Binary HeatKernel
Z = constructW(X',options);
Z = full(Z);
Z1 = Z-diag(diag(Z));
Z = (Z1+Z1')/2;
DZ= diag(sum(Z));
LZ = DZ - Z;
[F_ini, ~, evs]=eig1(LZ, c, 0);
Z_ini = Z;
clear LZ DZ Z fea Z1
max_iter= 80;
Ctg = inv(X'*X+2*eye(size(X,2)));
%这里得到F预测,但是并没有这个而是对Z进行的Ncut
[Z,S,U,F,E] = LRR_AGR(X,F_ini,Z_ini,c,lambda1,lambda2,lambda3,max_iter,Ctg);
%% 下面用的是Ncut(把得到的Z进行谱聚类)
addpath('Ncut_9');
% Z2=spo_fea
c=6
Z_out = Z;
A = Z_out;
A = A - diag(diag(A));
A = (A+A')/2;
[NcutDiscrete,NcutEigenvectors,NcutEigenvalues] = ncutW(A,c);
%result_label 是Ncut的 结果
[value,result_label] = max(NcutDiscrete,[],2);
Sil = silhouette(data,result_label);%轮廓系数应该是对原始数据的!!!
Sil = mean(Sil)
%result = ClusteringMeasure(gnd, result_label) %result = [ACC MIhat Purity];