public class CustomTrainTestMatrixKernel extends Kernel<java.lang.Integer>
Kernel with provided custom train and test matrices.
The datatype of input space is integer relative to row/column indices.
Therefore, the similarity between elements i and j is matrix[i][j].
Two matrices have to be provided: the first is train[nb_train][nb_train], and the second
is test[nb_train][nb_test].
We suppose the train indices start at 0, and the test indices start at
nb_train (the number of rows in the train matrix). For example, if you have 5
training samples and 10 testing samples, the train matrix is 5x5 and the test
matrix is 5x10. This means that valid training indices are {0, 1, 2, 3, 4}
and valid testing indices are {5, 6, 7, 8, 9, 10, 11, 12, 13, 14}.
To get the similarity between the first training sample and the first testing
sample, you thus have to call valueOf(0, 5+0). The kernel automatically
translates the second index for the test matrix and returns test[0][0].
Constructor and Description |
---|
CustomTrainTestMatrixKernel(double[][] train,
double[][] test)
Constructor using the supplied Gram matrices.
|
Modifier and Type | Method and Description |
---|---|
double |
valueOf(java.lang.Integer t1)
kernel similarity to zero
|
double |
valueOf(java.lang.Integer t1,
java.lang.Integer t2)
compute the kernel similarity between two element of input space
|
getKernelMatrix, getNormalizedKernelMatrix, normalizedValueOf, setName, toString
public CustomTrainTestMatrixKernel(double[][] train, double[][] test)
train
- the Gram matrix of underlying kernel function for train/train
similarity.test
- the Gram matrix for the train/test similarity.public double valueOf(java.lang.Integer t1, java.lang.Integer t2)
Kernel