weka.classifiers.functions.supportVector.Kernel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of weka-dev Show documentation
Show all versions of weka-dev Show documentation
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.
/*
* 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 .
*/
/*
* Kernel.java
* Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand
*
*/
package weka.classifiers.functions.supportVector;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.Vector;
import weka.core.Capabilities;
import weka.core.CapabilitiesHandler;
import weka.core.CapabilitiesIgnorer;
import weka.core.Copyable;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.Option;
import weka.core.OptionHandler;
import weka.core.RevisionHandler;
import weka.core.RevisionUtils;
import weka.core.SerializedObject;
import weka.core.Utils;
/**
* Abstract kernel. Kernels implementing this class must respect Mercer's
* condition in order to ensure a correct behaviour of SMOreg.
*
* @author Eibe Frank ([email protected])
* @author FracPete (fracpete at waikato dot ac dot nz)
* @version $Revision: 11013 $
*/
public abstract class Kernel implements Serializable, OptionHandler,
CapabilitiesHandler, CapabilitiesIgnorer,
RevisionHandler {
/** for serialization */
private static final long serialVersionUID = -6102771099905817064L;
/** The dataset */
protected Instances m_data;
/** enables debugging output */
protected boolean m_Debug = false;
/** Turns off all checks */
protected boolean m_ChecksTurnedOff = false;
/** Whether capabilities should not be checked */
protected boolean m_DoNotCheckCapabilities = false;
/**
* Returns the tip text for this property
*
* @return tip text for this property suitable for displaying in the
* explorer/experimenter gui
*/
public String doNotCheckCapabilitiesTipText() {
return "If set, associator capabilities are not checked before associator is built"
+ " (Use with caution to reduce runtime).";
}
/**
* Set whether not to check capabilities.
*
* @param doNotCheckCapabilities true if capabilities are not to be checked.
*/
@Override
public void setDoNotCheckCapabilities(boolean doNotCheckCapabilities) {
m_DoNotCheckCapabilities = doNotCheckCapabilities;
}
/**
* Get whether capabilities checking is turned off.
*
* @return true if capabilities checking is turned off.
*/
@Override
public boolean getDoNotCheckCapabilities() {
return m_DoNotCheckCapabilities;
}
/**
* Returns a string describing the kernel
*
* @return a description suitable for displaying in the explorer/experimenter
* gui
*/
public abstract String globalInfo();
/**
* Computes the result of the kernel function for two instances. If id1 == -1,
* eval use inst1 instead of an instance in the dataset.
*
* @param id1 the index of the first instance in the dataset
* @param id2 the index of the second instance in the dataset
* @param inst1 the instance corresponding to id1 (used if id1 == -1)
* @return the result of the kernel function
* @throws Exception if something goes wrong
*/
public abstract double eval(int id1, int id2, Instance inst1)
throws Exception;
/**
* Frees the memory used by the kernel. (Useful with kernels which use cache.)
* This function is called when the training is done. i.e. after that, eval
* will be called with id1 == -1.
*/
public abstract void clean();
/**
* Returns the number of kernel evaluation performed.
*
* @return the number of kernel evaluation performed.
*/
public abstract int numEvals();
/**
* Returns the number of dot product cache hits.
*
* @return the number of dot product cache hits, or -1 if not supported by
* this kernel.
*/
public abstract int numCacheHits();
/**
* 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