All Downloads are FREE. Search and download functionalities are using the official Maven repository.

weka.classifiers.functions.supportVector.KernelEvaluation Maven / Gradle / Ivy

Go to download

The Waikato Environment for Knowledge Analysis (WEKA), a machine learning workbench. This version represents the developer version, the "bleeding edge" of development, you could say. New functionality gets added to this version.

There is a newer version: 3.9.6
Show newest version
/*
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see .
 */

/*
 * KernelEvaluation.java
 * Copyright (C) 2006-2012 University of Waikato, Hamilton, New Zealand
 */

package weka.classifiers.functions.supportVector;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Enumeration;

import weka.core.Instances;
import weka.core.Option;
import weka.core.OptionHandler;
import weka.core.RevisionHandler;
import weka.core.RevisionUtils;
import weka.core.Utils;

/**
 * Class for evaluating Kernels.
 * 
 * @author fracpete (fracpete at waikato dot ac dot nz)
 * @version $Revision: 10169 $
 */
public class KernelEvaluation implements RevisionHandler {

  /** the result string */
  protected StringBuffer m_Result;

  /** the kernel evaluation results */
  protected double[][] m_Evaluations;

  /** the number of performed evaluations */
  protected int m_NumEvals;

  /** the number of cache hits */
  protected int m_NumCacheHits;

  /** user-supplied options */
  protected String[] m_Options;

  /**
   * default constructor
   */
  public KernelEvaluation() {
    super();

    m_Result = new StringBuffer();
    m_Evaluations = new double[0][0];
    m_Options = new String[0];
    m_NumEvals = 0;
    m_NumCacheHits = 0;
  }

  /**
   * sets the option the user supplied for the kernel
   * 
   * @param options options that were supplied for the kernel
   */
  public void setUserOptions(String[] options) {
    m_Options = options.clone();
  }

  /**
   * returns the options the user supplied for the kernel
   * 
   * @return the user supplied options for the kernel
   */
  public String[] getUserOptions() {
    return m_Options.clone();
  }

  /**
   * Generates an option string to output on the commandline.
   * 
   * @param Kernel the Kernel to generate the string for
   * @return the option string
   */
  protected static String makeOptionString(Kernel Kernel) {
    StringBuffer text;

    text = new StringBuffer();

    // general options
    text.append("\nGeneral options:\n\n");
    text.append("-t \n");
    text.append("\tThe name of the training file.\n");
    text.append("-c \n");
    text.append("\tSets index of class attribute (default: last).\n");

    // Kernel specific options, if any
    if (Kernel instanceof OptionHandler) {
      text.append("\nOptions specific to "
        + Kernel.getClass().getName().replaceAll(".*\\.", "") + ":\n\n");

      Enumeration




© 2015 - 2024 Weber Informatics LLC | Privacy Policy