-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuse_single_rnse.m
42 lines (38 loc) · 1.28 KB
/
use_single_rnse.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
function [ result_all ] = use_single_rnse( name,roundtime )
%USE_SINGLE_RNSE
%This function would run RNSE roundtime times on the dataset with the 'name' inputed.
%Output is mean and std of acc, NMI and purity.
%get data
data_name=name
[data,gt]=data_fetch(name);
gt=gt-(min(gt));
cluster_num= length(unique(gt))
%data get part end
times10 = zeros(roundtime,3);
for j=1:roundtime
[ la,s,p ] = RNSE( data,cluster_num,1e0,1e0);%call RNSE. la is the label output by RNSE, s is the similarity matrix, p is the indicator matrix.
la=la-(min(la));
result = ClusteringMeasure(double(gt), double(la));%call ClusteringMeasure.calculate acc NMI and purity
times10(j,:) = result;
end
all_acc=times10(:,1);
all_nmi=times10(:,2);
all_purity=times10(:,3);
acc=mean(all_acc);
nmi=mean(all_nmi);
purity=mean(all_purity);
std_acc=std(all_acc);
std_nmi=std(all_nmi);
std_purity=std(all_purity);
label_old=la;
result_all=zeros(3,2);
result_all(1,1)=acc;
result_all(1,2)=std_acc;
result_all(2,1)=nmi;
result_all(2,2)=std_nmi;
result_all(3,1)=purity;
result_all(3,2)=std_purity;
save_pa=['rnse_test_result/',name];
save_path=[save_pa,'.mat'];%save result in rnse_test_result
save(save_path,'all_acc','all_nmi','all_purity','acc','nmi','purity','std_acc','std_nmi','std_purity','label_old','s','p')
end