Search in sources :

Example 21 with Cluster

use of org.apache.commons.math3.ml.clustering.Cluster in project ACManager by kun368.

the class MyTest2 method test6.

@Test
public void test6() throws Exception {
    Clusterer<DoublePoint> clusterer = new KMeansPlusPlusClusterer<DoublePoint>(3);
    List<DoublePoint> list = new ArrayList<>();
    list.add(new DoublePoint(new double[] { 1 }));
    list.add(new DoublePoint(new double[] { 1.5 }));
    list.add(new DoublePoint(new double[] { 1.8 }));
    list.add(new DoublePoint(new double[] { 3.5 }));
    list.add(new DoublePoint(new double[] { 3.6 }));
    list.add(new DoublePoint(new double[] { 4 }));
    list.add(new DoublePoint(new double[] { 4.2 }));
    System.out.println(list);
    List<? extends Cluster<DoublePoint>> res = clusterer.cluster(list);
    System.out.println("!!!");
    System.out.println(res.size());
    for (Cluster<DoublePoint> re : res) {
        System.out.println(re.getPoints());
    }
}
Also used : DoublePoint(org.apache.commons.math3.ml.clustering.DoublePoint) KMeansPlusPlusClusterer(org.apache.commons.math3.ml.clustering.KMeansPlusPlusClusterer) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)7 ClusterPoint (gdsc.core.clustering.ClusterPoint)5 Plot2 (ij.gui.Plot2)3 WeightedObservedPoint (org.apache.commons.math3.fitting.WeightedObservedPoint)3 PointValuePair (org.apache.commons.math3.optim.PointValuePair)3 Material (com.jme3.material.Material)2 ColorRGBA (com.jme3.math.ColorRGBA)2 Geometry (com.jme3.scene.Geometry)2 Mesh (com.jme3.scene.Mesh)2 Node (com.jme3.scene.Node)2 VertexBuffer (com.jme3.scene.VertexBuffer)2 TDoubleArrayList (gnu.trove.list.array.TDoubleArrayList)2 PrintWriter (java.io.PrintWriter)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2