Package libsvm

Examples of libsvm.svm_problem


    }
  }
 
  protected void trainInternal(FeatureVector featureVector) throws MaltChainedException {
    try {
      final svm_problem prob = readProblem(getInstanceInputStreamReader(".ins"));
      final svm_parameter param = getLibSvmParameters();
      if(svm.svm_check_parameter(prob, param) != null) {
        throw new LibException(svm.svm_check_parameter(prob, param));
      }
      owner.getGuide().getConfiguration().getConfigLogger().info("Creating LIBSVM model "+getFile(".moo").getName()+"\n");
View Full Code Here


 
  protected void trainExternal(FeatureVector featureVector) throws MaltChainedException {
    try {   
      binariesInstances2SVMFileFormat(getInstanceInputStreamReader(".ins"), getInstanceOutputStreamWriter(".ins.tmp"));
      owner.getGuide().getConfiguration().getConfigLogger().info("Creating learner model (external) "+getFile(".mod").getName());
      final svm_problem prob = readProblem(getInstanceInputStreamReader(".ins"));
      final String[] params = getLibParamStringArray();
      String[] arrayCommands = new String[params.length+3];
      int i = 0;
      arrayCommands[i++] = pathExternalTrain;
      for (; i <= params.length; i++) {
View Full Code Here

    param.weight = new double[0];
    return param;
  }
 
  private svm_problem readProblem(InputStreamReader isr) throws MaltChainedException {
    final svm_problem problem = new svm_problem();
    final svm_parameter param = getLibSvmParameters();
    final FeatureList featureList = new FeatureList();
    try {
      final BufferedReader fp = new BufferedReader(isr);
     
View Full Code Here

   * @param cardinalities  a array containing the number of distinct values for a particular column.
   * @param param  a svm_parameter object
   * @throws LibsvmException
   */
  public final svm_problem readProblemMaltSVMFormat(InputStreamReader isr, int[] cardinalities, svm_parameter param) throws MaltChainedException {
    final svm_problem prob = new svm_problem();
    try {
      final BufferedReader fp = new BufferedReader(isr);
      int max_index = 0;
      if (xlist == null) {
        xlist = new ArrayList<svm_node>();
View Full Code Here

        //
        // 1- Form The File with SVM format
        // 2- loading the file using dataset loader into a problem object
        // 3- perform grid selection
        // 4- traing using the selected parameters and save into the model
        svm_problem prob = constructProblem(labels, trainingSamples);
        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;
View Full Code Here

            if (m > 0) {
                max_index = Math.max(max_index, x[m - 1].index);
            }
            allSamples[i] = x;
        }
        svm_problem newProblem = new svm_problem();
        newProblem.l = labels.size();
        newProblem.y = y;
        newProblem.x = allSamples;
        return newProblem;
    }
View Full Code Here

  public svm_model internallearnClassifer(double gamma, double c,
      ArrayList<svm_node[]> tData, ArrayList<Double> tars) {
    // duplicateData();
    this.convertToCSVfile();
    svm_problem problem = new svm_problem();
    problem.l = tData.size();
    problem.x = tData.toArray(new svm_node[tData.size()][]); // feature
                                  // nodes
    problem.y = ArrayUtils
        .toPrimitive(tars.toArray(new Double[tars.size()])); // target
View Full Code Here

      }
      if (m > 0)
        max_index = Math.max(max_index, x[m - 1].index);
      vx.addElement(x);
    }
    prob = new svm_problem();
    prob.l=vy.size();
    prob.y = new double[prob.l];
    prob.x = new svm_node[prob.l][];
    for (int i = 0; i < prob.l; i++)
      prob.x[i]= (svm_node[]) vx.elementAt(i);
View Full Code Here

        param.probability = 0;
        param.nr_weight = 0;
        param.weight_label = new int[0];
        param.weight = new double[0];

        svm_problem problem = toSvmProblem(dataset);

        //TODO: we should probably run this in another thread, and put a bound on the running time
        model = svm.svm_train(problem, param);
    }
View Full Code Here

    protected abstract int getLibsvmType();

    private static svm_problem toSvmProblem(Dataset dataset)
    {
        svm_problem problem = new svm_problem();
        List<Double> labels = dataset.getLabels();
        problem.l = labels.size();
        problem.y = new double[labels.size()];
        for (int i = 0; i < labels.size(); i++) {
            problem.y[i] = labels.get(i);
View Full Code Here

TOP

Related Classes of libsvm.svm_problem

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.