gov.sandia.cognition.learning.function.categorization
Class KernelBinaryCategorizer<InputType,EntryType extends WeightedValue<? extends InputType>>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.function.categorization.AbstractBinaryCategorizer<InputType>
          extended by gov.sandia.cognition.learning.function.categorization.AbstractDiscriminantBinaryCategorizer<InputType>
              extended by gov.sandia.cognition.learning.function.categorization.KernelBinaryCategorizer<InputType,EntryType>
Type Parameters:
InputType - The input type for the categorizer.
EntryType - The type of weighted value entry in the categorizer's list of examples.
All Implemented Interfaces:
Evaluator<InputType,Boolean>, BinaryCategorizer<InputType>, Categorizer<InputType,Boolean>, DiscriminantBinaryCategorizer<InputType>, DiscriminantCategorizer<InputType,Boolean,Double>, ThresholdBinaryCategorizer<InputType>, KernelContainer<InputType>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
DefaultKernelBinaryCategorizer

public class KernelBinaryCategorizer<InputType,EntryType extends WeightedValue<? extends InputType>>
extends AbstractDiscriminantBinaryCategorizer<InputType>
implements KernelContainer<InputType>, ThresholdBinaryCategorizer<InputType>

The KernelBinaryCategorizer class implements a binary categorizer that uses a kernel to do its categorization. It is parameterized by a kernel function, a list of examples and their weights, and a bias term. This type of classifier represents what is learned by a standard Support Vector Machine or the Kernel Perceptron.

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<EntryType> examples
          The list of weighted examples that are used for categorization.
protected  Kernel<? super InputType> kernel
          The internal kernel.
 
Fields inherited from class gov.sandia.cognition.learning.function.categorization.AbstractBinaryCategorizer
BINARY_CATEGORIES
 
Constructor Summary
KernelBinaryCategorizer()
          Creates a new instance of KernelBinaryCategorizer.
KernelBinaryCategorizer(Kernel<? super InputType> kernel)
          Creates a new instance of KernelBinaryCategorizer with the given kernel.
KernelBinaryCategorizer(Kernel<? super InputType> kernel, Collection<EntryType> examples, double bias)
          Creates a new instance of KernelBinaryCategorizer with the given kernel, weighted examples, and bias.
KernelBinaryCategorizer(KernelBinaryCategorizer<InputType,? extends EntryType> other)
          Creates a new copy of a KernelBinaryCategorizer.
 
Method Summary
 double evaluateAsDouble(InputType input)
          Categorizes the given input vector as a double by: sum w_i * k(input, x_i)
 double getBias()
          Gets the bias term.
 Collection<EntryType> getExamples()
          Gets the list of weighted examples that categorizer is using.
 Kernel<? super InputType> getKernel()
          Gets the kernel.
 double getThreshold()
          Gets the threshold, which is the negative of the bias.
 void setBias(double bias)
          Sets the bias term.
 void setExamples(Collection<EntryType> examples)
          Sets the list of weighted examples that categorizer is using.
 void setKernel(Kernel<? super InputType> kernel)
          Sets the internal kernel.
 void setThreshold(double threshold)
          Sets the threshold, which is the negative of the bias.
 
Methods inherited from class gov.sandia.cognition.learning.function.categorization.AbstractDiscriminantBinaryCategorizer
evaluate, evaluateWithDiscriminant
 
Methods inherited from class gov.sandia.cognition.learning.function.categorization.AbstractBinaryCategorizer
getCategories
 
Methods inherited from class gov.sandia.cognition.util.AbstractCloneableSerializable
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.learning.function.categorization.DiscriminantCategorizer
evaluateWithDiscriminant
 
Methods inherited from interface gov.sandia.cognition.learning.function.categorization.Categorizer
getCategories
 
Methods inherited from interface gov.sandia.cognition.evaluator.Evaluator
evaluate
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 

Field Detail

DEFAULT_BIAS

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

See Also:
Constant Field Values

kernel

protected Kernel<? super InputType> kernel
The internal kernel.


examples

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


bias

protected double bias
The bias term.

Constructor Detail

KernelBinaryCategorizer

public KernelBinaryCategorizer()
Creates a new instance of KernelBinaryCategorizer.


KernelBinaryCategorizer

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

Parameters:
kernel - The kernel to use.

KernelBinaryCategorizer

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

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

KernelBinaryCategorizer

public KernelBinaryCategorizer(KernelBinaryCategorizer<InputType,? extends EntryType> other)
Creates a new copy of a KernelBinaryCategorizer.

Parameters:
other - The KernelBinaryCategorizer to copy.
Method Detail

evaluateAsDouble

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

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

getThreshold

public double getThreshold()
Gets the threshold, which is the negative of the bias.

Specified by:
getThreshold in interface ThresholdBinaryCategorizer<InputType>
Returns:
The threshold, which is the negative of the bias.

setThreshold

public void setThreshold(double threshold)
Sets the threshold, which is the negative of the bias.

Specified by:
setThreshold in interface ThresholdBinaryCategorizer<InputType>
Parameters:
threshold - the threshold, which is the negative of the bias.

getExamples

public Collection<EntryType> getExamples()
Gets the list of weighted examples that categorizer is using.

Returns:
The list of weighted examples.

setExamples

public void setExamples(Collection<EntryType> 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.

getKernel

public Kernel<? super InputType> getKernel()
Description copied from interface: KernelContainer
Gets the kernel.

Specified by:
getKernel in interface KernelContainer<InputType>
Returns:
Internal kernel encapsulated by the KernelContainer.

setKernel

public void setKernel(Kernel<? super InputType> kernel)
Sets the internal kernel.

Parameters:
kernel - The internal kernel.