gov.sandia.cognition.learning.parameter
Class ParameterAdaptableBatchLearnerWrapper<DataType,ResultType,LearnerType extends BatchLearner<? super DataType,? extends ResultType>>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.algorithm.AbstractBatchLearnerContainer<LearnerType>
          extended by gov.sandia.cognition.learning.parameter.ParameterAdaptableBatchLearnerWrapper<DataType,ResultType,LearnerType>
Type Parameters:
DataType - Type of data to use.
ResultType - Type of result to return.
LearnerType - Type of BatchLearner to use.
All Implemented Interfaces:
BatchLearner<DataType,ResultType>, BatchLearnerContainer<LearnerType>, ParameterAdaptable<LearnerType,DataType>, CloneableSerializable, Serializable, Cloneable

public class ParameterAdaptableBatchLearnerWrapper<DataType,ResultType,LearnerType extends BatchLearner<? super DataType,? extends ResultType>>
extends AbstractBatchLearnerContainer<LearnerType>
implements BatchLearner<DataType,ResultType>, ParameterAdaptable<LearnerType,DataType>

A wrapper for adding parameter adapters to a batch learner. It simply passes the learner and the data to the parameter adapters attached to the wrapper before calling the learner.

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

Field Summary
protected  LinkedList<ParameterAdapter<? super LearnerType,? super DataType>> parameterAdapters
          The list of parameter adapters for the learner.
 
Fields inherited from class gov.sandia.cognition.learning.algorithm.AbstractBatchLearnerContainer
learner
 
Constructor Summary
ParameterAdaptableBatchLearnerWrapper()
          Creates a new ParameterAdaptableBatchLearnerWrapper.
ParameterAdaptableBatchLearnerWrapper(LearnerType learner)
          Creates a new ParameterAdaptableBatchLearnerWrapper.
 
Method Summary
 void addParameterAdapter(ParameterAdapter<? super LearnerType,? super DataType> parameterAdapter)
          Adds the given parameter adapter to this object.
 ParameterAdaptableBatchLearnerWrapper<DataType,ResultType,LearnerType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
static
<DataType,ResultType,LearnerType extends BatchLearner<? super DataType,? extends ResultType>>
ParameterAdaptableBatchLearnerWrapper<DataType,ResultType,LearnerType>
create(LearnerType learner)
          A convenience method for creating the wrapper for a learner.
 LinkedList<ParameterAdapter<? super LearnerType,? super DataType>> getParameterAdapters()
          Gets the collection of parameter adapters attached to this object.
 ResultType learn(DataType data)
          The learn method creates an object of ResultType using data of type DataType, using some form of "learning" algorithm.
 void removeParameterAdapter(ParameterAdapter<? super LearnerType,? super DataType> parameterAdapter)
          Removes the given parameter adapter from this object.
 void setParameterAdapters(LinkedList<ParameterAdapter<? super LearnerType,? super DataType>> parameterAdapters)
          Sets the list of parameter adapters for the learning algorithm.
 
Methods inherited from class gov.sandia.cognition.learning.algorithm.AbstractBatchLearnerContainer
getLearner, setLearner
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parameterAdapters

protected LinkedList<ParameterAdapter<? super LearnerType extends BatchLearner<? super DataType,? extends ResultType>,? super DataType>> parameterAdapters
The list of parameter adapters for the learner. It should be null if there are no adapters.

Constructor Detail

ParameterAdaptableBatchLearnerWrapper

public ParameterAdaptableBatchLearnerWrapper()
Creates a new ParameterAdaptableBatchLearnerWrapper.


ParameterAdaptableBatchLearnerWrapper

public ParameterAdaptableBatchLearnerWrapper(LearnerType learner)
Creates a new ParameterAdaptableBatchLearnerWrapper.

Parameters:
learner - The learner whose parameters are to be adapted.
Method Detail

clone

public ParameterAdaptableBatchLearnerWrapper<DataType,ResultType,LearnerType> clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractBatchLearnerContainer<LearnerType extends BatchLearner<? super DataType,? extends ResultType>>
Returns:
A clone of this object.

learn

public ResultType learn(DataType 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<DataType,ResultType>
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.

addParameterAdapter

public void addParameterAdapter(ParameterAdapter<? super LearnerType,? super DataType> parameterAdapter)
Description copied from interface: ParameterAdaptable
Adds the given parameter adapter to this object.

Specified by:
addParameterAdapter in interface ParameterAdaptable<LearnerType extends BatchLearner<? super DataType,? extends ResultType>,DataType>
Parameters:
parameterAdapter - The parameter adapter to add.

removeParameterAdapter

public void removeParameterAdapter(ParameterAdapter<? super LearnerType,? super DataType> parameterAdapter)
Description copied from interface: ParameterAdaptable
Removes the given parameter adapter from this object.

Specified by:
removeParameterAdapter in interface ParameterAdaptable<LearnerType extends BatchLearner<? super DataType,? extends ResultType>,DataType>
Parameters:
parameterAdapter - The parameter adapter to remove.

getParameterAdapters

public LinkedList<ParameterAdapter<? super LearnerType,? super DataType>> getParameterAdapters()
Description copied from interface: ParameterAdaptable
Gets the collection of parameter adapters attached to this object.

Specified by:
getParameterAdapters in interface ParameterAdaptable<LearnerType extends BatchLearner<? super DataType,? extends ResultType>,DataType>
Returns:
The parameter adapters attached to this object.

setParameterAdapters

public void setParameterAdapters(LinkedList<ParameterAdapter<? super LearnerType,? super DataType>> parameterAdapters)
Sets the list of parameter adapters for the learning algorithm.

Parameters:
parameterAdapters - The list of parameter adapters for the learning algorithm.

create

public static <DataType,ResultType,LearnerType extends BatchLearner<? super DataType,? extends ResultType>> ParameterAdaptableBatchLearnerWrapper<DataType,ResultType,LearnerType> create(LearnerType learner)
A convenience method for creating the wrapper for a learner.

Type Parameters:
DataType - Type of data to use.
ResultType - Type of result to return.
LearnerType - Type of BatchLearner to use.
Parameters:
learner - The learner whose parameters are to be adapted.
Returns:
A new ParameterAdaptableBatchLearnerWrapper.