|
STK++ 1.0
|
@ More...
#include <STK_IAAModel.h>


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 | |
| Regressor * | p_regressor_ |
| pointer on the regression method to use. | |
| IReduct * | p_reductor_ |
| pointer on the dimension reduction method. | |
| Matrix * | p_workData_ |
| Matrix of the local data set. | |
| Matrix * | p_reduced_ |
| Matrix of the reduced data set. | |
| Matrix * | p_predicted_ |
| Matrix of the restored data set. | |
| Matrix * | p_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. | |
@
Interface base class for all Auto-Associative models.
A function
is an auto-associative function of dimension d if it is a map from
to
that can be written
where p (the ``Reduction'') is a map from
to
(generally d<p) and r (the ``Regression'') is a map from
to
.
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.
typedef IRegression<Matrix, Matrix, Vector > STK::IAAModel::Regressor [private] |
regression type for the AAModels
Definition at line 68 of file STK_IAAModel.h.
| STK::IAAModel::IAAModel | ( | Matrix & | workData | ) | [protected] |
Constructor.
| workData | the working data set |
Definition at line 57 of file STK_IAAModel.cpp.
: p_regressor_(0) , p_reductor_(0) , p_workData_(&workData) , p_reduced_(0) , p_predicted_(0) , p_residuals_(0) , dim_(0) , mean_() , std_() , isCentered_(false) , isStandardized_(false) , covProjected_() , covResiduals_() , varResiduals_(0.) { }
| 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.
{ }
| Matrix const& STK::IAAModel::workData | ( | ) | const [inline] |
get 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.
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.
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
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
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
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
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 ?
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 ?
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
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
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
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
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
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.
| dim | the dimension of the model to set |
Definition at line 80 of file STK_IAAModel.cpp.
Referenced by STK::LinearAAModel::run().

| void STK::IAAModel::setWorkData | ( | Matrix & | workData | ) | [virtual] |
set the working set with the Data to treat.
| workData | the 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;
}

| void STK::IAAModel::setReductor | ( | IReduct * | p_reductor | ) |
set the reduction dimension method.
| p_reductor | a pointer on the reduction dimension method to use |
Definition at line 94 of file STK_IAAModel.cpp.
References p_reductor(), and p_reductor_.
{ p_reductor_ = p_reductor;}

| void STK::IAAModel::setRegressor | ( | Regressor * | p_regressor | ) |
set the regression method.
| p_regressor | a pointer on the regresssion method to use |
Definition at line 99 of file STK_IAAModel.cpp.
References p_regressor(), and p_regressor_.
{ p_regressor_ = p_regressor;}

| 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;
}

| void STK::IAAModel::center | ( | Vector const & | weights | ) |
weighted centering of the data set.
| weights | the 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;
}

| 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;
}

| void STK::IAAModel::standardize | ( | Vector const & | weights | ) |
weighted standardization the data set.
| weights | the 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;
}

| 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();
}

| 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();
}

| 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();
}

| 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();
}

| 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_);
}

| 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_);
}

| 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
}

| 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_);
}

Regressor* STK::IAAModel::p_regressor_ [protected] |
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().
IReduct* STK::IAAModel::p_reductor_ [protected] |
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* STK::IAAModel::p_workData_ [protected] |
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* STK::IAAModel::p_reduced_ [protected] |
Matrix of the reduced data set.
Definition at line 216 of file STK_IAAModel.h.
Referenced by STK::GaussianAAModel::computeLogLikelihood(), computeProjectedCovariance(), p_reduced(), reduction(), and STK::LinearAAModel::run().
Matrix* STK::IAAModel::p_predicted_ [protected] |
Matrix of the restored data set.
Definition at line 218 of file STK_IAAModel.h.
Referenced by decenterResults(), destandardizeResults(), p_predicted(), and regression().
Matrix* STK::IAAModel::p_residuals_ [protected] |
Matrix of the residuals.
Definition at line 220 of file STK_IAAModel.h.
Referenced by STK::GaussianAAModel::computeLogLikelihood(), computeResidualsCovariance(), destandardizeResults(), p_residuals(), and regression().
Integer STK::IAAModel::dim_ [private] |
The dimension of the AA Model.
Definition at line 224 of file STK_IAAModel.h.
Referenced by dim(), reduction(), and setDimension().
Point STK::IAAModel::mean_ [private] |
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().
Point STK::IAAModel::std_ [private] |
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().
bool STK::IAAModel::isCentered_ [private] |
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().
bool STK::IAAModel::isStandardized_ [private] |
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().
MatrixSquare STK::IAAModel::covProjected_ [private] |
The covariance matrix of the projected data set.
Definition at line 236 of file STK_IAAModel.h.
Referenced by computeProjectedCovariance(), and covProjected().
MatrixSquare STK::IAAModel::covResiduals_ [private] |
The covariance matrix of the residuals.
Definition at line 238 of file STK_IAAModel.h.
Referenced by computeResidualsCovariance(), and covResiduals().
Real STK::IAAModel::varResiduals_ [private] |
The total variance of the residuals.
Definition at line 240 of file STK_IAAModel.h.
Referenced by computeResidualsCovariance(), and varResiduals().