From 45a48e4737cc5bd7f5b117cb61d261c52e1634d2 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Mon, 8 Jun 2015 20:28:08 -0300 Subject: Fixed silhouette coefficient calculation. --- measures.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'measures.R') 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) { -- cgit v1.2.3