gov.sandia.cognition.learning.function.kernel
Class WeightedKernel<InputType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.function.kernel.DefaultKernelContainer<InputType>
          extended by gov.sandia.cognition.learning.function.kernel.WeightedKernel<InputType>
Type Parameters:
InputType - The type of the input to the Kernel. For example, Vector.
All Implemented Interfaces:
Kernel<InputType>, KernelContainer<InputType>, CloneableSerializable, Weighted, Serializable, Cloneable

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

The WeightedKernel class implements a kernel that takes another kernel, evaluates it, and then the result is rescaled by a given weight.

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

Field Summary
static double DEFAULT_WEIGHT
          The default weight is 1.0.
protected  double weight
          The weight on the kernel.
 
Fields inherited from class gov.sandia.cognition.learning.function.kernel.DefaultKernelContainer
kernel
 
Constructor Summary
WeightedKernel()
          Creates a new instance of WeightedKernel with a default weight of 1.0 and a null kernel.
WeightedKernel(double weight, Kernel<? super InputType> kernel)
          Creates a new instance of WeightedKernel from the given weight and kernel.
 
Method Summary
 WeightedKernel<InputType> clone()
          Creates a copy of this kernel.
 double evaluate(InputType x, InputType y)
          The weighted kernel just passes the kernel evaluation to its own internal kernel and then multiplies it by the weight.
 double getWeight()
          Gets the weight used to rescale the kernel's results.
 void setWeight(double weight)
          Sets the weight used to rescale the kernel's results.
 
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

DEFAULT_WEIGHT

public static final double DEFAULT_WEIGHT
The default weight is 1.0.

See Also:
Constant Field Values

weight

protected double weight
The weight on the kernel. Must be non-negative.

Constructor Detail

WeightedKernel

public WeightedKernel()
Creates a new instance of WeightedKernel with a default weight of 1.0 and a null kernel.


WeightedKernel

public WeightedKernel(double weight,
                      Kernel<? super InputType> kernel)
Creates a new instance of WeightedKernel from the given weight and kernel.

Parameters:
weight - The weight to apply to the kernel. Must be non-negative.
kernel - The actual kernel to evaluate.
Method Detail

clone

public WeightedKernel<InputType> clone()
Creates a copy of this kernel.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class DefaultKernelContainer<InputType>
Returns:
A copy of this kernel.

evaluate

public double evaluate(InputType x,
                       InputType y)
The weighted kernel just passes the kernel evaluation to its own internal kernel and then multiplies it by the weight.

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

getWeight

public double getWeight()
Gets the weight used to rescale the kernel's results.

Specified by:
getWeight in interface Weighted
Returns:
The kernel's weight.

setWeight

public void setWeight(double weight)
Sets the weight used to rescale the kernel's results.

Parameters:
weight - The kernel's weight. Must be non-negative.