gov.sandia.cognition.learning.algorithm.ensemble
Class AbstractWeightedEnsemble<MemberType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.algorithm.ensemble.AbstractWeightedEnsemble<MemberType>
Type Parameters:
MemberType - The type of the members of this weighted ensemble.
All Implemented Interfaces:
Ensemble<WeightedValue<MemberType>>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
WeightedAdditiveEnsemble, WeightedAveragingEnsemble

public class AbstractWeightedEnsemble<MemberType>
extends AbstractCloneableSerializable
implements Ensemble<WeightedValue<MemberType>>

An abstract implementation of the Ensemble interface for ensembles that have a weight associated with each member. Implements the ensemble as a list of weighted values.

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

Field Summary
static double DEFAULT_WEIGHT
          The default weight when adding a member is 1.0.
protected  List<WeightedValue<MemberType>> members
          The members of the ensemble.
 
Constructor Summary
AbstractWeightedEnsemble()
          Creates a new, empty of AbstractWeightedEnsemble.
AbstractWeightedEnsemble(List<WeightedValue<MemberType>> members)
          Creates a new instance of AbstractWeightedEnsemble.
 
Method Summary
 void add(MemberType member)
          Adds the given regression function with a default weight of 1.0.
 void add(MemberType member, double weight)
          Adds the given regression function with a given weight.
 AbstractWeightedEnsemble<MemberType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 int getMemberCount()
          Gets the number of members in the ensemble.
 List<WeightedValue<MemberType>> getMembers()
          Gets the members of the ensemble.
 double getWeightSum()
          Gets the sum of the weights of the ensemble members.
 void setMembers(List<WeightedValue<MemberType>> members)
          Sets the members of the ensemble.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_WEIGHT

public static final double DEFAULT_WEIGHT
The default weight when adding a member is 1.0.

See Also:
Constant Field Values

members

protected List<WeightedValue<MemberType>> members
The members of the ensemble.

Constructor Detail

AbstractWeightedEnsemble

public AbstractWeightedEnsemble()
Creates a new, empty of AbstractWeightedEnsemble.


AbstractWeightedEnsemble

public AbstractWeightedEnsemble(List<WeightedValue<MemberType>> members)
Creates a new instance of AbstractWeightedEnsemble.

Parameters:
members - The members of the ensemble.
Method Detail

clone

public AbstractWeightedEnsemble<MemberType> 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 AbstractCloneableSerializable
Returns:
A clone of this object.

add

public void add(MemberType member)
Adds the given regression function with a default weight of 1.0.

Parameters:
member - The regression function to add.

add

public void add(MemberType member,
                double weight)
Adds the given regression function with a given weight.

Parameters:
member - The regression function to add.
weight - The weight for the new member.

getMemberCount

public int getMemberCount()
Gets the number of members in the ensemble.

Returns:
The number of members in the ensemble.

getWeightSum

public double getWeightSum()
Gets the sum of the weights of the ensemble members.

Returns:
The sum of the ensemble member weights.

getMembers

public List<WeightedValue<MemberType>> getMembers()
Gets the members of the ensemble.

Specified by:
getMembers in interface Ensemble<WeightedValue<MemberType>>
Returns:
The members of the ensemble.

setMembers

public void setMembers(List<WeightedValue<MemberType>> members)
Sets the members of the ensemble.

Parameters:
members - The members of the ensemble.