STK++ 1.0
STK::IAAModel Class Reference

@ More...

#include <STK_IAAModel.h>

Inheritance diagram for STK::IAAModel:
Collaboration diagram for STK::IAAModel:

List of all members.

Public Member Functions

Matrix const & workData () const
 get the working data set
IReduct *const & p_reductor () const
 Get the reductor used for the computation of the reduced data.
Regressor *const & p_regressor () const
 Get the regressor used for the computation of the regressed data.
Matrix *const & p_reduced () const
 get the reduced data set
Matrix *const & p_predicted () const
 get the matrix of the predicted values
Matrix *const & p_residuals () const
 get the matrix of the residuals
Integer const & dim () const
 get the dimension of the model
bool isCentered () const
 is the data set centered ?
bool isStandardized () const
 is the data set standardized ?
Point const & mean () const
 get the mean of the data set
Point const & std () const
 get the standard deviation of the data set
MatrixSquare const & covProjected () const
 get the covariance of the projected the data set
MatrixSquare const & covResiduals () const
 get the covariance of the residuals
Real const & varResiduals () const
 get the covariance of the residuals
void setDimension (Integer const &dim)
 set the dimension of the model.
virtual void setWorkData (Matrix &workData)
 set the working set with the Data to treat.
void setReductor (IReduct *p_reductor)
 set the reduction dimension method.
void setRegressor (Regressor *p_regressor)
 set the regression method.
void freeReductor ()
 delete the reductor set to this model by the method setReductor.
void freeRegressor ()
 delete the regressor set to this model by the method setRegressor.
void center ()
 center the data set in workData_.
void center (Vector const &weights)
 weighted centering of the data set.
void standardize ()
 standardize the data set.
void standardize (Vector const &weights)
 weighted standardization the data set.
void reduction ()
 compute the dimension reduction of the data set and store the result in the p_reduced_ container.
void reduction (Vector const &weights)
 compute the weighted dimension reduction of the data set and store the result in the p_reduced_ container.
void regression ()
 compute the regression of the original data set and set the results in p_predicted and p_residuals.
void regression (Vector const &weights)
 compute the weighted regression of the original data set using the reduced data set as predictor and set the results in p_predicted and p_residuals.
void decenterResults ()
 decenter the predicted data set.
void destandardizeResults ()
 destandardize the predicted data set and the residuals.
void computeProjectedCovariance ()
 compute the covariance matrix of the projected data set.
void computeResidualsCovariance ()
 compute the covariance matrix of the residuals.

Protected Member Functions

 IAAModel (Matrix &workData)
 Constructor.
 ~IAAModel ()
 destructor.

Protected Attributes

Regressorp_regressor_
 pointer on the regression method to use.
IReductp_reductor_
 pointer on the dimension reduction method.
Matrixp_workData_
 Matrix of the local data set.
Matrixp_reduced_
 Matrix of the reduced data set.
Matrixp_predicted_
 Matrix of the restored data set.
Matrixp_residuals_
 Matrix of the residuals.

Private Types

typedef IRegression< Matrix,
Matrix, Vector
Regressor
 regression type for the AAModels

Private Attributes

Integer dim_
 The dimension of the AA Model.
Point mean_
 vector of the means of the input data set.
Point std_
 vector of the standard deviation of the input data set.
bool isCentered_
 a boolean true if the working data set is centered, false otherwise.
bool isStandardized_
 a boolean true if the working data set is standardized, false otherwise
MatrixSquare covProjected_
 The covariance matrix of the projected data set.
MatrixSquare covResiduals_
 The covariance matrix of the residuals.
Real varResiduals_
 The total variance of the residuals.

Detailed Description

@

Interface base class for all Auto-Associative models.

A function $ g $ is an auto-associative function of dimension d if it is a map from $ \mathbb{R}^p $ to $ \mathbb{R}^p $ that can be written $ g=r\circ p $ where p (the ``Reduction'') is a map from $ \mathbb{R}^p $ to $ \mathbb{R}^d $ (generally d<p) and r (the ``Regression'') is a map from $ \mathbb{R}^d $ to $ \mathbb{R}^p $ .

The IAAModel is an abstract base class for all these AAM. End user can set a reductor and a regressor.

Derived class can use therun() method and its variants which provide a default behavior in order to estimate the model.

Definition at line 65 of file STK_IAAModel.h.


Member Typedef Documentation

regression type for the AAModels

Definition at line 68 of file STK_IAAModel.h.


Constructor & Destructor Documentation

STK::IAAModel::IAAModel ( Matrix workData) [protected]

Constructor.

Parameters:
workDatathe working data set

Definition at line 57 of file STK_IAAModel.cpp.

STK::IAAModel::~IAAModel ( ) [protected]

destructor.

It is protected in order to prevent the use of this class. use GaussianAAModel decorator instead.

Definition at line 75 of file STK_IAAModel.cpp.

{ }

Member Function Documentation

Matrix const& STK::IAAModel::workData ( ) const [inline]

get the working data set

Returns:
the working data set

Definition at line 83 of file STK_IAAModel.h.

References p_workData_.

Referenced by setWorkData().

{ return *p_workData_;}
IReduct* const& STK::IAAModel::p_reductor ( ) const [inline]

Get the reductor used for the computation of the reduced data.

Returns:
a reference on the Index object

Definition at line 87 of file STK_IAAModel.h.

References p_reductor_.

Referenced by setReductor().

{ return p_reductor_;}
Regressor* const& STK::IAAModel::p_regressor ( ) const [inline]

Get the regressor used for the computation of the regressed data.

Returns:
a reference on the Index object

Definition at line 91 of file STK_IAAModel.h.

References p_regressor_.

Referenced by setRegressor().

{ return p_regressor_;}
Matrix* const& STK::IAAModel::p_reduced ( ) const [inline]

get the reduced data set

Returns:
the reduced data set

Definition at line 95 of file STK_IAAModel.h.

References p_reduced_.

{ return p_reduced_;}
Matrix* const& STK::IAAModel::p_predicted ( ) const [inline]

get the matrix of the predicted values

Returns:
A ptr on the predicted values

Definition at line 99 of file STK_IAAModel.h.

References p_predicted_.

{ return p_predicted_;}
Matrix* const& STK::IAAModel::p_residuals ( ) const [inline]

get the matrix of the residuals

Returns:
A ptr on the residual covariance

Definition at line 103 of file STK_IAAModel.h.

References p_residuals_.

{ return p_residuals_;}
Integer const& STK::IAAModel::dim ( ) const [inline]

get the dimension of the model

Returns:
the dimension of the model

Definition at line 107 of file STK_IAAModel.h.

References dim_.

Referenced by STK::GaussianAAModel::computeLogLikelihood(), and setDimension().

{ return dim_;}
bool STK::IAAModel::isCentered ( ) const [inline]

is the data set centered ?

Returns:
true if the data set is centered, false otherwise

Definition at line 112 of file STK_IAAModel.h.

References isCentered_.

Referenced by STK::LinearAAModel::run().

{ return isCentered_;}
bool STK::IAAModel::isStandardized ( ) const [inline]

is the data set standardized ?

Returns:
true if the data set is standardized, false otherwise

Definition at line 116 of file STK_IAAModel.h.

References isStandardized_.

Referenced by STK::LinearAAModel::run().

{ return isStandardized_;}
Point const& STK::IAAModel::mean ( ) const [inline]

get the mean of the data set

Returns:
the mean of the data set

Definition at line 121 of file STK_IAAModel.h.

References mean_.

Referenced by STK::GaussianAAModel::computeLogLikelihood().

{ return mean_;}
Point const& STK::IAAModel::std ( ) const [inline]

get the standard deviation of the data set

Returns:
the standard deviation of the data set

Definition at line 125 of file STK_IAAModel.h.

References std_.

{ return std_;}
MatrixSquare const& STK::IAAModel::covProjected ( ) const [inline]

get the covariance of the projected the data set

Returns:
the projected the data set

Definition at line 129 of file STK_IAAModel.h.

References covProjected_.

Referenced by STK::GaussianAAModel::computeLogLikelihood().

{ return covProjected_;}
MatrixSquare const& STK::IAAModel::covResiduals ( ) const [inline]

get the covariance of the residuals

Returns:
the residuals

Definition at line 133 of file STK_IAAModel.h.

References covResiduals_.

{ return covResiduals_;}
Real const& STK::IAAModel::varResiduals ( ) const [inline]

get the covariance of the residuals

Returns:
the residuals

Definition at line 137 of file STK_IAAModel.h.

References varResiduals_.

Referenced by STK::GaussianAAModel::computeLogLikelihood().

{ return varResiduals_;}
void STK::IAAModel::setDimension ( Integer const &  dim)

set the dimension of the model.

Parameters:
dimthe dimension of the model to set

Definition at line 80 of file STK_IAAModel.cpp.

References dim(), and dim_.

Referenced by STK::LinearAAModel::run().

{ dim_ = dim;}

Here is the call graph for this function:

void STK::IAAModel::setWorkData ( Matrix workData) [virtual]

set the working set with the Data to treat.

Parameters:
workDatathe working data set to treat

Reimplemented in STK::GaussianAAModel.

Definition at line 85 of file STK_IAAModel.cpp.

References isCentered_, isStandardized_, p_workData_, and workData().

{
  p_workData_ = &workData;
  isCentered_     = false;
  isStandardized_ = false;
}

Here is the call graph for this function:

void STK::IAAModel::setReductor ( IReduct p_reductor)

set the reduction dimension method.

Parameters:
p_reductora pointer on the reduction dimension method to use

Definition at line 94 of file STK_IAAModel.cpp.

References p_reductor(), and p_reductor_.

Here is the call graph for this function:

void STK::IAAModel::setRegressor ( Regressor p_regressor)

set the regression method.

Parameters:
p_regressora pointer on the regresssion method to use

Definition at line 99 of file STK_IAAModel.cpp.

References p_regressor(), and p_regressor_.

Here is the call graph for this function:

void STK::IAAModel::freeReductor ( )

delete the reductor set to this model by the method setReductor.

delete the reductor allocated set to this model.

Definition at line 103 of file STK_IAAModel.cpp.

References p_reductor_.

{
  if (p_reductor_) delete p_reductor_;
  p_reductor_ = 0;
}
void STK::IAAModel::freeRegressor ( )

delete the regressor set to this model by the method setRegressor.

delete the regressor allocated to this model.

Definition at line 109 of file STK_IAAModel.cpp.

References p_regressor_.

{
  if (p_regressor_) delete p_regressor_;
  p_regressor_ = 0;
}
void STK::IAAModel::center ( )

center the data set in workData_.

Definition at line 116 of file STK_IAAModel.cpp.

References _T, STK::Stat::decenter(), isCentered_, mean_, and p_workData_.

Referenced by center().

{
#ifdef STK_DEBUG
  if (!p_workData_)
    throw runtime_error(_T("Error in IAAModel::center(): "
                           "work data is not initialized."));
#endif
  // we have to decenter in case they have been centered with weights
  if (isCentered_)
  {
    Stat::decenter(*p_workData_, mean_);
    isCentered_ = false;
  }
  Stat::center(*p_workData_, mean_);
  isCentered_ = true;
}

Here is the call graph for this function:

void STK::IAAModel::center ( Vector const &  weights)

weighted centering of the data set.

Parameters:
weightsthe weights of the samples

Definition at line 134 of file STK_IAAModel.cpp.

References _T, center(), STK::Stat::decenter(), isCentered_, mean_, and p_workData_.

{
#ifdef STK_DEBUG
  if (!p_workData_)
    throw runtime_error(_T("Error in IAAModel::center(weights): "
                           "work data is not initialized."));
#endif
  // we have to decenter in case of this is not the same weights
  if (isCentered_)
  {
    Stat::decenter(*p_workData_, mean_);
    isCentered_ = false;
  }
  // center
  Stat::center(*p_workData_, weights, mean_);
  isCentered_ = true;
}

Here is the call graph for this function:

void STK::IAAModel::standardize ( )

standardize the data set.

Definition at line 153 of file STK_IAAModel.cpp.

References _T, STK::Stat::destandardize(), isStandardized_, mean_, p_workData_, and std_.

Referenced by standardize().

{
#ifdef STK_DEBUG
  if (!p_workData_)
    throw runtime_error(_T("Error in IAAModel::standardize(): "
                           "work data is not initialized."));
#endif

  // we have to destandardize in case they have been standardized with weights
  if (isStandardized_)
  {
    Stat::destandardize(*p_workData_, mean_, std_);
    isStandardized_ = false;
  }
  Stat::standardize(*p_workData_, mean_, std_);
  isStandardized_ = true;
}

Here is the call graph for this function:

void STK::IAAModel::standardize ( Vector const &  weights)

weighted standardization the data set.

Parameters:
weightsthe weights of the samples

Definition at line 172 of file STK_IAAModel.cpp.

References _T, STK::Stat::destandardize(), isStandardized_, mean_, p_workData_, standardize(), and std_.

{
#ifdef STK_DEBUG
  if (!p_workData_)
    throw runtime_error(_T("Error in IAAModel::standardize(weights): "
                            "work data is not initialized."));
#endif

  // we have to destandardize in case of this is not the same weights
  if (isStandardized_)
  {
    Stat::destandardize(*p_workData_, mean_, std_);
    isStandardized_ = false;
  }
  // standardize
  Stat::standardize(*p_workData_, weights, mean_, std_);
  isStandardized_ = true;
}

Here is the call graph for this function:

void STK::IAAModel::reduction ( )

compute the dimension reduction of the data set and store the result in the p_reduced_ container.

The reductor p_reductor have to be set.

Definition at line 193 of file STK_IAAModel.cpp.

References _T, dim_, STK::IReduct::p_reduced(), p_reduced_, p_reductor_, STK::IRunnerConstRef< TY >::run(), and STK::IReduct::setDimension().

Referenced by STK::LinearAAModel::run().

{
  if (!p_reductor_)
    throw runtime_error(_T("Error in IAAModel::reduction(): "
                           "reductor have not be set."));
  // compute axis
  p_reductor_->setDimension(dim_);
  p_reductor_->run();
  // compute matrix multiplication
  p_reduced_= p_reductor_->p_reduced();
}

Here is the call graph for this function:

void STK::IAAModel::reduction ( Vector const &  weights)

compute the weighted dimension reduction of the data set and store the result in the p_reduced_ container.

Definition at line 206 of file STK_IAAModel.cpp.

References _T, dim_, STK::IReduct::p_reduced(), p_reduced_, p_reductor_, STK::IRunnerConstRef< TY >::run(), and STK::IReduct::setDimension().

{
  if (!p_reductor_)
    throw runtime_error(_T("Error in IAAModel::reduction(weigths): "
                           "reductor have not be set."));
  // compute axis
  p_reductor_->setDimension(dim_);
  p_reductor_->run(weights);
  // get the reduced data set
  p_reduced_= p_reductor_->p_reduced();
}

Here is the call graph for this function:

void STK::IAAModel::regression ( )

compute the regression of the original data set and set the results in p_predicted and p_residuals.

Definition at line 219 of file STK_IAAModel.cpp.

References _T, STK::IRegression< YContainer, XContainer, WContainer >::p_predicted(), p_predicted_, p_regressor_, STK::IRegression< YContainer, XContainer, WContainer >::p_residuals(), p_residuals_, and STK::IRegression< YContainer, XContainer, WContainer >::run().

Referenced by STK::LinearAAModel::run().

{
  if (!p_regressor_)
    throw runtime_error(_T("Error in IAAModel::regression(): "
                           "regressor have not be set."));
  // compute regression
  p_regressor_->run();
  // get results
  p_predicted_ = p_regressor_->p_predicted();
  p_residuals_ = p_regressor_->p_residuals();
}

Here is the call graph for this function:

void STK::IAAModel::regression ( Vector const &  weights)

compute the weighted regression of the original data set using the reduced data set as predictor and set the results in p_predicted and p_residuals.

Definition at line 231 of file STK_IAAModel.cpp.

References _T, STK::IRegression< YContainer, XContainer, WContainer >::p_predicted(), p_predicted_, p_regressor_, STK::IRegression< YContainer, XContainer, WContainer >::p_residuals(), p_residuals_, and STK::IRegression< YContainer, XContainer, WContainer >::run().

{
  if (!p_regressor_)
    throw runtime_error(_T("Error in IAAModel::regression(weights): "
                           "regressor have not be set."));
  p_regressor_->run(weights);
  // get results
  p_predicted_ = p_regressor_->p_predicted();
  p_residuals_ = p_regressor_->p_residuals();
}

Here is the call graph for this function:

void STK::IAAModel::decenterResults ( )

decenter the predicted data set.

This will invalidate the results of p_regressor_.

Definition at line 243 of file STK_IAAModel.cpp.

References _T, STK::Stat::decenter(), mean_, and p_predicted_.

Referenced by STK::LinearAAModel::run().

{
  if (!p_predicted_)
    throw runtime_error(_T("Error in IAAModel::decenterResults(): "
                           "predictions have not been computed."));
  Stat::decenter(*p_predicted_, mean_);
}

Here is the call graph for this function:

void STK::IAAModel::destandardizeResults ( )

destandardize the predicted data set and the residuals.

This will invalidate the results of p_regressor_.

Definition at line 251 of file STK_IAAModel.cpp.

References _T, STK::Stat::destandardize(), mean_, p_predicted_, p_residuals_, and std_.

Referenced by STK::LinearAAModel::run().

{
  if (!p_predicted_)
    throw runtime_error(_T("Error in IAAModel::destandardizeResults(): "
                           "predictions have not been computed."));
  if (!p_residuals_)
    throw runtime_error(_T("Error in IAAModel::destandardizeResults(): "
                           "residuals have not been computed."));
  Stat::destandardize(*p_predicted_, mean_, std_);
  Stat::destandardize(*p_residuals_, std_);
}

Here is the call graph for this function:

void STK::IAAModel::computeProjectedCovariance ( )

compute the covariance matrix of the projected data set.

Definition at line 264 of file STK_IAAModel.cpp.

References _T, STK::Stat::covariance(), covProjected_, p_reduced_, and stk_cout.

Referenced by STK::LinearAAModel::run().

{
  if (!p_reduced_)
    throw runtime_error(_T("Error in IAAModel::computeProjectedCovariance(): "
                           "projected data have not been computed."));
#ifdef STK_VERBOSE
  stk_cout << "in IAAModel::computeProjectedCovariance().\n";
#endif
  Stat::covariance(*p_reduced_, covProjected_);
#ifdef STK_VERBOSE
  stk_cout << "in IAAModel::computeProjectedCovariance() done.\n";
#endif
}

Here is the call graph for this function:

void STK::IAAModel::computeResidualsCovariance ( )

compute the covariance matrix of the residuals.

Definition at line 278 of file STK_IAAModel.cpp.

References _T, STK::Stat::covariance(), covResiduals_, p_residuals_, STK::trace(), and varResiduals_.

{
  if (!p_residuals_)
    throw runtime_error(_T("Error in IAAModel::computeResidualsCovariance(): "
                           "residuals have not been computed."));
  Stat::covariance(*p_residuals_, covResiduals_);
  varResiduals_ = trace(covResiduals_);
}

Here is the call graph for this function:


Member Data Documentation

pointer on the regression method to use.

The regression method will be instanced in the derived class.

Definition at line 207 of file STK_IAAModel.h.

Referenced by STK::GaussianAAModel::computeLogLikelihood(), freeRegressor(), STK::LinearAAModel::LinearAAModel(), p_regressor(), regression(), STK::LinearAAModel::run(), setRegressor(), and STK::LinearAAModel::~LinearAAModel().

pointer on the dimension reduction method.

The dimension reduction method will be chosen in the derived class.

Definition at line 211 of file STK_IAAModel.h.

Referenced by freeReductor(), p_reductor(), reduction(), STK::LinearAAModel::run(), and setReductor().

Matrix of the local data set.

Definition at line 214 of file STK_IAAModel.h.

Referenced by center(), STK::LinearAAModel::run(), setWorkData(), standardize(), and workData().

Matrix of the restored data set.

Definition at line 218 of file STK_IAAModel.h.

Referenced by decenterResults(), destandardizeResults(), p_predicted(), and regression().

The dimension of the AA Model.

Definition at line 224 of file STK_IAAModel.h.

Referenced by dim(), reduction(), and setDimension().

vector of the means of the input data set.

Definition at line 226 of file STK_IAAModel.h.

Referenced by center(), decenterResults(), destandardizeResults(), mean(), and standardize().

vector of the standard deviation of the input data set.

Definition at line 228 of file STK_IAAModel.h.

Referenced by destandardizeResults(), standardize(), and std().

a boolean true if the working data set is centered, false otherwise.

Definition at line 231 of file STK_IAAModel.h.

Referenced by center(), isCentered(), and setWorkData().

a boolean true if the working data set is standardized, false otherwise

Definition at line 234 of file STK_IAAModel.h.

Referenced by isStandardized(), setWorkData(), and standardize().

The covariance matrix of the projected data set.

Definition at line 236 of file STK_IAAModel.h.

Referenced by computeProjectedCovariance(), and covProjected().

The covariance matrix of the residuals.

Definition at line 238 of file STK_IAAModel.h.

Referenced by computeResidualsCovariance(), and covResiduals().

The total variance of the residuals.

Definition at line 240 of file STK_IAAModel.h.

Referenced by computeResidualsCovariance(), and varResiduals().


The documentation for this class was generated from the following files: