Examples of svm_problem


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

    private static svm_problem prepareProblem(Instance[] instances) {
        return prepareProblem(instances, 0, instances.length - 1);
    }
   
    private static svm_problem prepareProblem(Instance[] instances, int begin, int end) {
        svm_problem prob = new svm_problem();
        prob.l = (end - begin) + 1;
        prob.y = new double[prob.l];
        prob.x = new svm_node[prob.l];
       
        for (int i = begin; i <= end; i++) {
View Full Code Here

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

     * @param param
     * @return
     */
    public static svm_model train(Instance[] instances, svm_parameter param) {
        //prepare svm_problem
        svm_problem prob = prepareProblem(instances);
       
        String error_msg = svm.svm_check_parameter(prob, param);

        if (error_msg != null) {
            System.err.print("ERROR: " + error_msg + "\n");
View Full Code Here

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

     * @param param parameters
     * @param nr_fold number of folds (N)
     * @param binary whether doing binary classification
     */
    public static void doCrossValidation(Instance[] instances, svm_parameter param, int nr_fold, boolean binary) {
        svm_problem prob = prepareProblem(instances);
       
        int i;
        int total_correct = 0;
        double total_error = 0;
        double sumv = 0, sumy = 0, sumvv = 0, sumyy = 0, sumvy = 0;
View Full Code Here

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

Examples of libsvm.svm_problem

 
  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

Examples of libsvm.svm_problem

    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

Examples of libsvm.svm_problem

   * @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

Examples of libsvm.svm_problem

        //
        // 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

Examples of libsvm.svm_problem

            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

Examples of libsvm.svm_problem

  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
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.