gov.sandia.cognition.learning.data.feature
Class RandomSubspace

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.util.AbstractRandomized
          extended by gov.sandia.cognition.learning.data.feature.RandomSubspace
All Implemented Interfaces:
BatchLearner<Collection<? extends Vectorizable>,SubVectorEvaluator>, VectorFactoryContainer, CloneableSerializable, Randomized, Serializable, Cloneable

@PublicationReference(title="Random Subspace Method",
                      author="Wikipedia",
                      year=2011,
                      type=WebPage,
                      url="http://en.wikipedia.org/wiki/Random_subspace_method")
public class RandomSubspace
extends AbstractRandomized
implements BatchLearner<Collection<? extends Vectorizable>,SubVectorEvaluator>, Randomized, VectorFactoryContainer

Selects a random subspace from the given vector, which is a random set of indices. It is typically used in the context of ensemble learning to adapt a base learner to increase the variance, similar to the method used in bagging or random forests. Thus, it is also known as attribute bagging.

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

Field Summary
static int DEFAULT_SIZE
          The default size is 10.
protected  int size
          The size of the random subspace to create, which is the number of dimensions that are chosen.
protected  VectorFactory<?> vectorFactory
          The vector factory for the sub vector evaluator to use.
 
Fields inherited from class gov.sandia.cognition.util.AbstractRandomized
random
 
Constructor Summary
RandomSubspace()
          Creates a new RandomSubspace with the default size.
RandomSubspace(int size)
          Creates a new RandomSubspace with the given size.
RandomSubspace(int size, Random random)
          Creates a new RandomSubspace with the given parameters.
RandomSubspace(int size, Random random, VectorFactory<?> vectorFactory)
          Creates a new RandomSubspace with the given parameters.
 
Method Summary
 int getSize()
          Gets the size of the subspace that will be created.
 VectorFactory<? extends Vector> getVectorFactory()
          Gets the vector factory the object to use to create new vectors.
 SubVectorEvaluator learn(Collection<? extends Vectorizable> data)
          The learn method creates an object of ResultType using data of type DataType, using some form of "learning" algorithm.
 void setSize(int size)
          Sets the size of the subspace that will be created.
 void setVectorFactory(VectorFactory<?> vectorFactory)
          Sets the vector factory to use.
 
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
 
Methods inherited from interface gov.sandia.cognition.util.Randomized
getRandom, setRandom
 

Field Detail

DEFAULT_SIZE

public static final int DEFAULT_SIZE
The default size is 10.

See Also:
Constant Field Values

size

protected int size
The size of the random subspace to create, which is the number of dimensions that are chosen.


vectorFactory

protected VectorFactory<?> vectorFactory
The vector factory for the sub vector evaluator to use.

Constructor Detail

RandomSubspace

public RandomSubspace()
Creates a new RandomSubspace with the default size.


RandomSubspace

public RandomSubspace(int size)
Creates a new RandomSubspace with the given size.

Parameters:
size - The size of the subspace to create. Must be positive.

RandomSubspace

public RandomSubspace(int size,
                      Random random)
Creates a new RandomSubspace with the given parameters.

Parameters:
size - The size of the subspace to create. Must be positive.
random - The random number generator to use.

RandomSubspace

public RandomSubspace(int size,
                      Random random,
                      VectorFactory<?> vectorFactory)
Creates a new RandomSubspace with the given parameters.

Parameters:
size - The size of the subspace to create. Must be positive.
random - The random number generator to use.
vectorFactory - The vector factory to use in the result to create
Method Detail

learn

public SubVectorEvaluator learn(Collection<? extends Vectorizable> 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 Vectorizable>,SubVectorEvaluator>
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.

getSize

public int getSize()
Gets the size of the subspace that will be created.

Returns:
The size of the subspace that will be created. Must be positive.

setSize

public void setSize(int size)
Sets the size of the subspace that will be created.

Parameters:
size - The size of the subspace that will be created. Must be positive.

getVectorFactory

public VectorFactory<? extends Vector> getVectorFactory()
Description copied from interface: VectorFactoryContainer
Gets the vector factory the object to use to create new vectors.

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

setVectorFactory

public void setVectorFactory(VectorFactory<?> vectorFactory)
Sets the vector factory to use.

Parameters:
vectorFactory - The vector factory to use.