-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCVDD.m
58 lines (56 loc) · 1.79 KB
/
CVDD.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
% -------------------------------------------------------------------------
%Aim: The matlab code of "An internal validity index based on density-involved distance"
%Algorithm 1: CVDD
% -------------------------------------------------------------------------
%Input:
%pi: the partition of X
%d: the Euclidean distance between objects in X
% -------------------------------------------------------------------------
%Output:
%results: the CVDD index of pi
% -------------------------------------------------------------------------
% Written by Lianyu Hu
% Department of Computer Science, Ningbo University
% February 2019
% function CVDD = CVDD_DDDE(pi,X, d)
function CVDD = CVDD(pi,d,DD)
% %% compute the density-involved distance, K=7
% try
% DD = DDDE_involved_distance(X, d, K);
% DD_erro = 0;
% catch
% DD_erro = 1;
% end
% if DD_erro~=1
%% initialization
NC = length(unique(pi));
sc_list = zeros(NC,1); %separation
com_list = zeros(NC,1);%compactness
%%
for i = 1: NC
a = find(pi == i);
b = pi ~= i;
n = length(a);
if isempty(a)~=1
%% compute the separation sep[i]
sc_list(i,1) = min(min(DD(a,b)));
%% compute the compactness com[i]
try
Ci = fast_PathbasedDist(d(a,a));
com_list(i,1) = (std2(Ci)/n)*mean(Ci(:));
catch
com_list(i,1) = max(com_list);
end
else
sc_list(i,1)=0;
com_list(i,1) = max(com_list);
end
end
%% compute the validity index CVDD
sep = sum(sc_list);
com = sum(com_list);
CVDD = sep/com;
% else
% CVDD = 0;
% end
end