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

weka.classifiers.functions.supportVector.PolyKernel 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 .
 */

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

package weka.classifiers.functions.supportVector;

import java.util.Collections;
import java.util.Enumeration;
import java.util.Vector;

import weka.core.Capabilities;
import weka.core.Capabilities.Capability;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.Option;
import weka.core.RevisionUtils;
import weka.core.Utils;

/**
 *  The polynomial kernel : K(x, y) = <x, y>^p or
 * K(x, y) = (<x, y>+1)^p
 * 

* * * Valid options are: *

* *

 * -D
 *  Enables debugging output (if available) to be printed.
 *  (default: off)
 * 
* *
 * -no-checks
 *  Turns off all checks - use with caution!
 *  (default: checks on)
 * 
* *
 * -C <num>
 *  The size of the cache (a prime number), 0 for full cache and 
 *  -1 to turn it off.
 *  (default: 250007)
 * 
* *
 * -E <num>
 *  The Exponent to use.
 *  (default: 1.0)
 * 
* *
 * -L
 *  Use lower-order terms.
 *  (default: no)
 * 
* * * * @author Eibe Frank ([email protected]) * @author Shane Legg ([email protected]) (sparse vector code) * @author Stuart Inglis ([email protected]) (sparse vector code) * @version $Revision: 10169 $ */ public class PolyKernel extends CachedKernel { /** for serialization */ static final long serialVersionUID = -321831645846363201L; /** Use lower-order terms? */ protected boolean m_lowerOrder = false; /** The exponent for the polynomial kernel. */ protected double m_exponent = 1.0; /** * default constructor - does nothing. */ public PolyKernel() { super(); } /** * Frees the cache used by the kernel. */ @Override public void clean() { if (getExponent() == 1.0) { m_data = null; } super.clean(); } /** * Creates a new PolyKernel instance. * * @param data the training dataset used. * @param cacheSize the size of the cache (a prime number) * @param exponent the exponent to use * @param lowerOrder whether to use lower-order terms * @throws Exception if something goes wrong */ public PolyKernel(Instances data, int cacheSize, double exponent, boolean lowerOrder) throws Exception { super(); setCacheSize(cacheSize); setExponent(exponent); setUseLowerOrder(lowerOrder); buildKernel(data); } /** * Returns a string describing the kernel * * @return a description suitable for displaying in the explorer/experimenter * gui */ @Override public String globalInfo() { return "The polynomial kernel : K(x, y) = ^p or K(x, y) = (+1)^p"; } /** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration




© 2015 - 2024 Weber Informatics LLC | Privacy Policy