pt.tumba.ngram.svm
Class Kernel

java.lang.Object
  extended by pt.tumba.ngram.svm.Kernel
Direct Known Subclasses:
ONECLASSQ, SVCQ, SVRQ

public abstract class Kernel
extends java.lang.Object

Abstract interface to model an SVM Kernel.

Author:
Bruno Martins

Field Summary
private  double coef0
           
private  double degree
           
private  double gamma
           
private  int kernelType
          SVM Kernel type
private  SVMNode[][] x
           
private  double[] xSquare
           
 
Constructor Summary
Kernel(int l, SVMNode[][] x_, SVMParameter param)
          Kernel constructor, prepares to calculate the l*l kernel matrix.
 
Method Summary
(package private) static double dot(SVMNode[] x, SVMNode[] y)
          Return the dot product of two vectors.
(package private) abstract  float[] getQ(int column, int len)
          Return one column of the Kernel matrix.
(package private)  double kernelFunction(int i, int j)
          Returns the value of a single kernel evaluation.
(package private) static double kernelFunction(SVMNode[] x, SVMNode[] y, SVMParameter param)
          Returns the value of a single kernel evaluation.
(package private)  void swapIndex(int i, int j)
          Swap two nodes of the Kernel matrix.
private static double tanh(double x)
          Returns the hyperbolic tangent of a given value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

private SVMNode[][] x

xSquare

private final double[] xSquare

kernelType

private final int kernelType
SVM Kernel type


degree

private final double degree

gamma

private final double gamma

coef0

private final double coef0
Constructor Detail

Kernel

Kernel(int l,
       SVMNode[][] x_,
       SVMParameter param)
Kernel constructor, prepares to calculate the l*l kernel matrix.

Parameters:
l - The length of the kernel matrix (number of rows and columns).
x_ - The SVM Nodes.
param - Kernel parameters.
Method Detail

getQ

abstract float[] getQ(int column,
                      int len)
Return one column of the Kernel matrix.

Parameters:
column - The column of the kernel matrix.
len - The nu
Returns:
One column of the Kernel matrix.

swapIndex

void swapIndex(int i,
               int j)
Swap two nodes of the Kernel matrix.

Parameters:
i -
j -

tanh

private static double tanh(double x)
Returns the hyperbolic tangent of a given value

Parameters:
x - A double value.
Returns:
The hyperbolic tangent of the given value.

dot

static double dot(SVMNode[] x,
                  SVMNode[] y)
Return the dot product of two vectors.

Parameters:
x - A vector.
y - Another vector.
Returns:
The dot product of both vectors.

kernelFunction

double kernelFunction(int i,
                      int j)
Returns the value of a single kernel evaluation.

Parameters:
i - The row of the kernel matrix.
j - The column of the kernel matrix.
Returns:
The value for the single kernel evaluation.

kernelFunction

static double kernelFunction(SVMNode[] x,
                             SVMNode[] y,
                             SVMParameter param)
Returns the value of a single kernel evaluation.

Parameters:
x - The row of the kernel matrix.
y - The column of the kernel matrix.
param - SVM kernel parameters
Returns:
The value for the single kernel evaluation.