Package org.apache.mahout.math

Examples of org.apache.mahout.math.JsonVectorAdapter


    BidiMap outNames = model.outputStateNames;
    model.outputStateNames = null;
    // now register the builders for matrix / vector
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Matrix.class, new JsonMatrixAdapter());
    builder.registerTypeAdapter(Vector.class, new JsonVectorAdapter());
    Gson gson = builder.create();
    // create a model
    JsonObject json = new JsonObject();
    // first, we add the model
    json.add(MODEL, new JsonPrimitive(gson.toJson(model)));
View Full Code Here


 
  /** Format the canopy for output */
  public static String formatCanopy(MeanShiftCanopy canopy) {
    Type vectorType = new TypeToken<Vector>() { }.getType();
    GsonBuilder gBuilder = new GsonBuilder();
    gBuilder.registerTypeAdapter(vectorType, new JsonVectorAdapter());
    Gson gson = gBuilder.create();
    return gson.toJson(canopy, MeanShiftCanopy.class);
  }
View Full Code Here

   * @return a new Canopy
   */
  public static MeanShiftCanopy decodeCanopy(String formattedString) {
    Type vectorType = new TypeToken<Vector>() { }.getType();
    GsonBuilder gBuilder = new GsonBuilder();
    gBuilder.registerTypeAdapter(vectorType, new JsonVectorAdapter());
    Gson gson = gBuilder.create();
    return gson.fromJson(formattedString, MeanShiftCanopy.class);
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.JsonVectorAdapter

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.