gov.sandia.cognition.learning.function.kernel
Class VectorFunctionKernel

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.function.kernel.DefaultKernelContainer<Vector>
          extended by gov.sandia.cognition.learning.function.kernel.VectorFunctionKernel
All Implemented Interfaces:
Kernel<Vectorizable>, KernelContainer<Vector>, CloneableSerializable, Serializable, Cloneable

@CodeReview(reviewer="Kevin R. Dixon",
            date="2009-07-08",
            changesNeeded=false,
            comments={"Made clone call super.clone.","Looks fine otherwise."})
public class VectorFunctionKernel
extends DefaultKernelContainer<Vector>
implements Kernel<Vectorizable>

The VectorFunctionKernel implements a kernel that makes use of a vector function plus a kernel that operates on vectors. If no kernel is specified the linear kernel (dot product) is used.

Since:
2.0
Author:
Justin Basilico
See Also:
Serialized Form

Field Summary
protected  VectorFunction function
          The vector function to use.
 
Fields inherited from class gov.sandia.cognition.learning.function.kernel.DefaultKernelContainer
kernel
 
Constructor Summary
VectorFunctionKernel()
          Creates a new instance of VectorFunctionKernel.
VectorFunctionKernel(VectorFunction function)
          Creates a new VectorFunctionKernel from the given function.
VectorFunctionKernel(VectorFunction function, Kernel<? super Vector> kernel)
          Creates a new VectorFunctionKernel from the given function and kernel.
 
Method Summary
 VectorFunctionKernel clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 double evaluate(Vectorizable x, Vectorizable y)
          Evaluates the kernel on the given inputs by first applying the vector function to each input vector and then evaluating the kernel on the results of the vector function.
 VectorFunction getFunction()
          Gets the vector function the kernel is using.
 void setFunction(VectorFunction function)
          Sets the vector function for the kernel to use.
 
Methods inherited from class gov.sandia.cognition.learning.function.kernel.DefaultKernelContainer
getKernel, setKernel
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

function

protected VectorFunction function
The vector function to use.

Constructor Detail

VectorFunctionKernel

public VectorFunctionKernel()
Creates a new instance of VectorFunctionKernel.


VectorFunctionKernel

public VectorFunctionKernel(VectorFunction function)
Creates a new VectorFunctionKernel from the given function. The default linear kernel is used.

Parameters:
function - The vector function to use.

VectorFunctionKernel

public VectorFunctionKernel(VectorFunction function,
                            Kernel<? super Vector> kernel)
Creates a new VectorFunctionKernel from the given function and kernel.

Parameters:
function - The vector function to use.
kernel - The kernel to use.
Method Detail

clone

public VectorFunctionKernel clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class DefaultKernelContainer<Vector>
Returns:
A clone of this object.

evaluate

public double evaluate(Vectorizable x,
                       Vectorizable y)
Evaluates the kernel on the given inputs by first applying the vector function to each input vector and then evaluating the kernel on the results of the vector function. If no kernel is specified then the linear kernel (dot product) is used.

Specified by:
evaluate in interface Kernel<Vectorizable>
Parameters:
x - The first item.
y - The second item.
Returns:
The kernel evaluated on the two given objects.

getFunction

public VectorFunction getFunction()
Gets the vector function the kernel is using.

Returns:
The vector function the kernel is using.

setFunction

public void setFunction(VectorFunction function)
Sets the vector function for the kernel to use.

Parameters:
function - The vector function for the kernel to use.