Package libsvm

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


            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

        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

        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

  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

          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

            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

    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

    public static SvmClassifier deserialize(byte[] modelData)
    {
        // TODO do something with the hyperparameters
        try {
            svm_model model = svm.svm_load_model(new BufferedReader(new InputStreamReader(new ByteArrayInputStream(modelData))));
            return new SvmClassifier(model);
        }
        catch (IOException e) {
            throw Throwables.propagate(e);
        }
View Full Code Here

    public static SvmRegressor deserialize(byte[] modelData)
    {
        // TODO do something with the hyperparameters
        try {
            svm_model model = svm.svm_load_model(new BufferedReader(new InputStreamReader(new ByteArrayInputStream(modelData))));
            return new SvmRegressor(model);
        }
        catch (IOException e) {
            throw Throwables.propagate(e);
        }
View Full Code Here

TOP

Related Classes of libsvm.svm_model

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.