From 46bea19f69cf95004e64a7767a8c85dc591cabda Mon Sep 17 00:00:00 2001 From: Igor Date: Fri, 13 Apr 2018 11:40:39 +0300 Subject: [PATCH] Fix error in silhouette calculation According to the book, it's (b-a)/max(a, b), but without else statement it would be added twice when a > b This also slightly changes the resulting value for this example, but not much (0.508 becomes 0.517) --- Chapter06/evaluating/example2/myprogram.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Chapter06/evaluating/example2/myprogram.go b/Chapter06/evaluating/example2/myprogram.go index 4b55e70..1b6f3ac 100644 --- a/Chapter06/evaluating/example2/myprogram.go +++ b/Chapter06/evaluating/example2/myprogram.go @@ -135,8 +135,9 @@ func main() { // Add to the average silhouette coefficient. if a > b { silhouette += ((b - a) / a) / float64(len(labels)) + } else { + silhouette += ((b - a) / b) / float64(len(labels)) } - silhouette += ((b - a) / b) / float64(len(labels)) } // Output the final average silhouette coeffcient to stdout.