public class KernelMatrix extends Object
Modifier and Type | Class and Description |
---|---|
private static interface |
KernelMatrix.DBIDMap
Map a DBID to its offset
TODO: move to shared code.
|
private static class |
KernelMatrix.RangeMap
Map a DBID to an integer offset, DBIDRange version.
|
private static class |
KernelMatrix.SortedArrayMap
Map a DBID to an integer offset, Version to support arbitrary DBIDs.
|
Modifier and Type | Field and Description |
---|---|
(package private) KernelMatrix.DBIDMap |
idmap
Static mapping from DBIDs to indexes.
|
(package private) Matrix |
kernel
The kernel matrix
|
Constructor and Description |
---|
KernelMatrix(Matrix matrix)
Makes a new kernel matrix from matrix (with data copying).
|
KernelMatrix(PrimitiveSimilarityFunction<? super O,D> kernelFunction,
Relation<? extends O> relation,
DBIDs ids)
Provides a new kernel matrix.
|
KernelMatrix(SimilarityQuery<? super O,D> kernelFunction,
Relation<? extends O> relation,
DBIDs ids)
Provides a new kernel matrix.
|
Modifier and Type | Method and Description |
---|---|
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 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.
|
Matrix |
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.
|
Matrix |
getSubColumn(DBIDRef i1,
DBIDs ids)
Deprecated.
|
Matrix |
getSubMatrix(DBIDs ids)
Returns a sub kernel matrix for all objects in ids
|
String |
toString() |
Matrix kernel
KernelMatrix.DBIDMap idmap
public KernelMatrix(PrimitiveSimilarityFunction<? super O,D> kernelFunction, Relation<? extends O> relation, DBIDs ids)
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 computedpublic KernelMatrix(SimilarityQuery<? super O,D> kernelFunction, Relation<? extends O> relation, DBIDs ids)
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 computedpublic KernelMatrix(Matrix matrix)
matrix
- a matrixpublic double getDistance(DBIDRef o1, DBIDRef o2)
o1
- first ObjectIDo2
- second ObjectIDpublic Matrix getKernel()
public double getSquaredDistance(DBIDRef id1, DBIDRef id2)
id1
- first ObjectIDid2
- second ObjectID@Deprecated public Matrix getSubColumn(DBIDRef i1, DBIDs ids)
i1
- the column which should be returnedids
- the objectspublic Matrix getSubMatrix(DBIDs ids)
ids
- the objectspublic static Matrix centerMatrix(Matrix matrix)
centeredMatrix = centerKernelMatrix(uncenteredMatrix.copy()) {
matrix
- the matrix to be centeredpublic static Matrix centerKernelMatrix(KernelMatrix kernelMatrix)
centeredMatrix = centerKernelMatrix(uncenteredMatrix.copy()) {
kernelMatrix
- the kernel matrix to be centered