gov.sandia.cognition.learning.algorithm.pca
Class KernelPrincipalComponentsAnalysis.Function<DataType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.function.kernel.DefaultKernelContainer<DataType>
          extended by gov.sandia.cognition.learning.algorithm.pca.KernelPrincipalComponentsAnalysis.Function<DataType>
Type Parameters:
DataType - The type of data used with the kernel that the function can be applied to.
All Implemented Interfaces:
Evaluator<DataType,Vector>, KernelContainer<DataType>, VectorOutputEvaluator<DataType,Vector>, CloneableSerializable, Serializable, Cloneable
Enclosing class:
KernelPrincipalComponentsAnalysis<DataType>

public static class KernelPrincipalComponentsAnalysis.Function<DataType>
extends DefaultKernelContainer<DataType>
implements VectorOutputEvaluator<DataType,Vector>

The resulting transformation function learned by Kernel Principal Components Analysis. It can take any data item from the input space and return a vector version of that item transformed into the principal components space.

See Also:
Serialized Form

Field Summary
protected  boolean centerData
          A flag indicating if the incoming data needs to be centered or not.
protected  Matrix components
          The matrix of components for the function.
protected  List<? extends DataType> data
          The data that the KPCA was performed over.
protected  Matrix kernelMatrix
          The kernel matrix for all the data the KPCA was done over.
 
Fields inherited from class gov.sandia.cognition.learning.function.kernel.DefaultKernelContainer
kernel
 
Constructor Summary
KernelPrincipalComponentsAnalysis.Function()
          Creates a new, empty Kernel Principal Components Analysis function.
KernelPrincipalComponentsAnalysis.Function(Kernel<? super DataType> kernel, List<? extends DataType> data, Matrix components, boolean centerData, Matrix kernelMatrix)
          Creates a new Kernel Principal Components Analysis function.
 
Method Summary
 Vector evaluate(DataType input)
          Evaluates the function on the given input and returns the output.
 int getComponentCount()
          Gets the number of components in the analysis result.
 Matrix getComponents()
          Gets the matrix of components from the analysis.
 List<? extends DataType> getData()
          Gets the data that was used in the analysis.
 Matrix getKernelMatrix()
          Gets the kernel matrix for the data that the analysis was done over.
 int getOutputDimensionality()
          Gets the expected dimensionality of the output vector of the evaluator, if it is known.
 boolean isCenterData()
          Gets whether or not the data needs to be centered in the kernel space before applying the function.
 void setCenterData(boolean centerData)
          Sets whether or not the data needs to be centered in the kernel space before applying the function.
 void setComponents(Matrix components)
          Sets the matrix of components from the analysis.
 void setData(List<? extends DataType> data)
          Sets the data that was used in the analysis.
 void setKernelMatrix(Matrix kernelMatrix)
          Sets the kernel matrix for the data that the analysis was done over.
 
Methods inherited from class gov.sandia.cognition.learning.function.kernel.DefaultKernelContainer
clone, getKernel, setKernel
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected List<? extends DataType> data
The data that the KPCA was performed over. Each one corresponds to a column in the components matrix.


components

protected Matrix components
The matrix of components for the function. The number of rows is the dimensionality of the reduction. The number of columns is equal to the number of data points that the KPCA was done over.


centerData

protected boolean centerData
A flag indicating if the incoming data needs to be centered or not. Unless the data is being pre-centered, this should be true.


kernelMatrix

protected Matrix kernelMatrix
The kernel matrix for all the data the KPCA was done over. It is a square matrix whose size is equal to the data.

Constructor Detail

KernelPrincipalComponentsAnalysis.Function

public KernelPrincipalComponentsAnalysis.Function()
Creates a new, empty Kernel Principal Components Analysis function.


KernelPrincipalComponentsAnalysis.Function

public KernelPrincipalComponentsAnalysis.Function(Kernel<? super DataType> kernel,
                                                  List<? extends DataType> data,
                                                  Matrix components,
                                                  boolean centerData,
                                                  Matrix kernelMatrix)
Creates a new Kernel Principal Components Analysis function.

Parameters:
kernel - The kernel to use.
data - The base data used in the KPCA analysis.
components - The matrix of components for the function.
centerData - True to center the data. Must correspond to whether or not the analysis was done with centered data.
kernelMatrix - The kernel matrix. Must be provided if data centering is true.
Method Detail

evaluate

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

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

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

getComponentCount

public int getComponentCount()
Gets the number of components in the analysis result.

Returns:
The number of components in the analysis result.

getData

public List<? extends DataType> getData()
Gets the data that was used in the analysis. It is still required for applying the transform.

Returns:
The data that was used in the analysis.

setData

public void setData(List<? extends DataType> data)
Sets the data that was used in the analysis. It is still required for applying the transform.

Parameters:
data - The data that was used in the analysis.

getComponents

public Matrix getComponents()
Gets the matrix of components from the analysis. The number of rows equals the number of components. The number of columns must equal the size of the data.

Returns:
The component matrix.

setComponents

public void setComponents(Matrix components)
Sets the matrix of components from the analysis. The number of rows equals the number of components. The number of columns must equal the size of the data.

Parameters:
components - The component matrix.

isCenterData

public boolean isCenterData()
Gets whether or not the data needs to be centered in the kernel space before applying the function. Only set this to false if the data has been pre-centered. If in doubt, set it to true. If this is set to true, the kernel matrix must be provided for the centering to be performed.

Returns:
True if the function will apply to the centered version of the input data. False if it will just apply directly to the given data.

setCenterData

public void setCenterData(boolean centerData)
Sets whether or not the data needs to be centered in the kernel space before applying the function. Only set this to false if the data has been pre-centered. If in doubt, set it to true. If this is set to true, the kernel matrix must be provided for the centering to be performed.

Parameters:
centerData - True if the function will apply to the centered version of the input data. False if it will just apply directly to the given data.

getKernelMatrix

public Matrix getKernelMatrix()
Gets the kernel matrix for the data that the analysis was done over. If the data needs to be centered, then this matrix must be provided. Each dimension corresponds to an element in the data list.

Returns:
The data kernel matrix.

setKernelMatrix

public void setKernelMatrix(Matrix kernelMatrix)
Sets the kernel matrix for the data that the analysis was done over. If the data needs to be centered, then this matrix must be provided. Each dimension corresponds to an element in the data list.

Parameters:
kernelMatrix - The data kernel matrix.