Compute the compactness validity index for a clustering result.
a dataset with rows as observations, columns as variables
a vector of cluster labels from a clustering result
the compactness score
This index is agnostic to any reference clustering results, calculating cluster performance on the basis of compactness and separability. Smaller values indicate a better clustering structure.
valid_compactness by Simon Garrett in