Facemorph.Stats
Class NumericRegressor

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

public class NumericRegressor
extends java.lang.Object
implements Regressor


Nested Class Summary
 
Nested classes/interfaces inherited from interface Facemorph.Stats.Regressor
Regressor.RegressorException
 
Field Summary
protected  double[] b
           
protected  double[] e
          Residuals after the regression calculation
protected  boolean interceptSetup
          True if the intercept has been setup
protected  BigMat ProjectionMatrix
          Projection Matix onto the space spanned by the columns of X (yhat = P.y)
protected  double rs
           
protected  double ssr
          Sum of Squares Residual Error
protected  double threshold
          size of smallest numeric values
protected  double tss
          Total sum of squares for the dependent variable
protected  boolean usingIntercept
          True if is using intercept data, necessary for statistical analysis
protected  BigMat X
          A set of predictor variables
protected  double[] y
          A set of responce variables
 
Constructor Summary
NumericRegressor()
           
NumericRegressor(BigMat predictors, double[] responses)
           
 
Method Summary
protected  void addInterceptColumn()
           
 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)
          Predict using the model the values of the dependent from a set of independents
 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
 

Field Detail

usingIntercept

protected boolean usingIntercept
True if is using intercept data, necessary for statistical analysis


interceptSetup

protected boolean interceptSetup
True if the intercept has been setup


ssr

protected double ssr
Sum of Squares Residual Error


tss

protected double tss
Total sum of squares for the dependent variable


rs

protected double rs

threshold

protected double threshold
size of smallest numeric values


X

protected BigMat X
A set of predictor variables


y

protected double[] y
A set of responce variables


ProjectionMatrix

protected BigMat ProjectionMatrix
Projection Matix onto the space spanned by the columns of X (yhat = P.y)


b

protected double[] b

e

protected double[] e
Residuals after the regression calculation

Constructor Detail

NumericRegressor

public NumericRegressor()

NumericRegressor

public NumericRegressor(BigMat predictors,
                        double[] responses)
Method Detail

train

public boolean train(boolean stats)
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)
Predict using the model the values of the dependent from a set of independents

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

setIndependentData

public void setIndependentData(BigMat data)
The independent part of the regression

Specified by:
setIndependentData in interface StatisticalModel
Parameters:
data - regression variables

setDependentData

public void setDependentData(BigMat data)
The dependent part of the regression

Specified by:
setDependentData in interface StatisticalModel
Parameters:
data - regression variables

setDependentData

public void setDependentData(double[] data)
The dependent part of the regression

Specified by:
setDependentData in interface StatisticalModel
Parameters:
data - regression variables

addInterceptColumn

protected void addInterceptColumn()

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

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

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