Class LinearRegressionCoefficientExtractor

  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.evaluator.AbstractStatefulEvaluator<Vector,Vector,FiniteCapacityBuffer<Vector>>
          extended by
All Implemented Interfaces:
Evaluator<Vector,Vector>, StatefulEvaluator<Vector,Vector,FiniteCapacityBuffer<Vector>>, CloneableSerializable, Serializable, Cloneable

@CodeReview(reviewer="Kevin R. Dixon",
            comments={"Encapsulated members, added a comment to virtually every method and member.","Added comment about the regression equation.","No additional changes needed."})
public class LinearRegressionCoefficientExtractor
extends AbstractStatefulEvaluator<Vector,Vector,FiniteCapacityBuffer<Vector>>

Takes a sampled sequence of equal-dimension vectors as input and computes the linear regression coefficients for each dimension in the vectors. In other words, it compute the best-fit equation:
y_i = m*x_i + b,
where "m" and "b" are the slope and offset for that dimension in the buffer. For each "i" vector dimension in the regression buffer. Thus, if one puts vectors of dimension "n" into the buffer, at each timestep, one will get one vector of slopes (m) and one vector of offsets (b), each of dimension n. The output of the evaluate() method is a Matrix with first column of slopes, and the next column of offsets.

Justin Basilico
See Also:
Serialized Form

Field Summary
          Default maximum buffer size, 20.
Constructor Summary
          Default constructor.
LinearRegressionCoefficientExtractor(int maxBufferSize)
          Creates new instance of LinearRegressionEvaluator
Method Summary
 LinearRegressionCoefficientExtractor clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 FiniteCapacityBuffer<Vector> createDefaultState()
          Creates a new default state object.
 Vector evaluate(Vector input)
          Evaluates the object using the given input and current state objects, returning the output.
 int getMaxBufferSize()
          Getter for maxBufferSize
 void setMaxBufferSize(int maxBufferSize)
          Setter for maxBufferSize
Methods inherited from class gov.sandia.cognition.evaluator.AbstractStatefulEvaluator
evaluate, getState, resetState, setState
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


public static final int DEFAULT_MAX_BUFFER_SIZE
Default maximum buffer size, 20.

See Also:
Constant Field Values
Constructor Detail


public LinearRegressionCoefficientExtractor()
Default constructor.


public LinearRegressionCoefficientExtractor(int maxBufferSize)
Creates new instance of LinearRegressionEvaluator

maxBufferSize - maximum number of vectors to hold in the buffer
Method Detail


public LinearRegressionCoefficientExtractor 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
clone in class AbstractStatefulEvaluator<Vector,Vector,FiniteCapacityBuffer<Vector>>
A clone of this object.


public FiniteCapacityBuffer<Vector> createDefaultState()
Description copied from interface: StatefulEvaluator
Creates a new default state object.

A new default state object.


public Vector evaluate(Vector input)
Description copied from interface: StatefulEvaluator
Evaluates the object using the given input and current state objects, returning the output. The current state may be modified by side effect.

input - The input to evaluate.
output that results from the evaluation, state is modified by side effect


public int getMaxBufferSize()
Getter for maxBufferSize

Maximum Buffer size


public void setMaxBufferSize(int maxBufferSize)
Setter for maxBufferSize

maxBufferSize - Maximum buffer size, must be >= 2