DiagonalCachingKernel (BioJava-1.5-beta API)
Keywords: org.biojava.stats.svm.DiagonalCachingKernel class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.biojava.stats.svm
Class DiagonalCachingKernel

    java.lang.Object
      org.biojava.stats.svm.NestedKernel
          org.biojava.stats.svm.DiagonalCachingKernel

All Implemented Interfaces:
  Serializable, SVMKernel

    public class DiagonalCachingKernel

extends NestedKernel

Caches the leading diagonal of a kernel matrix.

Several kernels need to repeatedly access k(x,x) to do things like normalization, or to calculate distances. This kernel wraps k so that these leading diagonal elements do not need to be calculated each time.

This kernel is thread-safe. However, care must be taken when setting the nested kernel that no other thread is retrieving values at the same time. This would cause a race condition in which the newly flushed cache may contain a value from the previous kernel.

Author:
  Matthew Pocock, Thomas Down
See Also:
  Serialized Form

Constructor Summary
`DiagonalCachingKernel()` Create a new CachingKernel.
`DiagonalCachingKernel(SVMKernel k)` Creates a new DiagonalCachingKernel that nests k.

Method Summary
`double` | `evaluate(Object x, Object y)` Returns the kernel product of two Objects.
`void` | `setNestedKernel(SVMKernel k)` Set the kernel to nest.
`String` | `toString()`

Methods inherited from class org.biojava.stats.svm.NestedKernel
`getNestedKernel`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### DiagonalCachingKernel

    public DiagonalCachingKernel()

  Create a new CachingKernel.

### DiagonalCachingKernel

    public DiagonalCachingKernel(SVMKernel k)

  Creates a new DiagonalCachingKernel that nests k.

Method Detail

### setNestedKernel

    public void setNestedKernel(SVMKernel k)

  Set the kernel to nest.

  This will flush the cache.

  Overrides:
    `setNestedKernel` in class `NestedKernel`
  Parameters:
    `k` - the kernel to nest.

### evaluate

    public double evaluate(Object x,
                           Object y)

  Returns the kernel product of two Objects.

  This returns `getNestedKernel.evaluate(x, y)`. If `x.equals(y)` then it will cache the result first time, and do a hash table look up to retrieve the value in subsequent calls.

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD