Facemorph.Stats
Class ICA

java.lang.Object
  extended by Facemorph.Stats.ICA
All Implemented Interfaces:
IniHandler, DataReducer, StatisticalModel

public class ICA
extends java.lang.Object
implements DataReducer

Independent Component Analysis


Nested Class Summary
 class ICA.ICAException
           
 
Nested classes/interfaces inherited from interface Facemorph.Stats.DataReducer
DataReducer.DataReducerInformation
 
Constructor Summary
ICA()
           
 
Method Summary
 BigMat apply(BigMat in)
          Apply the statistical model on the input data supplied in Matrix form
 BigMat getBasisMatrix()
          Outputs the basis matrix that is the result of PCA analysis
 double getEpsilon()
          Get epsilon, the very small error margin used the determine if the function has finished minimising.
 int getInputDimensions()
           
 void getModelInformation(ModelInformation mi)
          Queries the statistical model about its abilities.
 void getModelInformation(ModelResults result)
          Query the (previously built) model for information about the model's components
 int getOutputDimensions()
           
 double getTargetDependentVariance()
           
 double getTargetIndpendentVariance()
           
static void main(java.lang.String[] args)
           
 java.lang.StringBuffer outputStatistics()
           
 boolean outputStatistics(java.io.File statsFile)
           
 boolean read(iniFile in)
          Read from the current position in an iniFile.
 BigMat reconstructDependent(BigMat in)
          Reconstruct (approximately) a high dimensional input given the low dimensional output
 double[] reconstructDependent(double[] in)
           
 BigMat reconstructIndependent(BigMat in)
          Reconstruct (approximately) a high dimensional input given the low dimensional output
 double[] reconstructIndependent(double[] in)
          Reconstruct (approximately) a high dimensional input given the low dimensional output
 BigMat reduceDependent(BigMat in)
          Perform dimensionality reduction on the BigMat
 double[] reduceDependent(double[] in)
           
 BigMat reduceIndependent(BigMat in)
          Perform dimensionality reduction on the BigMat
 double[] reduceIndependent(double[] in)
          Perform dimensionality reduction on a single sample of variables
 void setDependentData(BigMat data)
          The dependent part of the regression
 void setDependentData(double[] data)
          The dependent part of the regression
 void setEpsilon(double e)
          Set epsilon, the very small error margin used the determine if the function has finished minimising.
 void setIndependentData(BigMat data)
          The independent part of the regression
 void setOutputDimensions(int d)
          Set the maximum number of output dimensions in the model (pre-build, undefined if set after building some classes will alter the dimensionality of the reduction others will not) If d is greater than the number input variables, the model will truncate at the maximum number of variables.
 void setTargetDependentVariance(double var)
          Stop calculating components when the variance explained in the dependent variable is greater than var
 void setTargetIndependentVariance(double var)
          Stop calculating components when the variance explained in the independent variable is greater than var
 void setTargetKaiserGuttman()
           
 boolean train(boolean stats)
          Perform multi-linear regression using the Ordinary Least Squares method.
 boolean write(iniFile file, java.lang.String name)
          Writes this Template to file (via a PrintStream)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ICA

public ICA()
Method Detail

setIndependentData

public void setIndependentData(BigMat data)
Description copied from interface: StatisticalModel
The independent part of the regression

Specified by:
setIndependentData in interface StatisticalModel

setDependentData

public void setDependentData(BigMat data)
Description copied from interface: StatisticalModel
The dependent part of the regression

Specified by:
setDependentData in interface StatisticalModel

train

public boolean train(boolean stats)
Description copied from interface: StatisticalModel
Perform multi-linear regression using the Ordinary Least Squares method. Solves y = XB + e using b = inv(X'X)X'y

Specified by:
train in interface StatisticalModel
Parameters:
stats - calculate values for statistical analysis
Returns:
true if the regression succeeds.

getBasisMatrix

public BigMat getBasisMatrix()
Outputs the basis matrix that is the result of PCA analysis

Returns:
the basis functions as a matrix

reduceIndependent

public double[] reduceIndependent(double[] in)
Description copied from interface: DataReducer
Perform dimensionality reduction on a single sample of variables

Specified by:
reduceIndependent in interface DataReducer
Parameters:
in - vector to reduce
Returns:
a shorted vector mapped in dimensionally reduced space

reconstructIndependent

public double[] reconstructIndependent(double[] in)
Description copied from interface: DataReducer
Reconstruct (approximately) a high dimensional input given the low dimensional output

Specified by:
reconstructIndependent in interface DataReducer
Parameters:
in - low dimensional vector
Returns:
high dimensional matrix

reduceDependent

public double[] reduceDependent(double[] in)
Specified by:
reduceDependent in interface DataReducer

reconstructDependent

public double[] reconstructDependent(double[] in)
Specified by:
reconstructDependent in interface DataReducer

reduceIndependent

public BigMat reduceIndependent(BigMat in)
Description copied from interface: DataReducer
Perform dimensionality reduction on the BigMat

Specified by:
reduceIndependent in interface DataReducer
Parameters:
in - BigMat to reduce
Returns:
a shorted vector mapped in dimensionally reduced space

reconstructIndependent

public BigMat reconstructIndependent(BigMat in)
Description copied from interface: DataReducer
Reconstruct (approximately) a high dimensional input given the low dimensional output

Specified by:
reconstructIndependent in interface DataReducer
Parameters:
in - low dimensional matrix
Returns:
high dimensional matrix

reduceDependent

public BigMat reduceDependent(BigMat in)
Description copied from interface: DataReducer
Perform dimensionality reduction on the BigMat

Specified by:
reduceDependent in interface DataReducer
Parameters:
in - BigMat to reduce
Returns:
a shorted vector mapped in dimensionally reduced space

reconstructDependent

public BigMat reconstructDependent(BigMat in)
Description copied from interface: DataReducer
Reconstruct (approximately) a high dimensional input given the low dimensional output

Specified by:
reconstructDependent in interface DataReducer
Parameters:
in - low dimensional matrix
Returns:
high dimensional matrix

setOutputDimensions

public void setOutputDimensions(int d)
Description copied from interface: DataReducer
Set the maximum number of output dimensions in the model (pre-build, undefined if set after building some classes will alter the dimensionality of the reduction others will not) If d is greater than the number input variables, the model will truncate at the maximum number of variables.

Specified by:
setOutputDimensions in interface DataReducer
Parameters:
d - target number of dimensions.

getInputDimensions

public int getInputDimensions()
Specified by:
getInputDimensions in interface StatisticalModel

getOutputDimensions

public int getOutputDimensions()
Specified by:
getOutputDimensions in interface StatisticalModel

setTargetDependentVariance

public void setTargetDependentVariance(double var)
Description copied from interface: DataReducer
Stop calculating components when the variance explained in the dependent variable is greater than var

Specified by:
setTargetDependentVariance in interface DataReducer
Parameters:
var - variance to explain

getTargetDependentVariance

public double getTargetDependentVariance()
Specified by:
getTargetDependentVariance in interface DataReducer
Returns:
the target variance to explain on the dependent variable (not neccessarily the amount actually calculated

setTargetIndependentVariance

public void setTargetIndependentVariance(double var)
Description copied from interface: DataReducer
Stop calculating components when the variance explained in the independent variable is greater than var

Specified by:
setTargetIndependentVariance in interface DataReducer
Parameters:
var - variance to explain

getTargetIndpendentVariance

public double getTargetIndpendentVariance()
Specified by:
getTargetIndpendentVariance in interface DataReducer
Returns:
the target variance to explain on the independent variable (not neccessarily the amount actually calculated

setEpsilon

public void setEpsilon(double e)
Description copied from interface: DataReducer
Set epsilon, the very small error margin used the determine if the function has finished minimising. i.e. if the change is less than e stop minimising

Specified by:
setEpsilon in interface DataReducer
Parameters:
e - error value

getEpsilon

public double getEpsilon()
Description copied from interface: DataReducer
Get epsilon, the very small error margin used the determine if the function has finished minimising. i.e. if the change is less than e stop minimising

Specified by:
getEpsilon in interface DataReducer
Returns:

outputStatistics

public boolean outputStatistics(java.io.File statsFile)
Specified by:
outputStatistics in interface StatisticalModel

outputStatistics

public java.lang.StringBuffer outputStatistics()
Specified by:
outputStatistics in interface StatisticalModel

read

public boolean read(iniFile in)
Description copied from interface: IniHandler
Read from the current position in an iniFile. assumes that the iniFile is already in the object's root block

Specified by:
read in interface IniHandler
Returns:
true if successfully read.

write

public boolean write(iniFile file,
                     java.lang.String name)
Description copied from interface: IniHandler
Writes this Template to file (via a PrintStream)

Specified by:
write in interface IniHandler
Parameters:
file - The output ini file to fill with class data
Returns:
if written successfully

setDependentData

public void setDependentData(double[] data)
Description copied from interface: StatisticalModel
The dependent part of the regression

Specified by:
setDependentData in interface StatisticalModel

getModelInformation

public void getModelInformation(ModelInformation mi)
Description copied from interface: StatisticalModel
Queries the statistical model about its abilities.

Specified by:
getModelInformation in interface StatisticalModel

apply

public BigMat apply(BigMat in)
Description copied from interface: StatisticalModel
Apply the statistical model on the input data supplied in Matrix form

Specified by:
apply in interface StatisticalModel
Parameters:
in - matrix containing values for modeling
Returns:
values computed by the model.

setTargetKaiserGuttman

public void setTargetKaiserGuttman()
Specified by:
setTargetKaiserGuttman in interface DataReducer

getModelInformation

public void getModelInformation(ModelResults result)
Description copied from interface: StatisticalModel
Query the (previously built) model for information about the model's components

Specified by:
getModelInformation in interface StatisticalModel
Parameters:
result - ModelResults object to fill with appropriate information

main

public static void main(java.lang.String[] args)