@Test public void testGetMostPopulatedClusters() { ClusterSet clusterSet = new ClusterSet(false); List<Cluster> clusters = new ArrayList<>(); for (int i = 0; i < 5; i++) { Cluster cluster = new Cluster(); cluster.setPoints(Point.toPoints(Nd4j.randn(i + 1, 5))); clusters.add(cluster); } clusterSet.setClusters(clusters); List<Cluster> mostPopulatedClusters = clusterSet.getMostPopulatedClusters(5); for (int i = 0; i < 5; i++) { Assert.assertEquals(5 - i, mostPopulatedClusters.get(i).getPoints().size()); } }
public List<Cluster> getMostPopulatedClusters(int count) { List<Cluster> mostPopulated = new ArrayList<>(clusters); Collections.sort(mostPopulated, new Comparator<Cluster>() { public int compare(Cluster o1, Cluster o2) { return Integer.compare(o2.getPoints().size(), o1.getPoints().size()); } }); return mostPopulated.subList(0, count); }
ClusterSet implements Serializable { public List<Cluster> getMostPopulatedClusters(int count) { List<Cluster> mostPopulated = new ArrayList<>(clusters); Collections.sort(mostPopulated, new Comparator<Cluster>() { public int compare(Cluster o1, Cluster o2) { return Integer.compare(o2.getPoints().size(), o1.getPoints().size()); } }); return mostPopulated.subList(0, count); } }
ClusterSet implements Serializable { public List<Cluster> getMostPopulatedClusters(int count) { List<Cluster> mostPopulated = new ArrayList<>(clusters); Collections.sort(mostPopulated, new Comparator<Cluster>() { public int compare(Cluster o1, Cluster o2) { return Integer.compare(o2.getPoints().size(), o1.getPoints().size()); } }); return mostPopulated.subList(0, count); } ClusterSet(boolean inverse);  ClusterSet(Distance distanceFunction, boolean inverse, long[] shape); }
ClusterSet implements Serializable { public List<Cluster> getMostPopulatedClusters(int count) { List<Cluster> mostPopulated = new ArrayList<>(clusters); Collections.sort(mostPopulated, new Comparator<Cluster>() { public int compare(Cluster o1, Cluster o2) { return Integer.compare(o2.getPoints().size(), o1.getPoints().size()); } }); return mostPopulated.subList(0, count); } ClusterSet(boolean inverse);  ClusterSet(Distance distanceFunction, boolean inverse, long[] shape); boolean isInverse(); Cluster addNewClusterWithCenter(Point center); PointClassification classifyPoint(Point point); void classifyPoints(List<Point> points); void classifyPoints(List<Point> points, boolean moveClusterCenter); PointClassification classifyPoint(Point point, boolean moveClusterCenter); Pair<Cluster, Double> nearestCluster(Point point); double getDistance(Point m1, Point m2); String getClusterCenterId(String clusterId); Point getClusterCenter(String clusterId); Cluster getCluster(String id); int getClusterCount(); void removePoints(); List<Cluster> getMostPopulatedClusters(int count); List<Cluster> removeEmptyClusters(); }
ClusterSet implements Serializable { public List<Cluster> getMostPopulatedClusters(int count) { List<Cluster> mostPopulated = new ArrayList<>(clusters); Collections.sort(mostPopulated, new Comparator<Cluster>() { public int compare(Cluster o1, Cluster o2) { return Integer.compare(o2.getPoints().size(), o1.getPoints().size()); } }); return mostPopulated.subList(0, count); } ClusterSet(boolean inverse);  ClusterSet(Distance distanceFunction, boolean inverse, long[] shape); boolean isInverse(); Cluster addNewClusterWithCenter(Point center); PointClassification classifyPoint(Point point); void classifyPoints(List<Point> points); void classifyPoints(List<Point> points, boolean moveClusterCenter); PointClassification classifyPoint(Point point, boolean moveClusterCenter); Pair<Cluster, Double> nearestCluster(Point point); double getDistance(Point m1, Point m2); String getClusterCenterId(String clusterId); Point getClusterCenter(String clusterId); Cluster getCluster(String id); int getClusterCount(); void removePoints(); List<Cluster> getMostPopulatedClusters(int count); List<Cluster> removeEmptyClusters();  }