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

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


  }

  public void testDirichletASNormalModel() {
    double[] d = { 1.1, 2.2, 3.3 };
    Vector m = new DenseVector(d);
    Printable model = new AsymmetricSampledNormalModel(m, m);
    String format = model.asFormatString(null);
    assertEquals("format", "asnm{n=0 m=[1.100, 2.200, 3.300] sd=[1.100, 2.200, 3.300]}", format);
    String json = model.asJsonString();
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Model.class, new JsonModelAdapter());
    Gson gson = builder.create();
    AsymmetricSampledNormalModel model2 = gson.fromJson(json, modelType);
    assertEquals("Json", format, model2.asFormatString(null));
  }
View Full Code Here


  }

  public void testDirichletAsymmetricSampledNormalModelClusterAsFormatString() {
    double[] d = { 1.1, 2.2, 3.3 };
    Vector m = new DenseVector(d);
    AsymmetricSampledNormalModel model = new AsymmetricSampledNormalModel(m, m);
    Printable cluster = new DirichletCluster<VectorWritable>(model, 35.0);
    String format = cluster.asFormatString(null);
    assertEquals("format", "asnm{n=0 m=[1.100, 2.200, 3.300] sd=[1.100, 2.200, 3.300]}", format);
  }
View Full Code Here

  }

  public void testDirichletAsymmetricSampledNormalModelClusterAsJsonString() {
    double[] d = { 1.1, 2.2, 3.3 };
    Vector m = new DenseVector(d);
    AsymmetricSampledNormalModel model = new AsymmetricSampledNormalModel(m, m);
    Printable cluster = new DirichletCluster<VectorWritable>(model, 35.0);
    String json = cluster.asJsonString();

    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Model.class, new JsonModelAdapter());
View Full Code Here

    int i = DisplayDirichlet.result.size() - 1;
    for (Model<VectorWritable>[] models : result) {
      g2.setStroke(new BasicStroke(i == 0 ? 3 : 1));
      g2.setColor(colors[Math.min(DisplayDirichlet.colors.length - 1, i--)]);
      for (Model<VectorWritable> m : models) {
        AsymmetricSampledNormalModel mm = (AsymmetricSampledNormalModel) m;
        dv.set(0, mm.getStdDev().get(0) * 3);
        dv.set(1, mm.getStdDev().get(1) * 3);
        if (DisplayDirichlet.isSignificant(mm)) {
          DisplayDirichlet.plotEllipse(g2, mm.getMean(), dv);
        }
      }
    }
  }
View Full Code Here

    int i = DisplayDirichlet.result.size() - 1;
    for (Model<VectorWritable>[] models : result) {
      g2.setStroke(new BasicStroke(i == 0 ? 3 : 1));
      g2.setColor(colors[Math.min(DisplayDirichlet.colors.length - 1, i--)]);
      for (Model<VectorWritable> m : models) {
        AsymmetricSampledNormalModel mm = (AsymmetricSampledNormalModel) m;
        dv.assign(mm.getStdDev().times(3));
        if (DisplayDirichlet.isSignificant(mm)) {
          DisplayDirichlet.plotEllipse(g2, mm.getMean(), dv);
        }
      }
    }
  }
View Full Code Here

    int i = DisplayDirichlet.result.size() - 1;
    for (Model<VectorWritable>[] models : result) {
      g2.setStroke(new BasicStroke(i == 0 ? 3 : 1));
      g2.setColor(colors[Math.min(DisplayDirichlet.colors.length - 1, i--)]);
      for (Model<VectorWritable> m : models) {
        AsymmetricSampledNormalModel mm = (AsymmetricSampledNormalModel) m;
        dv.assign(mm.getStdDev().times(3));
        if (DisplayDirichlet.isSignificant(mm)) {
          DisplayDirichlet.plotEllipse(g2, mm.getMean(), dv);
        }
      }
    }
  }
View Full Code Here

  }
 
  public void testAsymmetricSampledNormalModelWritableSerialization() throws Exception {
    double[] m = {1.1, 2.2, 3.3};
    double[] s = {3.3, 4.4, 5.5};
    Model<?> model = new AsymmetricSampledNormalModel(new DenseVector(m), new DenseVector(s));
    DataOutputBuffer out = new DataOutputBuffer();
    model.write(out);
    Model<?> model2 = new AsymmetricSampledNormalModel();
    DataInputBuffer in = new DataInputBuffer();
    in.reset(out.getData(), out.getLength());
    model2.readFields(in);
    assertEquals("models", model.toString(), model2.toString());
  }
View Full Code Here

  @Test
  public void testDirichletASNormalModel() {
    double[] d = { 1.1, 2.2, 3.3 };
    Vector m = new DenseVector(d);
    Cluster model = new AsymmetricSampledNormalModel(5, m, m);
    String format = model.asFormatString(null);
    assertEquals("format", "asnm{n=0 m=[1.100, 2.200, 3.300] sd=[1.100, 2.200, 3.300]}", format);
    String json = model.asJsonString();
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Model.class, new JsonModelAdapter());
    Gson gson = builder.create();
    AsymmetricSampledNormalModel model2 = gson.fromJson(json, MODEL_TYPE);
    assertEquals("Json", format, model2.asFormatString(null));
  }
View Full Code Here

  @Test
  public void testDirichletAsymmetricSampledNormalModelClusterAsFormatString() {
    double[] d = { 1.1, 2.2, 3.3 };
    Vector m = new DenseVector(d);
    AsymmetricSampledNormalModel model = new AsymmetricSampledNormalModel(5, m, m);
    Cluster cluster = new DirichletCluster(model, 35.0);
    String format = cluster.asFormatString(null);
    assertEquals("format", "C-5: asnm{n=0 m=[1.100, 2.200, 3.300] sd=[1.100, 2.200, 3.300]}", format);
  }
View Full Code Here

  @Test
  public void testDirichletAsymmetricSampledNormalModelClusterAsJsonString() {
    double[] d = { 1.1, 2.2, 3.3 };
    Vector m = new DenseVector(d);
    AsymmetricSampledNormalModel model = new AsymmetricSampledNormalModel(5, m, m);
    Cluster cluster = new DirichletCluster(model, 35.0);
    String json = cluster.asJsonString();

    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Cluster.class, new JsonClusterModelAdapter());
View Full Code Here

TOP

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

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.