-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheucledian.m
66 lines (54 loc) · 1.35 KB
/
eucledian.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
X=csvread('C:\Users\Devanshu\OneDrive\Data Mining\HW3\onlydata.csv');
a=zeros(99,1);
s=zeros(99,1);
d=zeros(99,1);
for k = 2:100
[idx,C,sumd,D] = kmeans(X,k,'Options',statset('UseParallel',1),'MaxIter',1000,'Replicates',10);
incluster = zeros(k,1);
betweencluster = zeros(k,1);
count = zeros(k,1);
%Incluster similarity
for j = 1:176
i = idx(j);
for m = 1:176
if (j~=m)
temp = pdist2(X(j),X(m));
incluster(i)=incluster(i)+temp;
count(i)=count(i)+1;
end
end
end
for i = 1:k
incluster(i)=incluster(i)/count(i);
%fprintf('%16.f',incluster(i));
%disp(incluster(i));
end
s(k) = sum(incluster)/(k-1);
%Between Cluster
for j = 1:k
for m = 1:k
if (j~=m)
temp = pdist2(C(j),C(m));
betweencluster(j)=betweencluster(j)+temp;
end
end
end
for i = 1:k
incluster(i)=incluster(i)/(k-1);
%fprintf('%16.f',incluster(i));
%sdisp(incluster(i));
end
d(k) = sum(betweencluster)/(k-1);
%disp('S : ');
disp(s(k));
%disp('D :');
disp(d(k));
a(k)=s(k)/d(k);
end
disp('Eucledian');
plot(s);
saveas(gcf,'eucledian_s.jpg');
plot(d);
saveas(gcf,'eucledian_d.jpg');
plot(a);
saveas(gcf,'eucledian_a.jpg');