weka.classifiers.functions.supportVector
Class PolyKernel

java.lang.Object
  extended byweka.classifiers.functions.supportVector.Kernel
      extended byweka.classifiers.functions.supportVector.PolyKernel
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
NormalizedPolyKernel

public class PolyKernel
extends Kernel

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

Version:
$$
Author:
Eibe Frank (eibe@cs.waikato.ac.nz), Shane Legg (shane@intelligenesis.net) (sparse vector code), Stuart Inglis (stuart@reeltwo.com) (sparse vector code)
See Also:
Serialized Form

Field Summary
private  int m_cacheSize
          The size of the cache (a prime number)
private  double m_exponent
          The exponent for the polynomial kernel.
private  int m_kernelEvals
          Counts the number of kernel evaluations.
private  long[] m_keys
           
private  boolean m_lowerOrder
          Use lower-order terms?
private  int m_numInsts
          The number of instance in the dataset
private  double[] m_storage
          Kernel cache
 
Fields inherited from class weka.classifiers.functions.supportVector.Kernel
m_data
 
Constructor Summary
PolyKernel(Instances dataset, int cacheSize, double exponent, boolean lowerOrder)
          Creates a new PolyKernel instance.
 
Method Summary
 void clean()
          Frees the cache used by the kernel.
private  double dotProd(Instance inst1, Instance inst2)
          Calculates a dot product between two instances
 double eval(int id1, int id2, Instance inst1)
          Implements the abstract function of Kernel.
 int numEvals()
          Returns the number of time Eval has been called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_cacheSize

private int m_cacheSize
The size of the cache (a prime number)


m_lowerOrder

private boolean m_lowerOrder
Use lower-order terms?


m_exponent

private double m_exponent
The exponent for the polynomial kernel.


m_storage

private double[] m_storage
Kernel cache


m_keys

private long[] m_keys

m_kernelEvals

private int m_kernelEvals
Counts the number of kernel evaluations.


m_numInsts

private int m_numInsts
The number of instance in the dataset

Constructor Detail

PolyKernel

public PolyKernel(Instances dataset,
                  int cacheSize,
                  double exponent,
                  boolean lowerOrder)
Creates a new PolyKernel instance.

Parameters:
dataset - the training dataset used.
cacheSize - the size of the cache (a prime number)
Method Detail

eval

public double eval(int id1,
                   int id2,
                   Instance inst1)
            throws java.lang.Exception
Implements the abstract function of Kernel.

Specified by:
eval in class Kernel
Parameters:
id1 - the index of the first instance in the dataset
id2 - the index of the second instance in the dataset
Returns:
the result of the kernel function
Throws:
java.lang.Exception

dotProd

private double dotProd(Instance inst1,
                       Instance inst2)
                throws java.lang.Exception
Calculates a dot product between two instances

Parameters:
inst1 - the first instance
inst2 - the second instance
Returns:
the dot product of the two instances.
Throws:
java.lang.Exception - if an error occurs

clean

public void clean()
Frees the cache used by the kernel.

Specified by:
clean in class Kernel

numEvals

public int numEvals()
Returns the number of time Eval has been called.

Specified by:
numEvals in class Kernel
Returns:
the number of kernel evaluation.