Package com.github.pmerienne.trident.ml.clustering

Examples of com.github.pmerienne.trident.ml.clustering.KMeans


public class KMeansTest extends ClustererTest {

  @Test
  public void testAgainstGaussianInstances() {
    int nbCluster = 5;
    KMeans kMeans = new KMeans(nbCluster);
    List<Instance<Integer>> samples = Datasets.generateDataForClusterization(nbCluster, 5000);

    double randIndex = this.eval(kMeans, samples);
    assertTrue("RAND index " + randIndex + "  isn't good enough : ", randIndex > 0.80);
  }
View Full Code Here


    assertTrue("RAND index " + randIndex + "  isn't good enough : ", randIndex > 0.80);
  }

  @Test
  public void testAgainstRealDataset() {
    KMeans kMeans = new KMeans(7);
    double randIndex = this.eval(kMeans, Datasets.getClusteringSamples());
    assertTrue("RAND index " + randIndex + "  isn't good enough : ", randIndex > 0.70);
  }
View Full Code Here

        // Convert trident tuple to instance
        .each(new Fields("label", "x0", "x1", "x2"), new InstanceCreator<Integer>(), new Fields("instance"))

        // Update a 3 classes kmeans
        .partitionPersist(new MemoryMapState.Factory(), new Fields("instance"), new ClusterUpdater("kmeans", new KMeans(3)));

      // Cluster stream
      toppology.newDRPCStream("predict", localDRPC)
        // Convert DRPC args to instance
        .each(new Fields("args"), new DRPCArgsToInstance(), new Fields("instance"))
View Full Code Here

TOP

Related Classes of com.github.pmerienne.trident.ml.clustering.KMeans

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.