Package elki.similarity.kernel
Class KernelMatrix
- java.lang.Object
-
- elki.similarity.kernel.KernelMatrix
-
public class KernelMatrix extends java.lang.Object
Kernel matrix representation.- Since:
- 0.1
- Author:
- Simon Paradies
-
-
Field Summary
Fields Modifier and Type Field Description (package private) KernelMatrix.DBIDMap
idmap
Static mapping from DBIDs to indexes.(package private) double[][]
kernel
The kernel matrix
-
Constructor Summary
Constructors Constructor Description KernelMatrix(double[][] matrix)
Makes a new kernel matrix from matrix (with data copying).KernelMatrix(SimilarityQuery<? super O> kernelFunction, Relation<? extends O> relation, DBIDs ids)
Provides a new kernel matrix.KernelMatrix(PrimitiveSimilarity<? super O> kernelFunction, Relation<? extends O> relation, DBIDs ids)
Provides a new kernel matrix.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static double[][]
centerKernelMatrix(KernelMatrix kernelMatrix)
Centers the Kernel Matrix in Feature Space according to Smola et.static double[][]
centerMatrix(double[][] matrix)
Centers the matrix in feature space according to Smola et Schoelkopf, Learning with Kernels p. 431 Alters the input matrix.double
getDistance(DBIDRef o1, DBIDRef o2)
Returns the kernel distance between the two specified objects.double[][]
getKernel()
Get the kernel matrix.double
getSimilarity(DBIDRef id1, DBIDRef id2)
Get the kernel similarity for the given objects.double
getSquaredDistance(DBIDRef id1, DBIDRef id2)
Returns the squared kernel distance between the two specified objects.
-
-
-
Field Detail
-
kernel
double[][] kernel
The kernel matrix
-
idmap
KernelMatrix.DBIDMap idmap
Static mapping from DBIDs to indexes.
-
-
Constructor Detail
-
KernelMatrix
public KernelMatrix(PrimitiveSimilarity<? super O> kernelFunction, Relation<? extends O> relation, DBIDs ids)
Provides a new kernel matrix.- Parameters:
kernelFunction
- the kernel function used to compute the kernel matrixrelation
- the database that holds the objectsids
- the IDs of those objects for which the kernel matrix is computed
-
KernelMatrix
public KernelMatrix(SimilarityQuery<? super O> kernelFunction, Relation<? extends O> relation, DBIDs ids)
Provides a new kernel matrix.- Parameters:
kernelFunction
- the kernel function used to compute the kernel matrixrelation
- the database that holds the objectsids
- the IDs of those objects for which the kernel matrix is computed
-
KernelMatrix
public KernelMatrix(double[][] matrix)
Makes a new kernel matrix from matrix (with data copying).- Parameters:
matrix
- a matrix
-
-
Method Detail
-
getDistance
public double getDistance(DBIDRef o1, DBIDRef o2)
Returns the kernel distance between the two specified objects.- Parameters:
o1
- first ObjectIDo2
- second ObjectID- Returns:
- the distance between the two objects
-
getKernel
public double[][] getKernel()
Get the kernel matrix.- Returns:
- kernel
-
getSquaredDistance
public double getSquaredDistance(DBIDRef id1, DBIDRef id2)
Returns the squared kernel distance between the two specified objects.- Parameters:
id1
- first ObjectIDid2
- second ObjectID- Returns:
- the distance between the two objects
-
centerMatrix
public static double[][] centerMatrix(double[][] 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, usecenteredMatrix = centerKernelMatrix(uncenteredMatrix.copy()) {
- Parameters:
matrix
- the matrix to be centered- Returns:
- centered matrix (for convenience)
-
centerKernelMatrix
public static double[][] 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, usecenteredMatrix = centerKernelMatrix(uncenteredMatrix.copy()) {
- Parameters:
kernelMatrix
- the kernel matrix to be centered- Returns:
- centered kernelMatrix (for convenience)
-
-