it.uniroma2.sag.kelp.kernel

## Class Kernel

• ### Constructor Summary

Constructors
Constructor and Description
Kernel()
• ### Method Summary

Methods
Modifier and Type Method and Description
void disableCache()
Disables the kernel cache
long getKernelComputations()
Returns the number of times the kernel function has been invoked
long getNumberOfHits()
Returns the number of times a cache hit happened
long getNumberOfMisses()
Returns the number of times a cache miss happened
float innerProduct(Example exA, Example exB)
Returns the kernel similarity between the given examples.
protected abstract float kernelComputation(Example exA, Example exB)
Returns the kernel similarity between the given examples.
void reset()
Resets the kernel statistics (number of kernel computations, cache hits and misses)
void setKernelCache(KernelCache cache)
Sets the cache in which storing the kernel operations in the RKHS defined by this kernel
void setNormCache(SquaredNormCache normCache)
Sets the cache in which storing the quadratic norms in the RKHS defined by this kernel
float squaredNorm(Example example)
Returns the squared norm of the given example in the RKHS defined by this kernel
float squaredNormOfTheDifference(Example exA, Example exB)
Returns the squared norm of the difference between the given examples in the RKHS.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### Kernel

public Kernel()
• ### Method Detail

• #### innerProduct

public final float innerProduct(Example exA,
Example exB)
Returns the kernel similarity between the given examples. This corresponds to the inner product in the implicit Reproducing Kernel Hilbert Space (RKHS)
Parameters:
exA - the first example
exB - the second example
Returns:
the kernel operation between exA and exB
• #### setNormCache

public void setNormCache(SquaredNormCache normCache)
Sets the cache in which storing the quadratic norms in the RKHS defined by this kernel
Parameters:
normCache - the cache for the quadratic norms
• #### setKernelCache

public void setKernelCache(KernelCache cache)
Sets the cache in which storing the kernel operations in the RKHS defined by this kernel
Parameters:
cache - the cache for the kernel operations
• #### kernelComputation

protected abstract float kernelComputation(Example exA,
Example exB)
Returns the kernel similarity between the given examples. This corresponds to the inner product in the implicit Reproducing Kernel Hilbert Space (RKHS)
Parameters:
exA - the first example
exB - the second example
Returns:
the kernel operation between exA and exB
• #### squaredNorm

public float squaredNorm(Example example)
Returns the squared norm of the given example in the RKHS defined by this kernel
Parameters:
example - the example whose squared norm must be computed
Returns:
the squared norm in the RKHS
• #### squaredNormOfTheDifference

public float squaredNormOfTheDifference(Example exA,
Example exB)
Returns the squared norm of the difference between the given examples in the RKHS. It computes ||exA-exB||^2 = + - 2* where defines the inner product between two generic examples a and b in the RKHS defined by this kernel
Parameters:
exA - the first example
exB - the second example
Returns:
the squared norm of the difference in the RKHS
• #### disableCache

public void disableCache()
Disables the kernel cache
• #### getKernelComputations

public long getKernelComputations()
Returns the number of times the kernel function has been invoked
Returns:
the number of performed kernel operations
• #### getNumberOfHits

public long getNumberOfHits()
Returns the number of times a cache hit happened
Returns:
the number of cache hits
• #### getNumberOfMisses

public long getNumberOfMisses()
Returns the number of times a cache miss happened
Returns:
the number of cache misses
• #### reset

public void reset()
Resets the kernel statistics (number of kernel computations, cache hits and misses)