de.lmu.ifi.dbs.elki.distance.similarityfunction.kernel
Class KernelMatrix

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.distance.similarityfunction.kernel.KernelMatrix

public class KernelMatrix
extends Object

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


Field Summary
(package private)  Matrix kernel
          The kernel matrix
 
Constructor Summary
KernelMatrix(double[][] matrixArray)
          Wraps the matrixArray in a KernelMatrix
KernelMatrix(Matrix matrix)
          Makes a new kernel matrix from matrix (with data copying).
KernelMatrix(PrimitiveSimilarityFunction<? super O,DoubleDistance> kernelFunction, Relation<? extends O> database)
          Deprecated. ID mapping is not reliable!
KernelMatrix(PrimitiveSimilarityFunction<? super O,DoubleDistance> kernelFunction, Relation<? extends O> database, ArrayDBIDs ids)
          Provides a new kernel matrix.
 
Method Summary
static Matrix centerKernelMatrix(KernelMatrix 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 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

@Deprecated
public KernelMatrix(PrimitiveSimilarityFunction<? super O,DoubleDistance> kernelFunction,
                               Relation<? extends O> database)
Deprecated. ID mapping is not reliable!

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(PrimitiveSimilarityFunction<? super O,DoubleDistance> kernelFunction,
                    Relation<? extends O> database,
                    ArrayDBIDs 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 (with data copying).

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

centerKernelMatrix

public static Matrix centerKernelMatrix(KernelMatrix 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.4.0 (2011-09-20_1324)