aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Fadel <samuelfadel@gmail.com>2015-06-08 20:28:08 -0300
committerSamuel Fadel <samuelfadel@gmail.com>2015-06-08 20:28:08 -0300
commit45a48e4737cc5bd7f5b117cb61d261c52e1634d2 (patch)
tree3e03beaf96ac328944150f9bdd0281dfea425354
parent945d4517d9a86c889ae5f887dd20d1ebedd862f7 (diff)
Fixed silhouette coefficient calculation.
-rw-r--r--measures.R4
1 files changed, 2 insertions, 2 deletions
diff --git a/measures.R b/measures.R
index 1b9128f..99aa4df 100644
--- a/measures.R
+++ b/measures.R
@@ -65,11 +65,11 @@ silhouette <- function(Dy, labels) {
for (i in 1:n) {
label <- labels[i]
- cohesion[i] <- mean(Dy[i, labels[-i] == label])
separation[i] <- min(Dy[i, labels != label])
+ cohesion[i] <- mean(Dy[i, labels[-i] == label])
}
- silh <- (cohesion - separation) / max(cohesion, separation)
+ silh <- (separation - cohesion) / max(separation, cohesion)
}
d2p <- function(D, perplexity = 9, tol = 1e-5, max.tries = 50) {