You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2020/03/10 18:36:12 UTC

[commons-math] 04/06: Revert to semantics mandated by "ClusterRanking" (higher is better).

This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git

commit 484b0e740a17622368983cd4327f2669629ee09b
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Tue Mar 10 19:23:45 2020 +0100

    Revert to semantics mandated by "ClusterRanking" (higher is better).
---
 .../apache/commons/math4/ml/clustering/ClusterEvaluator.java  | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/math4/ml/clustering/ClusterEvaluator.java b/src/main/java/org/apache/commons/math4/ml/clustering/ClusterEvaluator.java
index 694b273..ce50bdf 100644
--- a/src/main/java/org/apache/commons/math4/ml/clustering/ClusterEvaluator.java
+++ b/src/main/java/org/apache/commons/math4/ml/clustering/ClusterEvaluator.java
@@ -29,8 +29,8 @@ public interface ClusterEvaluator {
     /**
      * @param a Score computed by this evaluator.
      * @param b Score computed by this evaluator.
-     * @return true if the evaluator considers score {@code a} is
-     * considered better than score {@code b}.
+     * @return {@code true} if the evaluator considers that score
+     * {@code a} is better than score {@code b}.
      */
     boolean isBetterScore(double a, double b);
 
@@ -42,9 +42,8 @@ public interface ClusterEvaluator {
      * @return a ranking function.
      */
     static <T extends Clusterable> ClusterRanking ranking(ClusterEvaluator eval) {
-        return clusters -> {
-            double score = eval.score(clusters);
-            return eval.isBetterScore(1, 2) ? score : 1 / score;
-        };
+        return eval.isBetterScore(1, 2) ?
+            clusters -> 1 / eval.score(clusters) :
+            clusters -> eval.score(clusters);
     }
 }