gov.sandia.cognition.learning.algorithm.ensemble
Class WeightedVotingCategorizerEnsemble<InputType,CategoryType,MemberType extends Evaluator<? super InputType,? extends CategoryType>>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.function.categorization.AbstractCategorizer<InputType,CategoryType>
          extended by gov.sandia.cognition.learning.algorithm.ensemble.WeightedVotingCategorizerEnsemble<InputType,CategoryType,MemberType>
Type Parameters:
InputType - The type of the input to the ensemble. Passed on to each ensemble member categorizer to produce an output.
CategoryType - The type of the output of the ensemble. Also the output of ech ensemble member categorizer.
MemberType - The type of the members of the ensemble, which must be some extension of the Evaluator interface.
All Implemented Interfaces:
Evaluator<InputType,CategoryType>, Ensemble<WeightedValue<MemberType>>, Categorizer<InputType,CategoryType>, DiscriminantCategorizer<InputType,CategoryType,Double>, CloneableSerializable, Serializable, Cloneable

public class WeightedVotingCategorizerEnsemble<InputType,CategoryType,MemberType extends Evaluator<? super InputType,? extends CategoryType>>
extends AbstractCategorizer<InputType,CategoryType>
implements Ensemble<WeightedValue<MemberType>>, DiscriminantCategorizer<InputType,CategoryType,Double>

An ensemble of categorizers where each ensemble member is evaluated with the given input to find the category to which its weighted votes are assigned. The output with the maximum number of votes is the output of the ensemble. The default weight is 1.0, meaning that each ensemble member has equal votes.

Since:
3.0
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.
 
Fields inherited from class gov.sandia.cognition.learning.function.categorization.AbstractCategorizer
categories
 
Constructor Summary
WeightedVotingCategorizerEnsemble()
          Creates a new instance of WeightedVotingCategorizerEnsemble.
WeightedVotingCategorizerEnsemble(Set<CategoryType> categories)
          Creates a new instance of WeightedVotingCategorizerEnsemble.
WeightedVotingCategorizerEnsemble(Set<CategoryType> categories, List<WeightedValue<MemberType>> members)
          Creates a new instance of WeightedVotingCategorizerEnsemble.
 
Method Summary
 void add(MemberType categorizer)
          Adds the given categorizer with a default weight of 1.0.
 void add(MemberType member, double weight)
          Adds the given categorizer with a given weight.
 CategoryType evaluate(InputType input)
          Evaluates the ensemble.
 DefaultDataDistribution<CategoryType> evaluateAsVotes(InputType input)
          Evaluates the ensemble on the given input and returns the distribution of votes over the output categories.
 DefaultWeightedValueDiscriminant<CategoryType> evaluateWithDiscriminant(InputType input)
          Evaluates the ensemble on the given input and returns the category that has the most weighted votes as a pair containing the category and the percent of the weighted votes that it obtained.
 List<WeightedValue<MemberType>> getMembers()
          Gets the members of the ensemble.
 void setMembers(List<WeightedValue<MemberType>> members)
          Sets the members of the ensemble.
 
Methods inherited from class gov.sandia.cognition.learning.function.categorization.AbstractCategorizer
clone, getCategories, setCategories
 
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.Categorizer
getCategories
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 

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 extends Evaluator<? super InputType,? extends CategoryType>>> members
The members of the ensemble.

Constructor Detail

WeightedVotingCategorizerEnsemble

public WeightedVotingCategorizerEnsemble()
Creates a new instance of WeightedVotingCategorizerEnsemble.


WeightedVotingCategorizerEnsemble

public WeightedVotingCategorizerEnsemble(Set<CategoryType> categories)
Creates a new instance of WeightedVotingCategorizerEnsemble.

Parameters:
categories - The set of categories that the ensemble can output.

WeightedVotingCategorizerEnsemble

public WeightedVotingCategorizerEnsemble(Set<CategoryType> categories,
                                         List<WeightedValue<MemberType>> members)
Creates a new instance of WeightedVotingCategorizerEnsemble.

Parameters:
categories - The set of categories that the ensemble can output.
members - The members of the ensemble.
Method Detail

add

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

Parameters:
categorizer - The categorizer to add.

add

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

Parameters:
member - The categorizer to add.
weight - The weight for the new member. Cannot be negative.

evaluate

public CategoryType evaluate(InputType input)
Evaluates the ensemble. It determines the output by evaluating each member and counting the weighted votes for each category output by the member. It then returns the category with the most votes.

Specified by:
evaluate in interface Evaluator<InputType,CategoryType>
Parameters:
input - The input to evaluate.
Returns:
The ensemble evaluated on the given input.

evaluateWithDiscriminant

public DefaultWeightedValueDiscriminant<CategoryType> evaluateWithDiscriminant(InputType input)
Evaluates the ensemble on the given input and returns the category that has the most weighted votes as a pair containing the category and the percent of the weighted votes that it obtained.

Specified by:
evaluateWithDiscriminant in interface DiscriminantCategorizer<InputType,CategoryType,Double>
Parameters:
input - The input to evaluate.
Returns:
The ensemble evaluated on the given input.

evaluateAsVotes

public DefaultDataDistribution<CategoryType> evaluateAsVotes(InputType input)
Evaluates the ensemble on the given input and returns the distribution of votes over the output categories.

Parameters:
input - The input to evaluate.
Returns:
The ensemble's distribution of votes for the given input.

getMembers

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

Specified by:
getMembers in interface Ensemble<WeightedValue<MemberType extends Evaluator<? super InputType,? extends CategoryType>>>
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.