STK++ 0.9.13
STK::IAAModel< Array > Class Template Reference

@ More...

#include <STK_IAAModel.h>

Inheritance diagram for STK::IAAModel< Array >:
Inheritance graph

Public Member Functions

 ~IAAModel ()
 destructor.
 
Array constworkData () const
 
Reducer *constp_reducer () const
 
Regressor *constp_regressor () const
 
Array *constp_reduced () const
 
Array *constp_predicted () const
 
Array *constp_residuals () const
 
int dim () const
 
bool isCentered () const
 
bool isStandardized () const
 
PointX constmean () const
 
PointX conststd () const
 
void setDimension (int const &dim)
 
void setWorkData (Array &workData)
 
void setReducer (Reducer *p_reducer)
 
void setRegressor (Regressor *p_regressor)
 
void freeReducer ()
 delete the reducer set to this model by the method setReducer.
 
void freeRegressor ()
 delete the regressor set to this model by the method setRegressor.
 
void center ()
 center the data set workData_.
 
void center (VectorX const &weights)
 weighted centering of the data set.
 
void standardize ()
 standardize the data set.
 
void standardize (VectorX const &weights)
 weighted standardization the data set.
 
void reductionStep ()
 compute the reduction of the data set and store the result in the p_reduced_ container.
 
void reductionStep (VectorX const &weights)
 compute the weighted dimension reduction of the data set and store the result in the p_reduced_ container.
 
void regressionStep ()
 compute the regression of the original data set and set the results in p_predicted and p_residuals.
 
void regressionStep (VectorX 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 uncenterResults ()
 uncenter the predicted data set.
 
void unstandardizeResults ()
 unstandardize the predicted data set and the residuals.
 

Protected Member Functions

 IAAModel (Array *p_workData)
 Constructor.
 
 IAAModel (Array &workData)
 Constructor.
 

Protected Attributes

Regressorp_regressor_
 pointer on the regression method.
 
Reducerp_reducer_
 pointer on the reeducer.
 
Array * p_workData_
 Array of the local data set.
 
Array * p_reduced_
 Array of the reduced data set : the data set is shared with p_reducer and set when the regression method is call.
 
Array * p_predicted_
 Array of the predicted data set: the data set is shared with p_regressor and set when the regression method is call.
 
Array * p_residuals_
 Array of the residuals: the data set is shared with p_regressor and set when the regression method is call.
 

Private Types

typedef IRegression< Array, Array, VectorXRegressor
 regression type
 
typedef IReducer< Array, VectorXReducer
 reducer type
 

Private Attributes

int dim_
 The dimension of the AA Model.
 
PointX mean_
 vector of the means of the input data set.
 
PointX 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
 

Detailed Description

template<class Array>
class STK::IAAModel< Array >

@

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 Projecttion'' or theReduction'') is a map from $\mathbb{R}^p$ to $ \mathbb{R}^d $ and R (the `‘Regression’') is a map from $\mathbb{R}^d$ to $\mathbb{R}^p$ .

The IAAModel class is an abstract base class for all these AAM and a factory method that propose some tools that can be used in derived classes. End user can have to set a reducer and a regressor in order to implement this interface.

Definition at line 71 of file STK_IAAModel.h.

Member Typedef Documentation

◆ Reducer

template<class Array >
typedef IReducer<Array, VectorX > STK::IAAModel< Array >::Reducer
private

reducer type

Definition at line 77 of file STK_IAAModel.h.

◆ Regressor

template<class Array >
typedef IRegression<Array, Array, VectorX > STK::IAAModel< Array >::Regressor
private

regression type

Definition at line 75 of file STK_IAAModel.h.

Constructor & Destructor Documentation

◆ IAAModel() [1/2]

template<class Array >
STK::IAAModel< Array >::IAAModel ( Array *  p_workData)
protected

Constructor.

Parameters
p_workDataA pointer on the the working data set

Definition at line 203 of file STK_IAAModel.h.

204 : p_regressor_(0)
205 , p_reducer_(0)
206 , p_workData_(p_workData)
207 , p_reduced_(0)
208 , p_predicted_(0)
209 , p_residuals_(0)
210 , dim_(0)
211 , mean_()
212 , std_()
213 , isCentered_(false)
214 , isStandardized_(false)
215{}
Array * p_residuals_
Array of the residuals: the data set is shared with p_regressor and set when the regression method is...
int dim_
The dimension of the AA Model.
Reducer * p_reducer_
pointer on the reeducer.
bool isStandardized_
a boolean true if the working data set is standardized, false otherwise
Array * p_workData_
Array of the local data set.
Array * p_reduced_
Array of the reduced data set : the data set is shared with p_reducer and set when the regression met...
bool isCentered_
a boolean true if the working data set is centered, false otherwise.
Regressor * p_regressor_
pointer on the regression method.
PointX mean_
vector of the means of the input data set.
Array * p_predicted_
Array of the predicted data set: the data set is shared with p_regressor and set when the regression ...
PointX std_
vector of the standard deviation of the input data set.

◆ IAAModel() [2/2]

template<class Array >
STK::IAAModel< Array >::IAAModel ( Array &  workData)
protected

Constructor.

Parameters
workDatathe working data set

Definition at line 218 of file STK_IAAModel.h.

219 : p_regressor_(0)
220 , p_reducer_(0)
222 , p_reduced_(0)
223 , p_predicted_(0)
224 , p_residuals_(0)
225 , dim_(0)
226 , mean_()
227 , std_()
228 , isCentered_(false)
229 , isStandardized_(false)
230{ }
Array const & workData() const

◆ ~IAAModel()

template<class Array >
STK::IAAModel< Array >::~IAAModel ( )

destructor.

Definition at line 234 of file STK_IAAModel.h.

235{}

Member Function Documentation

◆ center() [1/2]

template<class Array >
void STK::IAAModel< Array >::center ( )

center the data set workData_.

Definition at line 282 of file STK_IAAModel.h.

283{
284#ifdef STK_AAMODELS_DEBUG
285 if (!p_workData_)
287#endif
288 // we have to uncenter in case they have been centered with weights
289 if (isCentered_)
290 {
292 isCentered_ = false;
293 }
295 isCentered_ = true;
296}
#define STKRUNTIME_ERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:138
void center()
center the data set workData_.
void center(Array &m, RowVector &mean)
Compute the mean by column of the variables in the container m and center it.
void uncenter(Array &m, RowVector const &mean)
Add the means to the columns of the container m.

References STK::Stat::center(), STKRUNTIME_ERROR_NO_ARG, and STK::Stat::uncenter().

◆ center() [2/2]

template<class Array >
void STK::IAAModel< Array >::center ( VectorX const weights)

weighted centering of the data set.

Parameters
weightsthe weights of the samples

Definition at line 300 of file STK_IAAModel.h.

301{
302#ifdef STK_AAMODELS_DEBUG
303 if (!p_workData_)
305#endif
306 // we have to uncenter in case of this is not the same weights
307 if (isCentered_)
308 {
310 isCentered_ = false;
311 }
312 // center
313 Stat::center(*p_workData_, weights, mean_);
314 isCentered_ = true;
315}

References STK::Stat::center(), STKRUNTIME_ERROR_NO_ARG, and STK::Stat::uncenter().

◆ dim()

template<class Array >
int STK::IAAModel< Array >::dim ( ) const
inline
Returns
the dimension of the model

Definition at line 104 of file STK_IAAModel.h.

104{ return dim_;}

References STK::IAAModel< Array >::dim_.

◆ freeReducer()

template<class Array >
void STK::IAAModel< Array >::freeReducer ( )

delete the reducer set to this model by the method setReducer.

delete the reducer allocated set to this model.

Definition at line 267 of file STK_IAAModel.h.

268{
269 if (p_reducer_) delete p_reducer_;
270 p_reducer_ = 0;
271}

◆ freeRegressor()

template<class Array >
void STK::IAAModel< Array >::freeRegressor ( )

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

delete the regressor allocated to this model.

Definition at line 274 of file STK_IAAModel.h.

275{
276 if (p_regressor_) delete p_regressor_;
277 p_regressor_ = 0;
278}

◆ isCentered()

template<class Array >
bool STK::IAAModel< Array >::isCentered ( ) const
inline
Returns
true if the data set is centered, false otherwise

Definition at line 106 of file STK_IAAModel.h.

106{ return isCentered_;}

References STK::IAAModel< Array >::isCentered_.

◆ isStandardized()

template<class Array >
bool STK::IAAModel< Array >::isStandardized ( ) const
inline
Returns
true if the data set is standardized, false otherwise

Definition at line 108 of file STK_IAAModel.h.

108{ return isStandardized_;}

References STK::IAAModel< Array >::isStandardized_.

◆ mean()

template<class Array >
PointX const & STK::IAAModel< Array >::mean ( ) const
inline
Returns
the mean of the data set

Definition at line 110 of file STK_IAAModel.h.

110{ return mean_;}

References STK::IAAModel< Array >::mean_.

◆ p_predicted()

template<class Array >
Array *const & STK::IAAModel< Array >::p_predicted ( ) const
inline
Returns
a pointer on the predicted values

Definition at line 100 of file STK_IAAModel.h.

100{ return p_predicted_;}

References STK::IAAModel< Array >::p_predicted_.

◆ p_reduced()

template<class Array >
Array *const & STK::IAAModel< Array >::p_reduced ( ) const
inline
Returns
the reduced data set

Definition at line 98 of file STK_IAAModel.h.

98{ return p_reduced_;}

References STK::IAAModel< Array >::p_reduced_.

◆ p_reducer()

template<class Array >
Reducer *const & STK::IAAModel< Array >::p_reducer ( ) const
inline
Returns
a reference on the Index object

Definition at line 94 of file STK_IAAModel.h.

94{ return p_reducer_;}

References STK::IAAModel< Array >::p_reducer_.

◆ p_regressor()

template<class Array >
Regressor *const & STK::IAAModel< Array >::p_regressor ( ) const
inline
Returns
a reference on the regresor object

Definition at line 96 of file STK_IAAModel.h.

96{ return p_regressor_;}

References STK::IAAModel< Array >::p_regressor_.

◆ p_residuals()

template<class Array >
Array *const & STK::IAAModel< Array >::p_residuals ( ) const
inline
Returns
A ptr on the residuals

Definition at line 102 of file STK_IAAModel.h.

102{ return p_residuals_;}

References STK::IAAModel< Array >::p_residuals_.

◆ reductionStep() [1/2]

template<class Array >
void STK::IAAModel< Array >::reductionStep ( )

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

The reducer p_reducer have to be set.

Definition at line 357 of file STK_IAAModel.h.

358{
359#ifdef STK_AAMODELS_DEBUG
360 if (!p_reducer_)
361 STKRUNTIME_ERROR_NO_ARG(IAAModel<Array>::reduction,reducer is not set);
362#endif
363 // compute axis
365 p_reducer_->run();
366 // compute matrix multiplication
368}
void setDimension(const int &dim)
set the number of dimension.
Array * p_reduced() const
get a pointer on the reduced data set
virtual bool run()=0
run the computations.

References STKRUNTIME_ERROR_NO_ARG.

◆ reductionStep() [2/2]

template<class Array >
void STK::IAAModel< Array >::reductionStep ( VectorX const weights)

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

Definition at line 372 of file STK_IAAModel.h.

373{
374#ifdef STK_AAMODELS_DEBUG
375 if (!p_reducer_)
376 STKRUNTIME_ERROR_NO_ARG(IAAModel<Array>::reduction,reducer is not set);
377#endif
378 // compute axis
380 p_reducer_->run(weights);
381 // get the reduced data set
383}

References STKRUNTIME_ERROR_NO_ARG.

◆ regressionStep() [1/2]

template<class Array >
void STK::IAAModel< Array >::regressionStep ( )

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

Definition at line 387 of file STK_IAAModel.h.

388{
389#ifdef STK_AAMODELS_DEBUG
390 if (!p_regressor_)
392#endif
393 // compute regression
394 p_regressor_->run();
395 // get results
398}
void regressionStep()
compute the regression of the original data set and set the results in p_predicted and p_residuals.
virtual bool run()
run the computations.

References STKRUNTIME_ERROR_NO_ARG.

◆ regressionStep() [2/2]

template<class Array >
void STK::IAAModel< Array >::regressionStep ( VectorX 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 401 of file STK_IAAModel.h.

402{
403#ifdef STK_AAMODELS_DEBUG
404 if (!p_regressor_)
406#endif
407 p_regressor_->run(weights);
408 // get results
411}

References STKRUNTIME_ERROR_NO_ARG.

◆ setDimension()

template<class Array >
void STK::IAAModel< Array >::setDimension ( int const dim)
Parameters
dimthe dimension of the model to set

Definition at line 239 of file STK_IAAModel.h.

240{ dim_ = dim;}
int dim() const

◆ setReducer()

template<class Array >
void STK::IAAModel< Array >::setReducer ( Reducer p_reducer)
Parameters
p_reducera pointer on the reduction dimension method to use

Definition at line 256 of file STK_IAAModel.h.

Reducer *const & p_reducer() const

◆ setRegressor()

template<class Array >
void STK::IAAModel< Array >::setRegressor ( Regressor p_regressor)
Parameters
p_regressora pointer on the regression method to use

Definition at line 262 of file STK_IAAModel.h.

Regressor *const & p_regressor() const

◆ setWorkData()

template<class Array >
void STK::IAAModel< Array >::setWorkData ( Array &  workData)
Parameters
workDatathe working data set to treat

Definition at line 246 of file STK_IAAModel.h.

247{
249 isCentered_ = false;
250 isStandardized_ = false;
251}

Referenced by STK::GaussianAAModel< Array >::setWorkData().

◆ standardize() [1/2]

template<class Array >
void STK::IAAModel< Array >::standardize ( )

standardize the data set.

Definition at line 319 of file STK_IAAModel.h.

320{
321#ifdef STK_AAMODELS_DEBUG
322 if (!p_workData_)
324#endif
325 // we have to unstandardize in case they have been standardized with weights
326 if (isStandardized_)
327 {
329 isStandardized_ = false;
330 }
332 isStandardized_ = true;
333}
void standardize()
standardize the data set.
void unstandardize(Array &m, RowVector const &std)
undo the standardization by columns of the standardized variable m.
void standardize(Array &m, RowVector &mean, RowVector &std, bool unbiased=false)
Compute the mean and the standard deviation by columns of the variable m and standardize it.

References STK::Stat::standardize(), STKRUNTIME_ERROR_NO_ARG, and STK::Stat::unstandardize().

◆ standardize() [2/2]

template<class Array >
void STK::IAAModel< Array >::standardize ( VectorX const weights)

weighted standardization the data set.

Parameters
weightsthe weights of the samples

Definition at line 337 of file STK_IAAModel.h.

338{
339#ifdef STK_AAMODELS_DEBUG
340 if (!p_workData_)
342#endif
343 // we have to unstandardize in case of this is not the same weights
344 if (isStandardized_)
345 {
347 isStandardized_ = false;
348 }
349 // standardize
351 isStandardized_ = true;
352}

References STK::Stat::standardize(), STKRUNTIME_ERROR_NO_ARG, and STK::Stat::unstandardize().

◆ std()

template<class Array >
PointX const & STK::IAAModel< Array >::std ( ) const
inline
Returns
the standard deviation of the data set

Definition at line 112 of file STK_IAAModel.h.

112{ return std_;}

References STK::IAAModel< Array >::std_.

◆ uncenterResults()

template<class Array >
void STK::IAAModel< Array >::uncenterResults ( )

uncenter the predicted data set.

This will invalidate the results of p_regressor_.

Definition at line 415 of file STK_IAAModel.h.

416{
417#ifdef STK_AAMODELS_DEBUG
418 if (!p_predicted_)
419 STKRUNTIME_ERROR_NO_ARG(IAAModel<Array>::uncenterResults,predictions are not computed);
420#endif
422}
void uncenterResults()
uncenter the predicted data set.

References STKRUNTIME_ERROR_NO_ARG, and STK::Stat::uncenter().

◆ unstandardizeResults()

template<class Array >
void STK::IAAModel< Array >::unstandardizeResults ( )

unstandardize the predicted data set and the residuals.

This will invalidate the results of p_regressor_.

Definition at line 425 of file STK_IAAModel.h.

426{
427#ifdef STK_AAMODELS_DEBUG
428 if (!p_predicted_)
430 if (!p_residuals_)
432#endif
435}
void unstandardizeResults()
unstandardize the predicted data set and the residuals.

References STKRUNTIME_ERROR_NO_ARG, and STK::Stat::unstandardize().

◆ workData()

template<class Array >
Array const & STK::IAAModel< Array >::workData ( ) const
inline
Returns
the working data set

Definition at line 92 of file STK_IAAModel.h.

92{ return *p_workData_;}

References STK::IAAModel< Array >::p_workData_.

Member Data Documentation

◆ dim_

template<class Array >
int STK::IAAModel< Array >::dim_
private

The dimension of the AA Model.

Definition at line 186 of file STK_IAAModel.h.

Referenced by STK::IAAModel< Array >::dim().

◆ isCentered_

template<class Array >
bool STK::IAAModel< Array >::isCentered_
private

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

Definition at line 193 of file STK_IAAModel.h.

Referenced by STK::IAAModel< Array >::isCentered().

◆ isStandardized_

template<class Array >
bool STK::IAAModel< Array >::isStandardized_
private

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

Definition at line 196 of file STK_IAAModel.h.

Referenced by STK::IAAModel< Array >::isStandardized().

◆ mean_

template<class Array >
PointX STK::IAAModel< Array >::mean_
private

vector of the means of the input data set.

Definition at line 188 of file STK_IAAModel.h.

Referenced by STK::IAAModel< Array >::mean().

◆ p_predicted_

template<class Array >
Array* STK::IAAModel< Array >::p_predicted_
protected

Array of the predicted data set: the data set is shared with p_regressor and set when the regression method is call.

Definition at line 178 of file STK_IAAModel.h.

Referenced by STK::IAAModel< Array >::p_predicted().

◆ p_reduced_

template<class Array >
Array* STK::IAAModel< Array >::p_reduced_
protected

Array of the reduced data set : the data set is shared with p_reducer and set when the regression method is call.

Definition at line 175 of file STK_IAAModel.h.

Referenced by STK::IAAModel< Array >::p_reduced().

◆ p_reducer_

template<class Array >
Reducer* STK::IAAModel< Array >::p_reducer_
protected

pointer on the reeducer.

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

Definition at line 169 of file STK_IAAModel.h.

Referenced by STK::IAAModel< Array >::p_reducer().

◆ p_regressor_

template<class Array >
Regressor* STK::IAAModel< Array >::p_regressor_
protected

pointer on the regression method.

The regression method will be chosen in the derived class.

Definition at line 165 of file STK_IAAModel.h.

Referenced by STK::LinearAAModel< Array >::LinearAAModel(), STK::LinearAAModel< Array >::LinearAAModel(), and STK::IAAModel< Array >::p_regressor().

◆ p_residuals_

template<class Array >
Array* STK::IAAModel< Array >::p_residuals_
protected

Array of the residuals: the data set is shared with p_regressor and set when the regression method is call.

Definition at line 182 of file STK_IAAModel.h.

Referenced by STK::IAAModel< Array >::p_residuals().

◆ p_workData_

template<class Array >
Array* STK::IAAModel< Array >::p_workData_
protected

Array of the local data set.

Definition at line 171 of file STK_IAAModel.h.

Referenced by STK::IAAModel< Array >::workData().

◆ std_

template<class Array >
PointX STK::IAAModel< Array >::std_
private

vector of the standard deviation of the input data set.

Definition at line 190 of file STK_IAAModel.h.

Referenced by STK::IAAModel< Array >::std().


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