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

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.data.feature.MultivariateDecorrelator
All Implemented Interfaces:
Evaluator<Vectorizable,Vector>, VectorInputEvaluator<Vectorizable,Vector>, VectorOutputEvaluator<Vectorizable,Vector>, CloneableSerializable, Serializable, Cloneable

public class MultivariateDecorrelator
extends AbstractCloneableSerializable
implements Evaluator<Vectorizable,Vector>, VectorInputEvaluator<Vectorizable,Vector>, VectorOutputEvaluator<Vectorizable,Vector>

Decorrelates a data using a mean and full or diagonal covariance matrix.

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

Nested Class Summary
static class MultivariateDecorrelator.DiagonalCovarianceLearner
          The DiagonalCovarianceLearner class implements a BatchLearner object for a MultivariateDecorrelator.
static class MultivariateDecorrelator.FullCovarianceLearner
          The FullCovarianceLearner class implements a BatchLearner object for a MultivariateDecorrelator.
 
Field Summary
protected  MultivariateGaussian gaussian
          The underlying Gaussian.
 
Constructor Summary
MultivariateDecorrelator()
          Creates a new instance of MultivariateDecorrelator with no underlying Gaussian.
MultivariateDecorrelator(MultivariateDecorrelator other)
          Copy constructor.
MultivariateDecorrelator(MultivariateGaussian gaussian)
          Creates a new instance of MultivariateDecorrelator with the given multivariate Gaussian.
MultivariateDecorrelator(Vector mean, Matrix covariance)
          Creates a new instance of MultivariateDecorrelator with the given mean and variance.
 
Method Summary
 MultivariateDecorrelator clone()
          Creates a new copy of this MultivariateDecorrelator.
 Vector evaluate(Vectorizable value)
          Normalizes the given double value by subtracting the mean and dividing by the standard deviation (the square root of the variance).
 Matrix getCovariance()
          Gets the covariance.
 Matrix getCovarianceInverseSquareRoot()
          Gets the square root of the inverse of the covariance matrix.
 MultivariateGaussian getGaussian()
          Gets the underlying multivariate Gaussian.
 int getInputDimensionality()
          Gets the expected dimensionality of the input vector to the evaluator, if it is known.
 Vector getMean()
          Gets the mean of the underlying Gaussian.
 int getOutputDimensionality()
          Gets the expected dimensionality of the output vector of the evaluator, if it is known.
static MultivariateDecorrelator learnDiagonalCovariance(Collection<? extends Vectorizable> values, double defaultCovariance)
          Learns a normalization based on a mean and covariance where the covariance matrix is diagonal.
static MultivariateDecorrelator learnFullCovariance(Collection<? extends Vectorizable> values, double defaultCovariance)
          Learns a normalization based on a mean and full covariance matrix from the given data.
 void setGaussian(MultivariateGaussian gaussian)
          Sets the underlying multivariate Gaussian.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gaussian

protected MultivariateGaussian gaussian
The underlying Gaussian.

Constructor Detail

MultivariateDecorrelator

public MultivariateDecorrelator()
Creates a new instance of MultivariateDecorrelator with no underlying Gaussian. It will have to be set later on using setGaussian.


MultivariateDecorrelator

public MultivariateDecorrelator(Vector mean,
                                Matrix covariance)
Creates a new instance of MultivariateDecorrelator with the given mean and variance.

Parameters:
mean - The mean.
covariance - The variance.

MultivariateDecorrelator

public MultivariateDecorrelator(MultivariateGaussian gaussian)
Creates a new instance of MultivariateDecorrelator with the given multivariate Gaussian.

Parameters:
gaussian - The multivariate Gaussian to use.

MultivariateDecorrelator

public MultivariateDecorrelator(MultivariateDecorrelator other)
Copy constructor.

Parameters:
other - MultivariateDecorrelator to copy
Method Detail

clone

public MultivariateDecorrelator clone()
Creates a new copy of this MultivariateDecorrelator.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractCloneableSerializable
Returns:
A new copy of this MultivariateDecorrelator.

evaluate

public Vector evaluate(Vectorizable value)
Normalizes the given double value by subtracting the mean and dividing by the standard deviation (the square root of the variance).

Specified by:
evaluate in interface Evaluator<Vectorizable,Vector>
Parameters:
value - The value to normalize.
Returns:
The normalized value.

getInputDimensionality

public int getInputDimensionality()
Description copied from interface: VectorInputEvaluator
Gets the expected dimensionality of the input vector to the evaluator, if it is known. If it is not known, -1 is returned.

Specified by:
getInputDimensionality in interface VectorInputEvaluator<Vectorizable,Vector>
Returns:
The expected dimensionality of the input vector to the evaluator, or -1 if it is not known.

getOutputDimensionality

public int getOutputDimensionality()
Description copied from interface: VectorOutputEvaluator
Gets the expected dimensionality of the output vector of the evaluator, if it is known. If it is not known, -1 is returned.

Specified by:
getOutputDimensionality in interface VectorOutputEvaluator<Vectorizable,Vector>
Returns:
The expected dimensionality of the output vector of the evaluator, or -1 if it is not known.

getMean

public Vector getMean()
Gets the mean of the underlying Gaussian.

Returns:
The mean.

getCovariance

public Matrix getCovariance()
Gets the covariance.

Returns:
The covariance

getGaussian

public MultivariateGaussian getGaussian()
Gets the underlying multivariate Gaussian.

Returns:
The underlying multivariate Gaussian.

setGaussian

public void setGaussian(MultivariateGaussian gaussian)
Sets the underlying multivariate Gaussian. A copy of this Gaussian is kept in the object.

Parameters:
gaussian - The Gaussian to use.

getCovarianceInverseSquareRoot

public Matrix getCovarianceInverseSquareRoot()
Gets the square root of the inverse of the covariance matrix. This value is what is used to perform the normalization.

Returns:
The square root of the inverse of the covariance matrix.

learnFullCovariance

public static MultivariateDecorrelator learnFullCovariance(Collection<? extends Vectorizable> values,
                                                           double defaultCovariance)
Learns a normalization based on a mean and full covariance matrix from the given data.

Parameters:
values - The values to learn the decorrelator from.
defaultCovariance - The default value for the covariance. Added to the diagonal of the covariance matrix to prevent singular values.
Returns:
The MultivariateDecorrelator created from the multivariate mean and variance.

learnDiagonalCovariance

public static MultivariateDecorrelator learnDiagonalCovariance(Collection<? extends Vectorizable> values,
                                                               double defaultCovariance)
Learns a normalization based on a mean and covariance where the covariance matrix is diagonal. That is, each dimension is treated separately.

Parameters:
values - The values to use to build the normalizer.
defaultCovariance - The default value for the covariance. Added to the diagonal of the covariance matrix to prevent singular values.
Returns:
The MultivariateDecorrelator created from the multivariate mean and variance of the given values.