Revert to semantics mandated by "ClusterRanking" (higher is better).

This commit is contained in:
Gilles Sadowski 2020-03-10 19:23:45 +01:00
parent af5ad16a06
commit 484b0e740a
1 changed files with 5 additions and 6 deletions

View File

@ -29,8 +29,8 @@ public interface ClusterEvaluator {
/** /**
* @param a Score computed by this evaluator. * @param a Score computed by this evaluator.
* @param b Score computed by this evaluator. * @param b Score computed by this evaluator.
* @return true if the evaluator considers score {@code a} is * @return {@code true} if the evaluator considers that score
* considered better than score {@code b}. * {@code a} is better than score {@code b}.
*/ */
boolean isBetterScore(double a, double b); boolean isBetterScore(double a, double b);
@ -42,9 +42,8 @@ public interface ClusterEvaluator {
* @return a ranking function. * @return a ranking function.
*/ */
static <T extends Clusterable> ClusterRanking ranking(ClusterEvaluator eval) { static <T extends Clusterable> ClusterRanking ranking(ClusterEvaluator eval) {
return clusters -> { return eval.isBetterScore(1, 2) ?
double score = eval.score(clusters); clusters -> 1 / eval.score(clusters) :
return eval.isBetterScore(1, 2) ? score : 1 / score; clusters -> eval.score(clusters);
};
} }
} }