gov.sandia.cognition.learning.function.scalar
Class LocallyWeightedKernelScalarFunction<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.scalar.KernelScalarFunction<InputType>
              extended by gov.sandia.cognition.learning.function.scalar.LocallyWeightedKernelScalarFunction<InputType>
Type Parameters:
InputType - Input type to the Kernel
All Implemented Interfaces:
Evaluator<InputType,Double>, KernelContainer<InputType>, Regressor<InputType>, ScalarFunction<InputType>, CloneableSerializable, Serializable, Cloneable

public class LocallyWeightedKernelScalarFunction<InputType>
extends KernelScalarFunction<InputType>

The LocallyWeightedKernelScalarFunction class implements a scalar function that uses kernels and does local weighting on them to get the result value. It also includes the ability to bias the function towards a constant when the kernel values are very small.

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

Field Summary
protected  double constantValue
          The constant value is what the constant weight biases the function toward when there is near zero weight.
protected  double constantWeight
          The constant weight is used as a weight for the constant value that is added to the result to bias the function to the constant value.
static double DEFAULT_CONSTANT_VALUE
          The default constant value is 0.0.
static double DEFAULT_CONSTANT_WEIGHT
          The default constant weight is 0.0.
 
Fields inherited from class gov.sandia.cognition.learning.function.scalar.KernelScalarFunction
bias, DEFAULT_BIAS, examples
 
Fields inherited from class gov.sandia.cognition.learning.function.kernel.DefaultKernelContainer
kernel
 
Constructor Summary
LocallyWeightedKernelScalarFunction()
          Creates a new instance of LocallyWeightedKernelScalarFunction.
LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel)
          Creates a new instance of LocallyWeightedKernelScalarFunction with the given kernel.
LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel, Collection<? extends WeightedValue<? extends InputType>> examples)
          Creates a new instance of LocallyWeightedKernelScalarFunction with the given kernel and weighted examples.
LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel, Collection<? extends WeightedValue<? extends InputType>> examples, double bias)
          Creates a new instance of LocallyWeightedKernelScalarFunction with the given kernel, weighted examples, and bias.
LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel, Collection<? extends WeightedValue<? extends InputType>> examples, double bias, double constantWeight, double constantValue)
          Creates a new instance of LocallyWeightedKernelScalarFunction with the given kernel, weighted examples, and bias.
LocallyWeightedKernelScalarFunction(LocallyWeightedKernelScalarFunction<InputType> other)
          Creates a new instance copy of LocallyWeightedKernelScalarFunction.
 
Method Summary
 Double evaluate(InputType input)
          Categorizes the given input vector as a double by: (sum w_i * k(input, x_i)) / (sum k(input, x_i))
 double getConstantValue()
          Gets the constant value.
 double getConstantWeight()
          Gets the constant weight.
 void setConstantValue(double constantValue)
          Sets the constant value.
 void setConstantWeight(double constantWeight)
          Sets the constant weight.
 
Methods inherited from class gov.sandia.cognition.learning.function.scalar.KernelScalarFunction
evaluateAsDouble, getBias, getExamples, setBias, setExamples
 
Methods inherited from class gov.sandia.cognition.learning.function.kernel.DefaultKernelContainer
clone, getKernel, setKernel
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONSTANT_WEIGHT

public static final double DEFAULT_CONSTANT_WEIGHT
The default constant weight is 0.0.

See Also:
Constant Field Values

DEFAULT_CONSTANT_VALUE

public static final double DEFAULT_CONSTANT_VALUE
The default constant value is 0.0.

See Also:
Constant Field Values

constantWeight

protected double constantWeight
The constant weight is used as a weight for the constant value that is added to the result to bias the function to the constant value.


constantValue

protected double constantValue
The constant value is what the constant weight biases the function toward when there is near zero weight.

Constructor Detail

LocallyWeightedKernelScalarFunction

public LocallyWeightedKernelScalarFunction()
Creates a new instance of LocallyWeightedKernelScalarFunction.


LocallyWeightedKernelScalarFunction

public LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel)
Creates a new instance of LocallyWeightedKernelScalarFunction with the given kernel.

Parameters:
kernel - The kernel to use.

LocallyWeightedKernelScalarFunction

public LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel,
                                           Collection<? extends WeightedValue<? extends InputType>> examples)
Creates a new instance of LocallyWeightedKernelScalarFunction with the given kernel and weighted examples.

Parameters:
kernel - The kernel to use.
examples - The weighted examples.

LocallyWeightedKernelScalarFunction

public LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel,
                                           Collection<? extends WeightedValue<? extends InputType>> examples,
                                           double bias)
Creates a new instance of LocallyWeightedKernelScalarFunction with the given kernel, weighted examples, and bias.

Parameters:
kernel - The kernel to use.
examples - The weighted examples.
bias - The bias.

LocallyWeightedKernelScalarFunction

public LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel,
                                           Collection<? extends WeightedValue<? extends InputType>> examples,
                                           double bias,
                                           double constantWeight,
                                           double constantValue)
Creates a new instance of LocallyWeightedKernelScalarFunction with the given kernel, weighted examples, and bias.

Parameters:
kernel - The kernel to use.
examples - The weighted examples.
bias - The bias.
constantWeight - The constant bias weight to use.
constantValue - The constant bias value to use.

LocallyWeightedKernelScalarFunction

public LocallyWeightedKernelScalarFunction(LocallyWeightedKernelScalarFunction<InputType> other)
Creates a new instance copy of LocallyWeightedKernelScalarFunction.

Parameters:
other - The object to copy.
Method Detail

evaluate

public Double evaluate(InputType input)
Categorizes the given input vector as a double by: (sum w_i * k(input, x_i)) / (sum k(input, x_i))

Specified by:
evaluate in interface Evaluator<InputType,Double>
Overrides:
evaluate in class KernelScalarFunction<InputType>
Parameters:
input - The input to categorize.
Returns:
The output categorization as a double where the sign is the categorization.

getConstantWeight

public double getConstantWeight()
Gets the constant weight.

Returns:
The constant weight.

setConstantWeight

public void setConstantWeight(double constantWeight)
Sets the constant weight.

Parameters:
constantWeight - The constant weight.

getConstantValue

public double getConstantValue()
Gets the constant value.

Returns:
The constant value.

setConstantValue

public void setConstantValue(double constantValue)
Sets the constant value.

Parameters:
constantValue - The constant value.