Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.distance.similarityfunction.kernel
Class KernelMatrix<O extends FeatureVector<O,?>>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.distance.similarityfunction.kernel.KernelMatrix<O>
Type Parameters:
O - object type

public class KernelMatrix<O extends FeatureVector<O,?>>
extends AbstractLoggable

Provides a class for storing the kernel matrix and several extraction methods for convenience.

Author:
Simon Paradies

Field Summary
(package private)  Matrix kernel
          The kernel matrix
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug, logger
 
Constructor Summary
KernelMatrix(double[][] matrixArray)
          Wraps the matrixArray in a KernelMatrix
KernelMatrix(KernelFunction<O,DoubleDistance> kernelFunction, Database<O> database)
          Provides a new kernel matrix.
KernelMatrix(KernelFunction<O,DoubleDistance> kernelFunction, Database<O> database, List<Integer> ids)
          Provides a new kernel matrix.
KernelMatrix(Matrix matrix)
          Makes a new kernel matrix from matrix.
 
Method Summary
static Matrix centerKernelMatrix(KernelMatrix<? extends NumberVector<?,?>> kernelMatrix)
          Centers the Kernel Matrix in Feature Space according to Smola et.
static Matrix centerMatrix(Matrix matrix)
          Centers the matrix in feature space according to Smola et.
 double getDistance(int o1, int o2)
          Returns the kernel distance between the two specified objects.
 Matrix getKernel()
          Get the kernel matrix.
 double getSimilarity(int o1, int o2)
          Returns the kernel value of object o1 and object o2
 double getSquaredDistance(int o1, int o2)
          Returns the squared kernel distance between the two specified objects.
 Matrix getSubColumn(int i, List<Integer> ids)
          Returns the ith kernel matrix column for all objects in ids
 Matrix getSubMatrix(Collection<Integer> ids)
          Returns a sub kernel matrix for all objects in ids
 String toString()
           
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, progress, verbose, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

kernel

Matrix kernel
The kernel matrix

Constructor Detail

KernelMatrix

public KernelMatrix(double[][] matrixArray)
Wraps the matrixArray in a KernelMatrix

Parameters:
matrixArray - two dimensional double array

KernelMatrix

public KernelMatrix(KernelFunction<O,DoubleDistance> kernelFunction,
                    Database<O> database)
Provides a new kernel matrix.

Parameters:
kernelFunction - the kernel function used to compute the kernel matrix
database - the database for which the kernel matrix is computed

KernelMatrix

public KernelMatrix(KernelFunction<O,DoubleDistance> kernelFunction,
                    Database<O> database,
                    List<Integer> ids)
Provides a new kernel matrix.

Parameters:
kernelFunction - the kernel function used to compute the kernel matrix
database - the database that holds the objects
ids - the IDs of those objects for which the kernel matrix is computed

KernelMatrix

public KernelMatrix(Matrix matrix)
Makes a new kernel matrix from matrix.

Parameters:
matrix - a matrix
Method Detail

getDistance

public double getDistance(int o1,
                          int o2)
Returns the kernel distance between the two specified objects.

Parameters:
o1 - first ObjectID
o2 - second ObjectID
Returns:
the distance between the two objects

getKernel

public Matrix getKernel()
Get the kernel matrix.

Returns:
kernel

getSimilarity

public double getSimilarity(int o1,
                            int o2)
Returns the kernel value of object o1 and object o2

Parameters:
o1 - ID of first object
o2 - ID of second object
Returns:
the kernel value of object o1 and object o2

getSquaredDistance

public double getSquaredDistance(int o1,
                                 int o2)
Returns the squared kernel distance between the two specified objects.

Parameters:
o1 - first ObjectID
o2 - second ObjectID
Returns:
the distance between the two objects

getSubColumn

public Matrix getSubColumn(int i,
                           List<Integer> ids)
Returns the ith kernel matrix column for all objects in ids

Parameters:
i - the column which should be returned
ids - the objects
Returns:
the ith kernel matrix column for all objects in ids

getSubMatrix

public Matrix getSubMatrix(Collection<Integer> ids)
Returns a sub kernel matrix for all objects in ids

Parameters:
ids - the objects
Returns:
a sub kernel matrix for all objects in ids.

centerMatrix

public static Matrix centerMatrix(Matrix matrix)
Centers the matrix in feature space according to Smola et. Schoelkopf, Learning with Kernels p. 431 Alters the input matrix. If you still need the original matrix, use centeredMatrix = centerKernelMatrix(uncenteredMatrix.copy()) {

Parameters:
matrix - the matrix to be centered
Returns:
centered matrix (for convenience)

toString

public String toString()
Overrides:
toString in class Object
See Also:
Matrix.toString()

centerKernelMatrix

public static Matrix centerKernelMatrix(KernelMatrix<? extends NumberVector<?,?>> kernelMatrix)
Centers the Kernel Matrix in Feature Space according to Smola et. Schoelkopf, Learning with Kernels p. 431 Alters the input matrix. If you still need the original matrix, use centeredMatrix = centerKernelMatrix(uncenteredMatrix.copy()) {

Parameters:
kernelMatrix - the kernel matrix to be centered
Returns:
centered kernelMatrix (for convenience)

Release 0.3 (2010-03-31_1612)