gov.sandia.cognition.learning.function.scalar
Class KernelScalarFunction<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>
Type Parameters:
InputType - The type of the input to the function. For example, Vector.
All Implemented Interfaces:
Evaluator<InputType,Double>, KernelContainer<InputType>, Regressor<InputType>, ScalarFunction<InputType>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
LocallyWeightedKernelScalarFunction

public class KernelScalarFunction<InputType>
extends DefaultKernelContainer<InputType>
implements Regressor<InputType>

The KernelScalarFunction class implements a scalar function that uses a kernel to compute its output value. It is parameterized by a kernel function, a list of examples and their weights, and a bias term. This types of scalar function represents what is learned by algorithms such as Support Vector Regression.

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

Field Summary
protected  double bias
          The bias term.
static double DEFAULT_BIAS
          The default value for the bias is 0.0.
protected  Collection<? extends WeightedValue<? extends InputType>> examples
          The list of weighted examples that are used for categorization.
 
Fields inherited from class gov.sandia.cognition.learning.function.kernel.DefaultKernelContainer
kernel
 
Constructor Summary
KernelScalarFunction()
          Creates a new instance of KernelScalarFunction.
KernelScalarFunction(Kernel<? super InputType> kernel)
          Creates a new instance of KernelScalarFunction with the given kernel.
KernelScalarFunction(Kernel<? super InputType> kernel, Collection<? extends WeightedValue<? extends InputType>> examples, double bias)
          Creates a new instance of KernelScalarFunction with the given kernel, weighted examples, and bias.
KernelScalarFunction(KernelScalarFunction<InputType> other)
          Creates a new copy of a KernelScalarFunction.
 
Method Summary
 Double evaluate(InputType input)
          Evaluates the given input vector as a double by: sum w_i * k(input, x_i)
 double evaluateAsDouble(InputType input)
          Evaluates the given input vector as a double by: sum w_i * k(input, x_i)
 double getBias()
          Gets the bias term.
 Collection<? extends WeightedValue<? extends InputType>> getExamples()
          Gets the list of weighted examples that categorizer is using.
 void setBias(double bias)
          Sets the bias term.
 void setExamples(Collection<? extends WeightedValue<? extends InputType>> examples)
          Sets the list of weighted examples that categorizer is using.
 
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_BIAS

public static final double DEFAULT_BIAS
The default value for the bias is 0.0.

See Also:
Constant Field Values

examples

protected Collection<? extends WeightedValue<? extends InputType>> examples
The list of weighted examples that are used for categorization.


bias

protected double bias
The bias term.

Constructor Detail

KernelScalarFunction

public KernelScalarFunction()
Creates a new instance of KernelScalarFunction.


KernelScalarFunction

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

Parameters:
kernel - The kernel to use.

KernelScalarFunction

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

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

KernelScalarFunction

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

Parameters:
other - The KernelScalarFunction to copy.
Method Detail

evaluate

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

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

evaluateAsDouble

public double evaluateAsDouble(InputType input)
Evaluates the given input vector as a double by: sum w_i * k(input, x_i)

Specified by:
evaluateAsDouble in interface ScalarFunction<InputType>
Parameters:
input - The input to categorize.
Returns:
The output categorization as a double where the sign is the categorization.

getExamples

public Collection<? extends WeightedValue<? extends InputType>> getExamples()
Gets the list of weighted examples that categorizer is using.

Returns:
The list of weighted examples.

setExamples

public void setExamples(Collection<? extends WeightedValue<? extends InputType>> examples)
Sets the list of weighted examples that categorizer is using.

Parameters:
examples - The list of weighted examples.

getBias

public double getBias()
Gets the bias term.

Returns:
bias The bias term.

setBias

public void setBias(double bias)
Sets the bias term.

Parameters:
bias - The bias term.