Hello.
Le mer. 11 mars 2020 à 07:28, [email protected] <[email protected]> a écrit :
>
> Hi all,
> The "EmptyClusterStrategy" in KMeansPlusPlusClusterer can be reused
> MiniBatchKMeansClusterer and other cluster altorithm.
> So I think the "EmptyClusterStrategy" should move out from
> KMeansPlusPlusClusterer(JIRA issue #MATH-1525).
> I am not sure if my design is good or not.
I can't say either; please provide more context/explanation
about the excerpts below.
> I think here should be a interface:
>
> Solution 1: Explicit indicate the usage by class name and function name.
> ```java
> @FunctionalInterface
> public interface ClusterBreeder {
> <T extends Clusterable> T newCenterPoint((final
> Collection<CentroidCluster<T extends Clusterable>> clusters);
> }
What is a "Breeder"?
This seems to further complicates the matter; what is a "center" (if there
can be old and new ones).
Regards,
Gilles
> ...
> // Implementations
> public LargestVarianceClusterPointBreeder implements ClusterBreeder{...}
> public MostPopularClusterPointBreeder implements ClusterBreeder{...}
> public FarthestPointBreeder implements ClusterBreeder{...}
> ...
> // Usage
> // KMeansPlusPlusClusterer.java
> public class KMeansPlusPlusClusterer<T extends Clusterable> extends
> Clusterer<T> {
> ...
> private final ClusterBreeder clusterBreeder;
> public KMeansPlusPlusClusterer(final int k, final int maxIterations,
> final DistanceMeasure measure,
> final UniformRandomProvider random,
> final ClusterBreeder clusterBreeder) {
> ...
> this.clusterBreeder=clusterBreeder;
> }
> ...
> public List<CentroidCluster<T>> cluster(final Collection<T> points) {
> ...
> if (cluster.getPoints().isEmpty()) {
> if (clusterBreeder == null) {
> throw new
> ConvergenceException(LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS);
> } else {
> newCenter = clusterBreeder.newCenterPoint(clusters);
> }
> }
> ...
> }
> }
> ```
>
> Solution2: Declare a more generic interface:
> ```java
> @FunctionalInterface
> public interface ClustersPointFinder {
> <T extends Clusterable> T find((final Collection<CentroidCluster<T
> extends Clusterable>> clusters);
> }
>
> ...
> // Implementations
> public LargestVarianceClusterPointFinder implements ClustersPointFinder {...}
> public MostPopularClusterPointFinder implements ClustersPointFinder {...}
> public FarthestPointFinder implements ClustersPointFinder {...}
> ```
>
> Thanks,
> -CT
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]