Package org.apache.mahout.clustering.dirichlet.models

Examples of org.apache.mahout.clustering.dirichlet.models.GaussianClusterDistribution


    for (Vector sd : sampleData) {
      points.add(new VectorWritable(sd));
    }

    DirichletClusterer dc = new DirichletClusterer(points,
        new GaussianClusterDistribution(new VectorWritable(
            new DenseVector(2))), 1.0, 10, 2, 2);
    List<Cluster[]> result = dc.cluster(20);
    for (Cluster cluster : result.get(result.size() - 1)) {
      System.out.println("Cluster id: " + cluster.getId() + " center: "
          + cluster.getCenter().asFormatString());
View Full Code Here


  }

  @Test
  public void testDirichlet() throws Exception {
    ClusteringTestUtils.writePointsToFile(sampleData, new Path(testdata, "file1"), fs, conf);
    ModelDistribution<VectorWritable> modelDistribution = new GaussianClusterDistribution(new VectorWritable(new DenseVector(2)));
    DirichletDriver.run(testdata, output, modelDistribution, 15, 5, 1.0, true, true, 0, true);
    int numIterations = 10;
    Configuration conf = new Configuration();
    Path clustersIn = new Path(output, "clusters-5");
    RepresentativePointsDriver.run(conf,
View Full Code Here

  }

  @Test
  public void testDirichlet() throws Exception {
    ClusteringTestUtils.writePointsToFile(sampleData, getTestTempFilePath("testdata/file1"), fs, conf);
    ModelDistribution<VectorWritable> modelDistribution = new GaussianClusterDistribution(new VectorWritable(new DenseVector(2)));
    DirichletDriver.run(testdata, output, modelDistribution, 15, 5, 1.0, true, true, 0, true);
    int numIterations = 10;
    Path clustersIn = new Path(output, "clusters-0");
    RepresentativePointsDriver.run(conf,
                                   clustersIn,
View Full Code Here

  @Test
  public void testDirichlet2() throws Exception {
    Path output = getTestTempDirPath("output");
    NamedVector prototype = (NamedVector) sampleData.get(0).get();
    AbstractVectorModelDistribution modelDistribution = new GaussianClusterDistribution(new VectorWritable(prototype));
    Configuration conf = new Configuration();
    DirichletDriver.run(conf, getTestTempDirPath("testdata"), output, modelDistribution, 15, 10, 1.0, true, true, 0, true);
    // run ClusterDumper
    ClusterDumper clusterDumper = new ClusterDumper(finalClusterPath(conf, output, 10), new Path(output, "clusteredPoints"));
    clusterDumper.printClusters(termDictionary);
View Full Code Here

public final class TestModelDistributionSerialization extends MahoutTestCase {

  @Test
  public void testGaussianClusterDistribution() {
    GaussianClusterDistribution dist = new GaussianClusterDistribution(new VectorWritable(new DenseVector(2)));
    String json = dist.asJsonString();
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(ModelDistribution.class, new JsonModelDistributionAdapter());
    builder.registerTypeAdapter(DistanceMeasure.class, new JsonDistanceMeasureAdapter());
    Gson gson = builder.create();
    GaussianClusterDistribution dist1 = (GaussianClusterDistribution) gson
        .fromJson(json, AbstractVectorModelDistribution.MODEL_DISTRIBUTION_TYPE);
    assertSame("prototype", dist.getModelPrototype().getClass(), dist1.getModelPrototype().getClass());
  }
View Full Code Here

    generateSamples(40, 1, 1, 3);
    generateSamples(30, 1, 0, 0.1);
    generateSamples(30, 0, 1, 0.1);

    DirichletClusterer dc = new DirichletClusterer(sampleData,
                                                   new GaussianClusterDistribution(new VectorWritable(new DenseVector(2))),
                                                   1.0,
                                                   10,
                                                   1,
                                                   0);
    List<Cluster[]> result = dc.cluster(30);
View Full Code Here

    generateSamples(40, 1, 1, 3);
    generateSamples(30, 1, 0, 0.1);
    generateSamples(30, 0, 1, 0.1);

    DirichletClusterer dc = new DirichletClusterer(sampleData,
                                                   new GaussianClusterDistribution(new VectorWritable(new DenseVector(2))),
                                                   1.0,
                                                   10,
                                                   1,
                                                   0);
    List<Cluster[]> result = dc.cluster(30);
View Full Code Here

  /** Test the basic Mapper */
  @Test
  public void testMapper() throws Exception {
    generateSamples(10, 0, 0, 1);
    DirichletState state =
        new DirichletState(new GaussianClusterDistribution(new VectorWritable(new DenseVector(2))), 5, 1);
    DirichletMapper mapper = new DirichletMapper();
    mapper.setup(state);

    RecordWriter<Text, VectorWritable> writer = new DummyRecordWriter<Text, VectorWritable>();
    Mapper<WritableComparable<?>,VectorWritable,Text,VectorWritable>.Context context =
View Full Code Here

    generateSamples(100, 0, 0, 1);
    generateSamples(100, 2, 0, 1);
    generateSamples(100, 0, 2, 1);
    generateSamples(100, 2, 2, 1);
    DirichletState state =
        new DirichletState(new GaussianClusterDistribution(new VectorWritable(new DenseVector(2))), 20, 1);
    DirichletMapper mapper = new DirichletMapper();
    mapper.setup(state);

    DummyRecordWriter<Text, VectorWritable> mapWriter = new DummyRecordWriter<Text, VectorWritable>();
    Mapper<WritableComparable<?>,VectorWritable,Text,VectorWritable>.Context mapContext =
View Full Code Here

    generateSamples(100, 0, 0, 1);
    generateSamples(100, 2, 0, 1);
    generateSamples(100, 0, 2, 1);
    generateSamples(100, 2, 2, 1);
    DirichletState state =
        new DirichletState(new GaussianClusterDistribution(new VectorWritable(new DenseVector(2))), 20, 1.0);

    Collection<Model<VectorWritable>[]> models = Lists.newArrayList();

    for (int iteration = 0; iteration < 10; iteration++) {
      DirichletMapper mapper = new DirichletMapper();
View Full Code Here

TOP

Related Classes of org.apache.mahout.clustering.dirichlet.models.GaussianClusterDistribution

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.