gov.sandia.cognition.learning.algorithm.tree
Class RandomSubVectorThresholdLearner<OutputType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.util.AbstractRandomized
          extended by gov.sandia.cognition.learning.algorithm.tree.RandomSubVectorThresholdLearner<OutputType>
Type Parameters:
OutputType - The output type for the decider.
All Implemented Interfaces:
BatchLearner<Collection<? extends InputOutputPair<? extends Vectorizable,OutputType>>,Categorizer<? super Vectorizable,? extends Boolean>>, DeciderLearner<Vectorizable,OutputType,Boolean,Categorizer<? super Vectorizable,? extends Boolean>>, VectorFactoryContainer, CloneableSerializable, Randomized, Serializable, Cloneable

public class RandomSubVectorThresholdLearner<OutputType>
extends AbstractRandomized
implements DeciderLearner<Vectorizable,OutputType,Boolean,Categorizer<? super Vectorizable,? extends Boolean>>, VectorFactoryContainer

Learns a decision function by taking a randomly sampling a subspace from a given set of input vectors and then learning a threshold function by passing the subspace vectors to a sublearner. This component is typically used along with a decision tree learner to create random forests of decision trees.

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

Field Summary
static double DEFAULT_PERCENT_TO_SAMPLE
          The default percent to sample is 0.1.
protected  double percentToSample
          The percentage of the dimensionality to sample.
protected  DeciderLearner<Vectorizable,OutputType,Boolean,VectorElementThresholdCategorizer> subLearner
          The decider learner for the subspace.
protected  VectorFactory<? extends Vector> vectorFactory
          The vector factory to use.
 
Fields inherited from class gov.sandia.cognition.util.AbstractRandomized
random
 
Constructor Summary
RandomSubVectorThresholdLearner()
          Creates a new RandomSubVectorThresholdLearner.
RandomSubVectorThresholdLearner(DeciderLearner<Vectorizable,OutputType,Boolean,VectorElementThresholdCategorizer> subLearner, double percentToSample, Random random)
          Creates a new RandomSubVectorThresholdLearner.
RandomSubVectorThresholdLearner(DeciderLearner<Vectorizable,OutputType,Boolean,VectorElementThresholdCategorizer> subLearner, double percentToSample, Random random, VectorFactory<? extends Vector> vectorFactory)
          Creates a new RandomSubVectorThresholdLearner.
 
Method Summary
 double getPercentToSample()
          Gets the percent of the dimensionality to sample.
 int getSubDimensionality(int dimensionality)
          Gets the dimensionality of the subspace based on the full dimensionality.
 DeciderLearner<Vectorizable,OutputType,Boolean,VectorElementThresholdCategorizer> getSubLearner()
          Gets the learner used to learn a threshold function over the subspace.
 VectorFactory<? extends Vector> getVectorFactory()
          Gets the vector factory.
 VectorElementThresholdCategorizer learn(Collection<? extends InputOutputPair<? extends Vectorizable,OutputType>> data)
          The learn method creates an object of ResultType using data of type DataType, using some form of "learning" algorithm.
 void setPercentToSample(double percentToSample)
          Sets the percent of the dimensionality to sample.
 void setSubLearner(DeciderLearner<Vectorizable,OutputType,Boolean,VectorElementThresholdCategorizer> subLearner)
          Sets the learner used to learn a threshold function over the subspace.
 void setVectorFactory(VectorFactory<? extends Vector> vectorFactory)
          Sets the vector factory.
 
Methods inherited from class gov.sandia.cognition.util.AbstractRandomized
clone, getRandom, setRandom
 
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

DEFAULT_PERCENT_TO_SAMPLE

public static final double DEFAULT_PERCENT_TO_SAMPLE
The default percent to sample is 0.1.

See Also:
Constant Field Values

subLearner

protected DeciderLearner<Vectorizable,OutputType,Boolean,VectorElementThresholdCategorizer> subLearner
The decider learner for the subspace.


percentToSample

protected double percentToSample
The percentage of the dimensionality to sample.


vectorFactory

protected VectorFactory<? extends Vector> vectorFactory
The vector factory to use.

Constructor Detail

RandomSubVectorThresholdLearner

public RandomSubVectorThresholdLearner()
Creates a new RandomSubVectorThresholdLearner.


RandomSubVectorThresholdLearner

public RandomSubVectorThresholdLearner(DeciderLearner<Vectorizable,OutputType,Boolean,VectorElementThresholdCategorizer> subLearner,
                                       double percentToSample,
                                       Random random)
Creates a new RandomSubVectorThresholdLearner.

Parameters:
subLearner - The threshold decision function learner to use over the subspace.
percentToSample - The percentage of the dimensionality to sample (must be between 0.0 (exclusive) and 1.0 (inclusive).
random - The random number generator.

RandomSubVectorThresholdLearner

public RandomSubVectorThresholdLearner(DeciderLearner<Vectorizable,OutputType,Boolean,VectorElementThresholdCategorizer> subLearner,
                                       double percentToSample,
                                       Random random,
                                       VectorFactory<? extends Vector> vectorFactory)
Creates a new RandomSubVectorThresholdLearner.

Parameters:
subLearner - The threshold decision function learner to use over the subspace.
percentToSample - The percentage of the dimensionality to sample (must be between 0.0 and 1.0.
random - The random number generator.
vectorFactory - The vector factory to use.
Method Detail

learn

public VectorElementThresholdCategorizer learn(Collection<? extends InputOutputPair<? extends Vectorizable,OutputType>> 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<Collection<? extends InputOutputPair<? extends Vectorizable,OutputType>>,Categorizer<? super Vectorizable,? extends Boolean>>
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.

getSubDimensionality

public int getSubDimensionality(int dimensionality)
Gets the dimensionality of the subspace based on the full dimensionality.

Parameters:
dimensionality - The full dimensionality
Returns:
The dimensionality of the subspace. Will always be greater than or equal to 1.

getSubLearner

public DeciderLearner<Vectorizable,OutputType,Boolean,VectorElementThresholdCategorizer> getSubLearner()
Gets the learner used to learn a threshold function over the subspace.

Returns:
The learner for the subspace.

setSubLearner

public void setSubLearner(DeciderLearner<Vectorizable,OutputType,Boolean,VectorElementThresholdCategorizer> subLearner)
Sets the learner used to learn a threshold function over the subspace.

Parameters:
subLearner - The learner for the subspace.

getPercentToSample

public double getPercentToSample()
Gets the percent of the dimensionality to sample. Must be between 0.0 and 1.0.

Returns:
The percent of the dimensionality to sample.

setPercentToSample

public void setPercentToSample(double percentToSample)
Sets the percent of the dimensionality to sample. Must be between 0.0 and 1.0.

Parameters:
percentToSample - The percent of the dimensionality to sample.

getVectorFactory

public VectorFactory<? extends Vector> getVectorFactory()
Gets the vector factory.

Specified by:
getVectorFactory in interface VectorFactoryContainer
Returns:
The vector factory.

setVectorFactory

public void setVectorFactory(VectorFactory<? extends Vector> vectorFactory)
Sets the vector factory.

Parameters:
vectorFactory - The vector factory.