Examples of asJsonString()


Examples of org.apache.mahout.clustering.dirichlet.models.DistanceMeasureClusterDistribution.asJsonString()

  @Test
  public void testDMClusterDistribution2() {
    DistanceMeasureClusterDistribution dist =
        new DistanceMeasureClusterDistribution(new VectorWritable(new DenseVector(2)), new EuclideanDistanceMeasure());
    String json = dist.asJsonString();
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(ModelDistribution.class, new JsonModelDistributionAdapter());
    builder.registerTypeAdapter(DistanceMeasure.class, new JsonDistanceMeasureAdapter());
    Gson gson = builder.create();
    DistanceMeasureClusterDistribution dist1 = (DistanceMeasureClusterDistribution) gson
View Full Code Here

Examples of org.apache.mahout.clustering.dirichlet.models.GaussianClusterDistribution.asJsonString()

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
View Full Code Here

Examples of org.apache.mahout.clustering.dirichlet.models.L1Model.asJsonString()

    double[] d = { 1.1, 2.2, 3.3 };
    Vector m = new DenseVector(d);
    Printable model = new L1Model(m);
    String format = model.asFormatString(null);
    assertEquals("format", "l1m{n=0 c=[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();
    L1Model model2 = gson.fromJson(json, modelType);
    assertEquals("Json", format, model2.asFormatString(null));
View Full Code Here

Examples of org.apache.mahout.clustering.dirichlet.models.L1Model.asJsonString()

    double[] d = { 1.1, 2.2, 3.3 };
    Vector m = new DenseVector(d);
    Cluster model = new L1Model(5, m);
    String format = model.asFormatString(null);
    assertEquals("format", "l1m{n=0 c=[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();
    L1Model model2 = gson.fromJson(json, MODEL_TYPE);
    assertEquals("Json", format, model2.asFormatString(null));
View Full Code Here

Examples of org.apache.mahout.clustering.dirichlet.models.NormalModel.asJsonString()

    double[] d = { 1.1, 2.2, 3.3 };
    Vector m = new DenseVector(d);
    Printable model = new NormalModel(m, 0.75);
    String format = model.asFormatString(null);
    assertEquals("format", "nm{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();
    NormalModel model2 = gson.fromJson(json, modelType);
    assertEquals("Json", format, model2.asFormatString(null));
View Full Code Here

Examples of org.apache.mahout.clustering.dirichlet.models.NormalModel.asJsonString()

    double[] d = { 1.1, 2.2, 3.3 };
    Vector m = new DenseVector(d);
    Cluster model = new NormalModel(5, m, 0.75);
    String format = model.asFormatString(null);
    assertEquals("format", "nm{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();
    NormalModel model2 = gson.fromJson(json, MODEL_TYPE);
    assertEquals("Json", format, model2.asFormatString(null));
View Full Code Here

Examples of org.apache.mahout.clustering.dirichlet.models.SampledNormalDistribution.asJsonString()

        DefaultOptionCreator.SEQUENTIAL_METHOD };
    new DirichletDriver().run(args);
    // and inspect results
    Collection<List<DirichletCluster>> clusters = new ArrayList<List<DirichletCluster>>();
    Configuration conf = new Configuration();
    conf.set(DirichletDriver.MODEL_DISTRIBUTION_KEY, modelDistribution.asJsonString());
    conf.set(DirichletDriver.NUM_CLUSTERS_KEY, "20");
    conf.set(DirichletDriver.ALPHA_0_KEY, "1.0");
    for (int i = 0; i <= maxIterations; i++) {
      conf.set(DirichletDriver.STATE_IN_KEY, new Path(getTestTempDirPath("output"), "clusters-" + i).toString());
      clusters.add(DirichletMapper.getDirichletState(conf).getClusters());
View Full Code Here

Examples of org.apache.mahout.clustering.dirichlet.models.SampledNormalDistribution.asJsonString()

        optKey(DefaultOptionCreator.CLUSTERING_OPTION) };
    ToolRunner.run(new Configuration(), new DirichletDriver(), args);
    // and inspect results
    Collection<List<DirichletCluster>> clusters = new ArrayList<List<DirichletCluster>>();
    Configuration conf = new Configuration();
    conf.set(DirichletDriver.MODEL_DISTRIBUTION_KEY, modelDistribution.asJsonString());
    conf.set(DirichletDriver.NUM_CLUSTERS_KEY, "20");
    conf.set(DirichletDriver.ALPHA_0_KEY, "1.0");
    for (int i = 0; i <= maxIterations; i++) {
      conf.set(DirichletDriver.STATE_IN_KEY, new Path(getTestTempDirPath("output"), "clusters-" + i).toString());
      clusters.add(DirichletMapper.getDirichletState(conf).getClusters());
View Full Code Here

Examples of org.apache.mahout.clustering.dirichlet.models.SampledNormalDistribution.asJsonString()

                        true,
                        0,
                        false);
    // and inspect results
    List<List<DirichletCluster>> clusters = new ArrayList<List<DirichletCluster>>();
    conf.set(DirichletDriver.MODEL_DISTRIBUTION_KEY, modelDistribution.asJsonString());
    conf.set(DirichletDriver.NUM_CLUSTERS_KEY, "20");
    conf.set(DirichletDriver.ALPHA_0_KEY, "1.0");
    for (int i = 0; i <= maxIterations; i++) {
      conf.set(DirichletDriver.STATE_IN_KEY, new Path(getTestTempDirPath("output"), "clusters-" + i).toString());
      clusters.add(DirichletMapper.getDirichletState(conf).getClusters());
View Full Code Here

Examples of org.apache.mahout.clustering.dirichlet.models.SampledNormalModel.asJsonString()

    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
TOP
Copyright © 2018 www.massapi.com. 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.