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

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


  }

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


    assertEquals("models", model.toString(), model2.toString());
  }
 
  public void testSampledNormalModelWritableSerialization() throws Exception {
    double[] m = {1.1, 2.2, 3.3};
    Model<?> model = new SampledNormalModel(new DenseVector(m), 3.3);
    DataOutputBuffer out = new DataOutputBuffer();
    model.write(out);
    Model<?> model2 = new SampledNormalModel();
    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 testDirichletSampledNormalModel() {
    double[] d = { 1.1, 2.2, 3.3 };
    Vector m = new DenseVector(d);
    Cluster model = new SampledNormalModel(5, m, 0.75);
    String format = model.asFormatString(null);
    assertEquals("format", "snm{n=0 m=[1.100, 2.200, 3.300] sd=0.75}", format);
    String json = model.asJsonString();
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Model.class, new JsonModelAdapter());
    Gson gson = builder.create();
    SampledNormalModel model2 = gson.fromJson(json, MODEL_TYPE);
    assertEquals("Json", format, model2.asFormatString(null));
  }
View Full Code Here

  }

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

  }

  @SuppressWarnings("unchecked")
  public void testSampledNormalModelSerialization() {
    double[] m = { 1.1, 2.2 };
    Model model = new SampledNormalModel(new DenseVector(m), 3.3);
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Vector.class, new JsonVectorAdapter());
    Gson gson = builder.create();
    String jsonString = gson.toJson(model);
    Model model2 = gson.fromJson(jsonString, SampledNormalModel.class);
    assertEquals("models", model.toString(), model2.toString());
  }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  public void testSampledNormalModelSerialization() {
    double[] m = {1.1, 2.2};
    Model<?> model = new SampledNormalModel(new DenseVector(m), 3.3);
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Vector.class, new JsonVectorAdapter());
    Gson gson = builder.create();
    String jsonString = gson.toJson(model);
    Model<?> model2 = gson.fromJson(jsonString, SampledNormalModel.class);
    assertEquals("models", model.toString(), model2.toString());
  }
View Full Code Here

TOP

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

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.