package univ.ml.sparse;

import com.google.common.collect.Lists;
import univ.ml.sparse.algorithm.SparseCoresetAlgorithm;

import java.util.List;
import java.util.stream.Collectors;

public class SparseCoresetEvaluator {

    private final SparseWeightedKMeansPlusPlus clusterer;

    private final SparseWSSE costFunction = new SparseWSSE();

    public SparseCoresetEvaluator(final SparseWeightedKMeansPlusPlus clusterer) {
        this.clusterer = clusterer;
    }

    public double evalute(final SparseCoresetAlgorithm algorithm, final List<SparseWeightableVector> pointSet) {
        final List<SparseCentroidCluster> clusters = clusterer.cluster(algorithm.takeSample(pointSet));

        final List<SparseWeightableVector> centers = Lists.newArrayList();

        for (SparseCentroidCluster cluster : clusters) {
            centers.add(new SparseWeightableVector(cluster.getCenter().getVector(), 1));
        }

        return costFunction.getCost(centers, pointSet);
    }

}

@@ -29,41 +29,25 @@
 ort 
-com.google.common.collect
+java.util
 .List
-s
 ;%0A
+%0A
 impo
@@ -110,57 +110,38 @@
 ort 
-java.util.List;%0Aimport java.util.stream.C
+com.google.common.c
 ollect
-or
+.List
 s;%0A%0A

remove dependency on java 8