[10] | 1 | %GOFCL Goodness of clusters/classes separability vs compactness |
---|
| 2 | %
|
---|
| 3 | % J = GOFCL(D)
|
---|
| 4 | %
|
---|
| 5 | % INPUT
|
---|
| 6 | % D NxN Dissimilarity dataset
|
---|
| 7 | %
|
---|
| 8 | % OUTPUT
|
---|
| 9 | % J Criterion value |
---|
| 10 | %
|
---|
| 11 | % DESCRIPTION
|
---|
| 12 | % Computes a goodness of clusters/classes in an NxN dissimilarity dataset D. |
---|
| 13 | % D is labeled. The criterion provides a trade-off between the cluster/class |
---|
| 14 | % compactness and cluster/class separability. Consider K classes, with the total |
---|
| 15 | % numbr of objects N and N_i elements in the i-th class. Let A_ij be the average |
---|
| 16 | % dissimilarity between the i-th and j-th clusters. Then the criterion is computed |
---|
| 17 | % as: |
---|
| 18 | % J = sum_i (n_i sum_{j neq i} N_i/(N-N_i) A_ij) / (2 sum_i n_i A_ii ) |
---|
| 19 | % |
---|
| 20 | % The larger value, the better the separability between the classes. |
---|
| 21 | % |
---|
| 22 | % EXAMPLE |
---|
| 23 | % Compare: |
---|
| 24 | % 1) rand('seed',37); randn('seed',37); a=gendats(40,2,1); d=sqrt(distm(a)); |
---|
| 25 | % scatterd(a); j1 = gofcl(d); |
---|
| 26 | % 2) rand('seed',37); randn('seed',37); a=gendats(40,2,7); d=sqrt(distm(a)); |
---|
| 27 | % scatterd(a); j2 = gofcl(d); |
---|
| 28 | |
---|
| 29 |
|
---|
| 30 | % Copyright: Elzbieta Pekalska, ela.pekalska@googlemail.com
|
---|
| 31 | % Faculty EWI, Delft University of Technology and
|
---|
| 32 | % School of Computer Science, University of Manchester
|
---|
| 33 |
|
---|
| 34 | function J = gofcl(d); |
---|
| 35 | |
---|
| 36 | issym(d); |
---|
| 37 | lab = getnlab(d); |
---|
| 38 | cc = max(lab); |
---|
| 39 | |
---|
| 40 | for i=1:cc |
---|
| 41 | Z = find(lab == i); |
---|
| 42 | dw(i) = mean(mean(d(Z,Z))); |
---|
| 43 | for j=i+1:cc |
---|
| 44 | ZZ = find(lab == j); |
---|
| 45 | db(i,j) = mean(mean(d(Z,ZZ))); |
---|
| 46 | db(j,i) = mean(mean(d(Z,ZZ))); |
---|
| 47 | end |
---|
| 48 | end |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | J = 0; |
---|
| 52 | for i=1:cc |
---|
| 53 | for j=i+1:cc |
---|
| 54 | J = J + db(i,j)/((dw(i)+dw(j))); |
---|
| 55 | end |
---|
| 56 | end |
---|
| 57 | J = J /((cc-1)*cc); |
---|