Examples of svm_model


Examples of ca.uwo.csd.ai.nlp.libsvm.svm_model

                } else {
                    trainingInstances.add(instances[j]);
                }
            }                                   
           
            svm_model trainModel = train(trainingInstances, param);
            double[] predictions = SVMPredictor.predict(testingInstances, trainModel);
            for (int k = 0; k < predictions.length; k++) {
               
                if (predictions[k] == testingInstances.get(k).getLabel()) {
                //if (Math.abs(predictions[k] - testingInstances.get(k).getLabel()) < 0.00001) {
View Full Code Here

Examples of ca.uwo.csd.ai.nlp.libsvm.svm_model

        //Setup parameters
        svm_parameter param = new svm_parameter();               
       
        //Train the model
        System.out.println("Training started...");
        svm_model model = SVMTrainer.train(trainingInstances, param);
        System.out.println("Training completed.");
               
        //Save the trained model
        //SVMTrainer.saveModel(model, "a1a.model");
        //model = SVMPredictor.load_model("a1a.model");
View Full Code Here

Examples of libsvm.svm_model

      owner.getGuide().getConfiguration().getConfigLogger().info("Creating LIBSVM model "+getFile(".moo").getName()+"\n");
      final PrintStream out = System.out;
      final PrintStream err = System.err;
      System.setOut(NoPrintStream.NO_PRINTSTREAM);
      System.setErr(NoPrintStream.NO_PRINTSTREAM);
      svm_model model = svm.svm_train(prob, param);
      System.setOut(err);
      System.setOut(out);
        ObjectOutputStream output = new ObjectOutputStream (new BufferedOutputStream(new FileOutputStream(getFile(".moo").getAbsolutePath())));
          try{
            output.writeObject(new MaltLibsvmModel(model, prob));
View Full Code Here

Examples of libsvm.svm_model

            if (child.waitFor() != 0) {
              owner.getGuide().getConfiguration().getConfigLogger().info(" FAILED ("+child.exitValue()+")");
            }
          in.close();
          err.close();
          svm_model model = svm.svm_load_model(getFile(".mod").getAbsolutePath());
          MaltLibsvmModel xmodel = new MaltLibsvmModel(model, prob);
          ObjectOutputStream output = new ObjectOutputStream (new BufferedOutputStream(new FileOutputStream(getFile(".moo").getAbsolutePath())));
          try {
            output.writeObject(xmodel);
        } finally {
View Full Code Here

Examples of libsvm.svm_model

        svm_parameter param = new svm_parameter();
        param.svm_type = svm_parameter.C_SVC;
        param.kernel_type = svm_parameter.RBF;
        param.gamma = 0.5;
        param.C = 1.0;
        svm_model theModel = svm.svm_train(prob, param);
        try {
            svm.svm_save_model(PropertiesGetter.getProperty("SVMModelFile"), theModel);
        } catch (IOException ex) {
            Logger.getLogger(LibSVMWrapper.class.getName()).log(Level.SEVERE, null, ex);
        }
View Full Code Here

Examples of libsvm.svm_model

        return labels;
    }

    public double classify(LinkedHashMap<Integer, Double> trainingSample) {
        try {
            svm_model currentModel = svm.svm_load_model(PropertiesGetter.getProperty("SVMModelFile"));
            Iterator<Entry<Integer, Double>> it = trainingSample.entrySet().iterator();
            int m = trainingSample.size();
            svm_node[] x = new svm_node[m];
            Entry<Integer, Double> currentEntry;
            for (int j = 0; j < m; j++) {
View Full Code Here

Examples of libsvm.svm_model

  HashSet<String> stopwords;
  private ArrayList<String> treeFrags;

  private svm_model loadModel (UimaContext uc, String m) {
    svm_model ret = null;
    try {
      String r = ((FileResource) uc.getResourceObject(m)).getFile().getAbsolutePath();
      ret = svm.svm_load_model(r);
      logger.info(m+" loaded: "+r);
    } catch (Exception e) {
View Full Code Here

Examples of libsvm.svm_model

          stopwords.add(l.substring(0,i).trim());
        else if (i < 0)
          stopwords.add(l.trim());
      }
      File anaphModFile = FileLocator.locateFile("anaphoricity.mayo.rbf.model");
      svm_model anaphModel = svm.svm_load_model(anaphModFile.getAbsolutePath());
      vecCreator = new SvmVectorCreator(stopwords, anaphModel);
      r = (FileResource) super.getUimaContext().getResourceObject("treeFrags");
      Scanner scanner = new Scanner(r.getFile());
      if(useFrags){
        treeFrags = new ArrayList<String>();
View Full Code Here

Examples of libsvm.svm_model

            tmpTrain.add(trainData.get(itemIndex));
            tmpTraintar.add(targets.get(itemIndex));
          }
        }
      }
      svm_model m = internallearnClassifer(gamma, c, tmpTrain,
          tmpTraintar);
      acc += getAccuracy(m, tmpTest, tmpTesttar);
    }
    return acc * 1.0 / fold;
  }
View Full Code Here

Examples of libsvm.svm_model

    svm.svm_set_print_string_function(new svm_print_interface() {
      public void print(String s) {
      }
    });
    svm.rand.setSeed(0);
    svm_model model = svm.svm_train(problem, parameters);
    return model;
  }
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.