Hi,
    I have created a JIRA issue for this suggestion:
 https://issues.apache.org/jira/projects/MATH/issues/MATH-1522

    I think the generic parameter on class "ClusterRanking" is unnecessary,
it is redundancy when define a variable, and hard to reuse(it could be):
```java
ClusterRanking<DoublePoint> evaluator = new SumOfClusterVariances<>();
List<Cluster<DoublePoint>> clusters1 = ...
evaluator.compute(clusters1); // It is OK.
...
// It could be reused globally, but now trigger a compile error
List<Cluster<MyClusterable>> clusters2 = ...
evaluator.compute(clusters2); // Compile error
```

The generic parameter of ClusterRanking can be move onto method:
```java
@FunctionalInterface
public interface ClusterRanking {
    /**
     * Computes the rank (higher is better).
     *
     * @param clusters Clusters to be evaluated.
     * @return the rank of the provided {@code clusters}.
     */
    <T extends Clusterable> double compute(List<? extends Cluster<T>> clusters);
}
```

Then we can define a ClusterRanking easier and reuse it globally:
```java
// The variable define is simple now.
ClusterRanking evaluator = new SumOfClusterVariances();
...
List<Cluster<DoublePoint>> clusters1 = ...
double score1 = evaluator.compute(clusters1); // OK.
...
// It can be reused globally now.
List<Cluster<MyClusterable>> clusters2 = ...
double score2 = evaluator.compute(clusters2); // OK.
```

Best regards,
Chentao

Reply via email to