gov.sandia.cognition.statistics.bayesian
Class BayesianLinearRegression

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.statistics.bayesian.BayesianLinearRegression
All Implemented Interfaces:
BatchLearner<Collection<? extends InputOutputPair<? extends Vectorizable,Double>>,MultivariateGaussian>, BayesianEstimator<InputOutputPair<? extends Vectorizable,Double>,Vector,MultivariateGaussian>, BayesianRegression<Double,MultivariateGaussian>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
BayesianLinearRegression.IncrementalEstimator

@PublicationReferences(references={@PublicationReference(author="Christopher M. Bishop",title="Pattern Recognition and Machine Learning",type=Book,year=2006,pages={152,159}),@PublicationReference(author="Hanna M. Wallach",title="Introduction to Gaussian Process Regression",type=Misc,year=2005,url="http://www.cs.umass.edu/~wallach/talks/gp_intro.pdf"),@PublicationReference(author="Wikipedia",title="Bayesian linear regression",type=WebPage,year=2010,url="http://en.wikipedia.org/wiki/Bayesian_linear_regression")})
public class BayesianLinearRegression
extends AbstractCloneableSerializable
implements BayesianRegression<Double,MultivariateGaussian>

Computes a Bayesian linear estimator for a given feature function and a set of observed data.

Since:
3.0
Author:
Kevin R. Dixon
See Also:
Serialized Form

Nested Class Summary
static class BayesianLinearRegression.IncrementalEstimator
          Incremental estimator for BayesianLinearRegression
 class BayesianLinearRegression.PredictiveDistribution
          Creates the predictive distribution for the likelihood of a given point.
 
Field Summary
static double DEFAULT_OUTPUT_VARIANCE
          Default output variance, 1.0.
static double DEFAULT_WEIGHT_VARIANCE
          Default weight variance, 1.0.
protected  double outputVariance
          Assumed known variance of the outputs (measurements), must be greater than zero.
protected  MultivariateGaussian weightPrior
          Prior distribution of the weights, typically a zero-mean, diagonal-variance distribution.
 
Constructor Summary
BayesianLinearRegression(double outputVariance, MultivariateGaussian weightPrior)
          Creates a new instance of BayesianLinearRegression
BayesianLinearRegression(int dimensionality)
          Creates a new instance of BayesianLinearRegression
 
Method Summary
 BayesianLinearRegression clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 UnivariateGaussian createConditionalDistribution(Vectorizable input, Vector weights)
          Creates the distribution from which the outputs are generated, given the weights and the input to consider.
 BayesianLinearRegression.PredictiveDistribution createPredictiveDistribution(MultivariateGaussian posterior)
          Creates the predictive distribution of outputs given the weight posterior
 double getOutputVariance()
          Getter for outputVariance
 MultivariateGaussian getWeightPrior()
          Getter for weightPrior
 MultivariateGaussian.PDF learn(Collection<? extends InputOutputPair<? extends Vectorizable,Double>> data)
          The learn method creates an object of ResultType using data of type DataType, using some form of "learning" algorithm.
 void setOutputVariance(double outputVariance)
          Setter for outputVariance
 void setWeightPrior(MultivariateGaussian weightPrior)
          Setter for weightPrior
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_OUTPUT_VARIANCE

public static final double DEFAULT_OUTPUT_VARIANCE
Default output variance, 1.0.

See Also:
Constant Field Values

DEFAULT_WEIGHT_VARIANCE

public static final double DEFAULT_WEIGHT_VARIANCE
Default weight variance, 1.0.

See Also:
Constant Field Values

outputVariance

protected double outputVariance
Assumed known variance of the outputs (measurements), must be greater than zero.


weightPrior

protected MultivariateGaussian weightPrior
Prior distribution of the weights, typically a zero-mean, diagonal-variance distribution.

Constructor Detail

BayesianLinearRegression

public BayesianLinearRegression(int dimensionality)
Creates a new instance of BayesianLinearRegression

Parameters:
dimensionality - Sets up the parameters (except featureMap) for the given dimensionality of objects in feature space.

BayesianLinearRegression

public BayesianLinearRegression(double outputVariance,
                                MultivariateGaussian weightPrior)
Creates a new instance of BayesianLinearRegression

Parameters:
outputVariance - Assumed known variance of the outputs (measurements), must be greater than zero.
weightPrior - Prior distribution of the weights, typically a zero-mean, diagonal-variance distribution.
Method Detail

clone

public BayesianLinearRegression 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.

learn

public MultivariateGaussian.PDF learn(Collection<? extends InputOutputPair<? extends Vectorizable,Double>> 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,Double>>,MultivariateGaussian>
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.

createConditionalDistribution

public UnivariateGaussian createConditionalDistribution(Vectorizable input,
                                                        Vector weights)
Creates the distribution from which the outputs are generated, given the weights and the input to consider.

Specified by:
createConditionalDistribution in interface BayesianRegression<Double,MultivariateGaussian>
Parameters:
input - Input to condition on
weights - Weights that determine the mean
Returns:
Conditional distribution from which outputs are generated.

getWeightPrior

public MultivariateGaussian getWeightPrior()
Getter for weightPrior

Returns:
Prior distribution of the weights, typically a zero-mean, diagonal-variance distribution.

setWeightPrior

public void setWeightPrior(MultivariateGaussian weightPrior)
Setter for weightPrior

Parameters:
weightPrior - Prior distribution of the weights, typically a zero-mean, diagonal-variance distribution.

getOutputVariance

public double getOutputVariance()
Getter for outputVariance

Returns:
Assumed known variance of the outputs (measurements), must be greater than zero.

setOutputVariance

public void setOutputVariance(double outputVariance)
Setter for outputVariance

Parameters:
outputVariance - Assumed known variance of the outputs (measurements), must be greater than zero.

createPredictiveDistribution

public BayesianLinearRegression.PredictiveDistribution createPredictiveDistribution(MultivariateGaussian posterior)
Creates the predictive distribution of outputs given the weight posterior

Specified by:
createPredictiveDistribution in interface BayesianRegression<Double,MultivariateGaussian>
Parameters:
posterior - Posterior distribution of weights.
Returns:
Predictive distribution of outputs given the posterior.