Facemorph.Stats
Class DifferenceOfAverages

java.lang.Object
  extended by Facemorph.Stats.DifferenceOfAverages
All Implemented Interfaces:
IniHandler, Regressor, StatisticalModel

public class DifferenceOfAverages
extends java.lang.Object
implements Regressor

Technically similar to a linear regressor, DifferenceOfAverages describes a function as a line connecting two points Distances along the line a scaled such that point 1 is considered to be the 0.0 point and point 2 the 1.0 point


Nested Class Summary
 class DifferenceOfAverages.DiffernceOfAveragesException
           
 
Nested classes/interfaces inherited from interface Facemorph.Stats.Regressor
Regressor.RegressorException
 
Constructor Summary
DifferenceOfAverages()
           
 
Method Summary
 BigMat apply(BigMat in)
          Apply the statistical model on the input data supplied in Matrix form
 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 getSumSquaredResiduals()
           
 java.lang.StringBuffer outputStatistics()
           
 boolean outputStatistics(java.io.File statsFile)
           
 double[] predict(BigMat values)
          The projection of a point onto a line is given by the inner produce of the point to the source divided by the square magnitude of the line
 boolean read(java.io.File f)
           
 boolean read(iniFile in)
          Read from the current position in an iniFile.
 void setDependentData(BigMat data)
          The dependent part of the regression
 void setDependentData(double[] data)
          The dependent part of the regression
 void setIndependentData(BigMat data)
          The independent part of the regression
 boolean train(boolean stats)
          Perform multi-linear regression using the Ordinary Least Squares method.
 boolean write(java.io.File s)
          Writes to the file specified
 boolean write(iniFile file, java.lang.String name)
          Writes this Template to file (via a PrintStream)
 boolean write(java.io.PrintStream out)
          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

DifferenceOfAverages

public DifferenceOfAverages()
Method Detail

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.

predict

public double[] predict(BigMat values)
The projection of a point onto a line is given by the inner produce of the point to the source divided by the square magnitude of the line

Specified by:
predict in interface Regressor
Parameters:
values - the independent values
Returns:
set of predicted values

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

setDependentData

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

Specified by:
setDependentData in interface StatisticalModel

getSumSquaredResiduals

public double getSumSquaredResiduals()
Specified by:
getSumSquaredResiduals in interface Regressor
Returns:
The Sum of Squared Residuals of the regression.

getInputDimensions

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

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(java.io.File f)
             throws java.io.FileNotFoundException
Specified by:
read in interface Regressor
Throws:
java.io.FileNotFoundException

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(java.io.File s)
Writes to the file specified

Specified by:
write in interface Regressor
Parameters:
s - the name of the file to write to
Returns:
returns true if all is OK

write

public boolean write(java.io.PrintStream out)
Writes this Template to file (via a PrintStream)

Specified by:
write in interface Regressor
Parameters:
out - The output PrintStream
Returns:
if written successfully

write

public boolean write(iniFile file,
                     java.lang.String name)
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

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.

getOutputDimensions

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

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