gov.sandia.cognition.learning.function.vector
Class GeneralizedLinearModel

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.function.vector.GeneralizedLinearModel
All Implemented Interfaces:
Evaluator<Vector,Vector>, VectorFunction, VectorInputEvaluator<Vector,Vector>, Vectorizable, VectorizableVectorFunction, VectorOutputEvaluator<Vector,Vector>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
DifferentiableGeneralizedLinearModel

@PublicationReference(author="Wikipedia",
                      title="Generalized linear model",
                      type=WebPage,
                      year=2011,
                      url="http://en.wikipedia.org/wiki/Generalized_linear_model")
public class GeneralizedLinearModel
extends AbstractCloneableSerializable
implements VectorizableVectorFunction, VectorInputEvaluator<Vector,Vector>, VectorOutputEvaluator<Vector,Vector>

A VectorizableVectorFunction that is a matrix multiply followed by a VectorFunction... a no-hidden-layer neural network

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

Constructor Summary
GeneralizedLinearModel()
          Default constructor.
GeneralizedLinearModel(GeneralizedLinearModel other)
          Creates a new instance of GeneralizedLinearModel
GeneralizedLinearModel(int numInputs, int numOutputs, UnivariateScalarFunction scalarFunction)
          Creates a new instance of GeneralizedLinearModel
GeneralizedLinearModel(MultivariateDiscriminant matrixMultiply, UnivariateScalarFunction scalarSquashingFunction)
          Creates a new instance of GeneralizedLinearModel
GeneralizedLinearModel(MultivariateDiscriminant discriminant, VectorFunction squashingFunction)
          Creates a new instance of GeneralizedLinearModel
 
Method Summary
 GeneralizedLinearModel clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 void convertFromVector(Vector parameters)
          Converts the object from a Vector of parameters.
 Vector convertToVector()
          Converts the object to a vector.
 Vector evaluate(Vector input)
          Evaluates the function on the given input and returns the output.
 MultivariateDiscriminant getDiscriminant()
          Getter for discriminant
 int getInputDimensionality()
          Gets the expected dimensionality of the input vector to the evaluator, if it is known.
 int getOutputDimensionality()
          Gets the expected dimensionality of the output vector of the evaluator, if it is known.
 VectorFunction getSquashingFunction()
          Getter for squashingFunction
 void setDiscriminant(MultivariateDiscriminant discriminant)
          Setter for discriminant
 void setSquashingFunction(VectorFunction squashingFunction)
          Setter for squashingFunction
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GeneralizedLinearModel

public GeneralizedLinearModel()
Default constructor. Creates a 1x1 model with an identity function for the output.


GeneralizedLinearModel

public GeneralizedLinearModel(int numInputs,
                              int numOutputs,
                              UnivariateScalarFunction scalarFunction)
Creates a new instance of GeneralizedLinearModel

Parameters:
numInputs - Number of inputs of the function (number of matrix columns)
numOutputs - Number of outputs of the function (number of matrix rows)
scalarFunction - Function to apply to each output

GeneralizedLinearModel

public GeneralizedLinearModel(MultivariateDiscriminant discriminant,
                              VectorFunction squashingFunction)
Creates a new instance of GeneralizedLinearModel

Parameters:
discriminant - GradientDescendable that multiplies an input by the internal matrix
squashingFunction - VectorFunction that is applied to the output of the matrix multiply

GeneralizedLinearModel

public GeneralizedLinearModel(GeneralizedLinearModel other)
Creates a new instance of GeneralizedLinearModel

Parameters:
other - GeneralizedLinearModel to copy

GeneralizedLinearModel

public GeneralizedLinearModel(MultivariateDiscriminant matrixMultiply,
                              UnivariateScalarFunction scalarSquashingFunction)
Creates a new instance of GeneralizedLinearModel

Parameters:
matrixMultiply - GradientDescendable that multiplies an input by the internal matrix
scalarSquashingFunction - scalar function that is applied to the output of the matrix multiply
Method Detail

getDiscriminant

public MultivariateDiscriminant getDiscriminant()
Getter for discriminant

Returns:
GradientDescendable that multiplies an input by the internal matrix

setDiscriminant

public void setDiscriminant(MultivariateDiscriminant discriminant)
Setter for discriminant

Parameters:
discriminant - GradientDescendable that multiplies an input by the internal matrix

getSquashingFunction

public VectorFunction getSquashingFunction()
Getter for squashingFunction

Returns:
VectorFunction that is applied to the output of the matrix multiply

setSquashingFunction

public void setSquashingFunction(VectorFunction squashingFunction)
Setter for squashingFunction

Parameters:
squashingFunction - VectorFunction that is applied to the output of the matrix multiply

convertToVector

public Vector convertToVector()
Description copied from interface: Vectorizable
Converts the object to a vector.

Specified by:
convertToVector in interface Vectorizable
Returns:
The Vector form of the object.

convertFromVector

public void convertFromVector(Vector parameters)
Description copied from interface: Vectorizable
Converts the object from a Vector of parameters.

Specified by:
convertFromVector in interface Vectorizable
Parameters:
parameters - The parameters to incorporate.

evaluate

public Vector evaluate(Vector input)
Description copied from interface: Evaluator
Evaluates the function on the given input and returns the output.

Specified by:
evaluate in interface Evaluator<Vector,Vector>
Parameters:
input - The input to evaluate.
Returns:
The output produced by evaluating the input.

clone

public GeneralizedLinearModel 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 Vectorizable
Specified by:
clone in interface VectorizableVectorFunction
Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractCloneableSerializable
Returns:
A clone of this object.

toString

public String toString()
Overrides:
toString in class Object

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<Vector,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<Vector,Vector>
Returns:
The expected dimensionality of the output vector of the evaluator, or -1 if it is not known.