Example usage for weka.classifiers.functions.supportVector Kernel forName

List of usage examples for weka.classifiers.functions.supportVector Kernel forName

Introduction

In this page you can find the example usage for weka.classifiers.functions.supportVector Kernel forName.

Prototype

public static Kernel forName(String kernelName, String[] options) throws Exception 

Source Link

Document

Creates a new instance of a kernel given it's class name and (optional) arguments to pass to it's setOptions method.

Usage

From source file:SMO.java

License:Open Source License

/**
 * Parses a given list of options. <p/>
 *
 <!-- options-start -->/*from   ww w.  j a v a2  s  .  c om*/
 * Valid options are: <p/>
 * 
 * <pre> -D
 *  If set, classifier is run in debug mode and
 *  may output additional info to the console</pre>
 * 
 * <pre> -no-checks
 *  Turns off all checks - use with caution!
 *  Turning them off assumes that data is purely numeric, doesn't
 *  contain any missing values, and has a nominal class. Turning them
 *  off also means that no header information will be stored if the
 *  machine is linear. Finally, it also assumes that no instance has
 *  a weight equal to 0.
 *  (default: checks on)</pre>
 * 
 * <pre> -C &lt;double&gt;
 *  The complexity constant C. (default 1)</pre>
 * 
 * <pre> -N
 *  Whether to 0=normalize/1=standardize/2=neither. (default 0=normalize)</pre>
 * 
 * <pre> -L &lt;double&gt;
 *  The tolerance parameter. (default 1.0e-3)</pre>
 * 
 * <pre> -P &lt;double&gt;
 *  The epsilon for round-off error. (default 1.0e-12)</pre>
 * 
 * <pre> -M
 *  Fit logistic models to SVM outputs. </pre>
 * 
 * <pre> -V &lt;double&gt;
 *  The number of folds for the internal
 *  cross-validation. (default -1, use training data)</pre>
 * 
 * <pre> -W &lt;double&gt;
 *  The random number seed. (default 1)</pre>
 * 
 * <pre> -K &lt;classname and parameters&gt;
 *  The Kernel to use.
 *  (default: weka.classifiers.functions.supportVector.PolyKernel)</pre>
 * 
 * <pre> 
 * Options specific to kernel weka.classifiers.functions.supportVector.PolyKernel:
 * </pre>
 * 
 * <pre> -D
 *  Enables debugging output (if available) to be printed.
 *  (default: off)</pre>
 * 
 * <pre> -no-checks
 *  Turns off all checks - use with caution!
 *  (default: checks on)</pre>
 * 
 * <pre> -C &lt;num&gt;
 *  The size of the cache (a prime number), 0 for full cache and 
 *  -1 to turn it off.
 *  (default: 250007)</pre>
 * 
 * <pre> -E &lt;num&gt;
 *  The Exponent to use.
 *  (default: 1.0)</pre>
 * 
 * <pre> -L
 *  Use lower-order terms.
 *  (default: no)</pre>
 * 
 <!-- options-end -->
 *
 * @param options the list of options as an array of strings
 * @throws Exception if an option is not supported 
 */
public void setOptions(String[] options) throws Exception {
    String tmpStr;
    String[] tmpOptions;

    setChecksTurnedOff(Utils.getFlag("no-checks", options));

    tmpStr = Utils.getOption('C', options);
    if (tmpStr.length() != 0)
        setC(Double.parseDouble(tmpStr));
    else
        setC(1.0);

    tmpStr = Utils.getOption('L', options);
    if (tmpStr.length() != 0)
        setToleranceParameter(Double.parseDouble(tmpStr));
    else
        setToleranceParameter(1.0e-3);

    tmpStr = Utils.getOption('P', options);
    if (tmpStr.length() != 0)
        setEpsilon(Double.parseDouble(tmpStr));
    else
        setEpsilon(1.0e-12);

    tmpStr = Utils.getOption('N', options);
    if (tmpStr.length() != 0)
        setFilterType(new SelectedTag(Integer.parseInt(tmpStr), TAGS_FILTER));
    else
        setFilterType(new SelectedTag(FILTER_NORMALIZE, TAGS_FILTER));

    setBuildLogisticModels(Utils.getFlag('M', options));

    tmpStr = Utils.getOption('V', options);
    if (tmpStr.length() != 0)
        setNumFolds(Integer.parseInt(tmpStr));
    else
        setNumFolds(-1);

    tmpStr = Utils.getOption('W', options);
    if (tmpStr.length() != 0)
        setRandomSeed(Integer.parseInt(tmpStr));
    else
        setRandomSeed(1);

    tmpStr = Utils.getOption('K', options);
    tmpOptions = Utils.splitOptions(tmpStr);
    if (tmpOptions.length != 0) {
        tmpStr = tmpOptions[0];
        tmpOptions[0] = "";
        setKernel(Kernel.forName(tmpStr, tmpOptions));
    }

    super.setOptions(options);
}