gov.sandia.cognition.learning.algorithm.baseline
Class ConstantLearner<ValueType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.algorithm.baseline.ConstantLearner<ValueType>
Type Parameters:
ValueType - The type of the constant value returned as the result of learning.
All Implemented Interfaces:
BatchLearner<Object,ValueType>, CloneableSerializable, Serializable, Cloneable

public class ConstantLearner<ValueType>
extends AbstractCloneableSerializable
implements BatchLearner<Object,ValueType>

A learner that always returns the same value as the result. This is not really a learner, but more of an adapter class when you need to stub in a constant value into the learning framework.

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

Field Summary
protected  ValueType value
          The result of learning.
 
Constructor Summary
ConstantLearner()
          Creates a new ConstantLearner with a null value.
ConstantLearner(ValueType value)
          Creates a new ConstantLearner with the given value;
 
Method Summary
static
<ValueType>
ConstantLearner<ValueType>
create(ValueType value)
          Creates a new ConstantLearner.
 ValueType getValue()
          Gets the value that is the result of learning.
 ValueType learn(Object data)
          The learn method creates an object of ResultType using data of type DataType, using some form of "learning" algorithm.
 void setValue(ValueType value)
          Sets the value that is the result of learning.
 
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.util.CloneableSerializable
clone
 

Field Detail

value

protected ValueType value
The result of learning.

Constructor Detail

ConstantLearner

public ConstantLearner()
Creates a new ConstantLearner with a null value.


ConstantLearner

public ConstantLearner(ValueType value)
Creates a new ConstantLearner with the given value;

Parameters:
value - The value that is used as the result of learning.
Method Detail

learn

public ValueType learn(Object data)
Description copied from interface: BatchLearner
The learn method creates an object of ResultType using data of type DataType, using some form of "learning" algorithm.

Specified by:
learn in interface BatchLearner<Object,ValueType>
Parameters:
data - The data that the learning algorithm will use to create an object of ResultType.
Returns:
The object that is created based on the given data using the learning algorithm.

getValue

public ValueType getValue()
Gets the value that is the result of learning.

Returns:
The value that is the result of learning.

setValue

public void setValue(ValueType value)
Sets the value that is the result of learning.

Parameters:
value - The value that is the result of learning.

create

public static <ValueType> ConstantLearner<ValueType> create(ValueType value)
Creates a new ConstantLearner.

Type Parameters:
ValueType - The type of value that is the result of learning.
Parameters:
value - The value that is the result of learning.
Returns:
A new ConstantLearner for the given value.