-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNe_count.m
More file actions
89 lines (70 loc) · 2.17 KB
/
Ne_count.m
File metadata and controls
89 lines (70 loc) · 2.17 KB
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
77
78
79
80
81
82
83
84
85
86
87
% Calculate N_e numbers under different distance measures and kernels as shown in Figure 1(c)(d), Table 1 and Figure 4
clear
load('Gaussians.mat'); % please unzip Gaussians under "Clustering and Indexing datasets"
load('nGaussians.mat');
% adding query points
data(2000,:)=[];
class(2000,:)=[];
data=[data;nd];
class=[class;nc];
gscatter(data(:,1),data(:,2),class,'rgb');
d=10000; % d=10 or 10000
data=data(:,1:d);
e=0.005; % Calculate the ratio of the circle radius to the distance to the nearest point
%% IK
t=1000;
psi=32;
dis=pdist2(data,data,'minkowski',0.5);
dis=dis./max(max(dis));
num=0;
n = 10; % repeat times
for i = 1:n
[ ~, proximity ] = aNNE (dis, psi, t); % data dependent IK
% [ ~, proximity ] = UaNNE (data, psi, t); % data independent IK
dis_anne = 1 - proximity;
% spa=dis_anne(end,1:1999); % Query point is in the center of sparse cluster
% den=dis_anne(end-1,1:1999); % Query point is in the center of dense cluster
cen=dis_anne(end-2,1:1999); % Query point is between 2 clusters
ls = min(cen)*(1+e); % cen can be replaced with den or spa
num = num+sum(cen<ls); % cen can be replaced with den or spa
end
num = num/n;
%% Linear Kernel
% LK = Linear1(data);
% cen=LK(end-2,1:1999); % Query point is between 2 clusters
% %spa=LK(end,1:1999); Query point is in the center of sparse cluster
% %den=LK(end-1,1:1999); % Query point is in the center of dense cluster
% ls = min(cen)*(1+e); % cen can be replaced with den or spa
% num = sum(cen<ls);
%% Gaussian Kernel
% sigma=5;
% Gadis = Gaussian1(data, sigma);
% cen=Gadis(end-2,1:1999);
% %spa=Gadis(end,1:1999);
% ls = min(cen)*(1+e);
% num = sum(cen<ls);
%% AG
% k=ceil(0.1*size(data,1));
% AG = KNN_AdaptiveGaussian1(data, k, 0.1);
% AG=AG./max(max(AG));
% cen=AG(end-2,1:1999);
% %spa=AG(end,1:1999);
% ls = min(cen)*(1+e);
% num = sum(cen<ls);
%% SNN
% % k=ceil(size(data,1)*0.7);
% k = 1200;
% [~,S] = JSNN(data,k, 0.5);
% S=1-S;
% S=normalize(S);
% cen=S(end-2,1:1999);
% %spa=S(end,1:1999);
% ls = min(cen)*(1+e);
% num = sum(cen<ls);
%% lp
% p=0.1; %p=0.1,0.5 & 2
% dis=pdist2(data,data,'minkowski',p);
% cen=dis(end-2 ,1:1999);
% %spa=S(end,1:1999);
% ls = min(cen)*(1+e);
% num = sum(cen<ls);