Examples of SparseModel


Examples of com.clearnlp.classification.model.SparseModel

  public void predict(String testFile, String outputFile, String modelFile, byte vectorType) throws Exception
  {
    BufferedReader    fin = UTInput.createBufferedFileReader(testFile);
    PrintStream      fout = UTOutput.createPrintBufferedFileStream(outputFile);
    ObjectInputStream  in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(modelFile)));
    SparseModel    pModel = null;
    StringModel    sModel = null;
   
    switch (vectorType)
    {
    case AbstractTrainSpace.VECTOR_SPARSE:
      pModel = (SparseModel)in.readObject(); break;
    case AbstractTrainSpace.VECTOR_STRING:
      sModel = (StringModel)in.readObject(); break;
    }
   
    in.close();
   
    boolean hasWeight = AbstractTrainSpace.hasWeight(vectorType, testFile);
    int correct = 0, total = 0;
    StringPrediction r = null;
    String line, label = null;
   
    System.out.print("Predicting");
   
    while ((line = fin.readLine()) != null)
    {
      if (vectorType == AbstractTrainSpace.VECTOR_SPARSE)
      {
        Pair<String,SparseFeatureVector> sp = SparseTrainSpace.toInstance(line, hasWeight);
        r = pModel.predictBest(sp.o2);
        label = sp.o1;
      }
      else
      {
        StringInstance ss = StringTrainSpace.toInstance(line, hasWeight);
View Full Code Here

Examples of com.clearnlp.classification.model.SparseModel

   * Constructs a train space containing sparse vectors.
   * @param hasWeight {@code true} if features are assigned with different weights.
   */
  public SparseTrainSpace(boolean hasWeight)
  {
    super(new SparseModel(), hasWeight);
    s_model = (SparseModel)m_model;
    s_ys    = new ArrayList<String>();
  }
View Full Code Here

Examples of com.clearnlp.classification.model.SparseModel

  public void predict(String testFile, String outputFile, String modelFile, byte vectorType) throws Exception
  {
    BufferedReader    fin = UTInput.createBufferedFileReader(testFile);
    PrintStream      fout = UTOutput.createPrintBufferedFileStream(outputFile);
    ObjectInputStream  in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(modelFile)));
    SparseModel    pModel = null;
    StringModel    sModel = null;
   
    switch (vectorType)
    {
    case AbstractTrainSpace.VECTOR_SPARSE:
      pModel = (SparseModel)in.readObject(); break;
    case AbstractTrainSpace.VECTOR_STRING:
      sModel = (StringModel)in.readObject(); break;
    }
   
    in.close();
   
    boolean hasWeight = AbstractTrainSpace.hasWeight(vectorType, testFile);
    int correct = 0, total = 0;
    StringPrediction r = null;
    String line, label = null;
   
    System.out.print("Predicting");
   
    while ((line = fin.readLine()) != null)
    {
      if (vectorType == AbstractTrainSpace.VECTOR_SPARSE)
      {
        Pair<String,SparseFeatureVector> sp = SparseTrainSpace.toInstance(line, hasWeight);
        r = pModel.predictBest(sp.o2);
        label = sp.o1;
      }
      else
      {
        StringInstance ss = StringTrainSpace.toInstance(line, hasWeight);
View Full Code Here

Examples of hivemall.io.SparseModel

            }
        } else {
            int initModelSize = getInitialModelSize();
            logger.info("Build a sparse model with initial with " + initModelSize
                    + " initial dimensions");
            model = new SparseModel(initModelSize, useCovar);
        }
        if(mixConnectInfo != null) {
            model.configureClock();
            model = new SynchronizedModelWrapper(model);
            MixClient client = configureMixClient(mixConnectInfo, label, model);
View Full Code Here

Examples of hivemall.io.SparseModel

    }

    private static void invokeClient01(String groupId, int serverPort, boolean denseModel)
            throws InterruptedException {
        PredictionModel model = denseModel ? new DenseModel(100, false)
                : new SparseModel(100, false);
        model.configureClock();
        MixClient client = null;
        try {
            client = new MixClient(MixEventName.average, groupId, "localhost:" + serverPort, false, 3, model);
            model.setUpdateHandler(client);
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.