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

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.evaluator.AbstractStatefulEvaluator<Vector,Vector,FiniteCapacityBuffer<Vector>>
          extended by gov.sandia.cognition.learning.data.feature.LinearRegressionCoefficientExtractor
All Implemented Interfaces:
Evaluator<Vector,Vector>, StatefulEvaluator<Vector,Vector,FiniteCapacityBuffer<Vector>>, CloneableSerializable, Serializable, Cloneable

@CodeReview(reviewer="Kevin R. Dixon",
            date="2006-07-17",
            changesNeeded=false,
            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.

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

Field Summary
static int DEFAULT_MAX_BUFFER_SIZE
          Default maximum buffer size, 20.
 
Constructor Summary
LinearRegressionCoefficientExtractor()
          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

DEFAULT_MAX_BUFFER_SIZE

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

See Also:
Constant Field Values
Constructor Detail

LinearRegressionCoefficientExtractor

public LinearRegressionCoefficientExtractor()
Default constructor.


LinearRegressionCoefficientExtractor

public LinearRegressionCoefficientExtractor(int maxBufferSize)
Creates new instance of LinearRegressionEvaluator

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

clone

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

createDefaultState

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

Returns:
A new default state object.

evaluate

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.

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

getMaxBufferSize

public int getMaxBufferSize()
Getter for maxBufferSize

Returns:
Maximum Buffer size

setMaxBufferSize

public void setMaxBufferSize(int maxBufferSize)
Setter for maxBufferSize

Parameters:
maxBufferSize - Maximum buffer size, must be >= 2