|
STK++ 1.0
|
Interface base class for Regression methods. More...
#include <STK_IRegress.h>
Public Member Functions | |
| IRegress (YContainer const *p_y=0, XContainer const *p_x=0) | |
| Constructor. | |
| virtual | ~IRegress () |
| virtual destructor. | |
| void | run () |
| run the computations. | |
| void | run (Vector const *p_weights) |
| run the weighted computations. | |
| YContainer * | p_predicted () const |
| get the pointer of the container of the predicted values. | |
| YContainer * | p_residuals () const |
| get the pointer of the container of the residuals. | |
| void | setData (YContainer const *p_y, XContainer const *p_x) |
| Set the data set the regression method should use. | |
| void | setY (YContainer const *p_y) |
| Set the Y data set the regression method should use. | |
| void | setX (XContainer const *p_x) |
| Set the X data set. | |
Protected Member Functions | |
| virtual void | preWork () |
| perform any work needed before the call of the regression method. | |
| void | residuals () |
| Compute the residuals of the model. | |
Protected Attributes | |
| YContainer const * | p_y_ |
| Container of the output to regress. | |
| XContainer const * | p_x_ |
| Container of the regressors. | |
| Vector const * | p_weights_ |
| weigths of the samples. | |
| YContainer * | p_predicted_ |
| Container of the predicted output. | |
| YContainer * | p_residuals_ |
| Container of the residuals. | |
Private Member Functions | |
| virtual void | regression ()=0 |
| compute the regression function. | |
| virtual void | wregression ()=0 |
| compute the weighted regression function. | |
| virtual void | prediction ()=0 |
| Compute the predicted outputs by the regression function and store the result in the p_predicted_ container. | |
| void | clear () |
| delete allocated memory. | |
Interface base class for Regression methods.
Definition at line 50 of file STK_IRegress.h.
| STK::IRegress< YContainer, XContainer >::IRegress | ( | YContainer const * | p_y = 0, |
| XContainer const * | p_x = 0 |
||
| ) | [inline] |
Constructor.
Initialize the data members.
| p_y | container with the observed output |
| p_x | container with the predictors (inputs) of the model |
Definition at line 69 of file STK_IRegress.h.
: p_y_(p_y) , p_x_(p_x) , p_weights_(0) , p_predicted_(0) , p_residuals_(0) { ;}
| virtual STK::IRegress< YContainer, XContainer >::~IRegress | ( | ) | [inline, virtual] |
| void STK::IRegress< YContainer, XContainer >::run | ( | ) | [inline] |
run the computations.
Definition at line 82 of file STK_IRegress.h.
Referenced by STK::IAAModel::regression(), and STK::IAAModel::wregression().
{
// remove any existing storage
clear();
// compute regression
regression();
// predictions
prediction();
// compute residuals
residuals();
}
| void STK::IRegress< YContainer, XContainer >::run | ( | Vector const * | p_weights | ) | [inline] |
run the weighted computations.
| p_weights | pointer on the weights of the samples |
Definition at line 97 of file STK_IRegress.h.
{
// set weights
p_weights_ = p_weights;
// remove any existing storage
clear();
// compute weighted regression
wregression();
// create container of the predicted value and compute prediction
prediction();
// create container of the residuals and compute them
residuals();
}
| YContainer* STK::IRegress< YContainer, XContainer >::p_predicted | ( | ) | const [inline] |
get the pointer of the container of the predicted values.
The container p_predicted_ will not be deleted by this.
Definition at line 115 of file STK_IRegress.h.
Referenced by STK::IAAModel::regression(), and STK::IAAModel::wregression().
{ return p_predicted_;}
| YContainer* STK::IRegress< YContainer, XContainer >::p_residuals | ( | ) | const [inline] |
get the pointer of the container of the residuals.
The container p_residuals_ will not be deleted by this.
Definition at line 121 of file STK_IRegress.h.
Referenced by STK::IAAModel::regression(), and STK::IAAModel::wregression().
{ return p_residuals_;}
| void STK::IRegress< YContainer, XContainer >::setData | ( | YContainer const * | p_y, |
| XContainer const * | p_x | ||
| ) | [inline] |
Set the data set the regression method should use.
| p_y | data set to adjust |
| p_x | data set of the predictors |
Definition at line 128 of file STK_IRegress.h.
| void STK::IRegress< YContainer, XContainer >::setY | ( | YContainer const * | p_y | ) | [inline] |
Set the Y data set the regression method should use.
| p_y | data set to adjust |
Definition at line 134 of file STK_IRegress.h.
Referenced by STK::IAAModel::run().
{ p_y_ = p_y;}
| void STK::IRegress< YContainer, XContainer >::setX | ( | XContainer const * | p_x | ) | [inline] |
Set the X data set.
| p_x | data set of the predictors |
Definition at line 140 of file STK_IRegress.h.
Referenced by STK::IAAModel::run().
{ p_x_ = p_x;}
| virtual void STK::IRegress< YContainer, XContainer >::preWork | ( | ) | [inline, protected, virtual] |
perform any work needed before the call of the regression method.
At this level do nothing.
Definition at line 148 of file STK_IRegress.h.
{ }
| void STK::IRegress< YContainer, XContainer >::residuals | ( | ) | [inline, protected] |
Compute the residuals of the model.
The residuals of the model are computed by computing the difference between the observed outputs and the predicted outputs of the model.
Definition at line 156 of file STK_IRegress.h.
Referenced by STK::IRegress< Matrix, Matrix >::run().
{
p_residuals_ = p_y_->clone();
*p_residuals_ = *p_y_ - *p_predicted_;
}
| virtual void STK::IRegress< YContainer, XContainer >::regression | ( | ) | [private, pure virtual] |
compute the regression function.
Implemented in STK::AdditiveBSplineRegression, STK::BSplineRegression, and STK::MultidimRegression.
Referenced by STK::IRegress< YContainer, Matrix >::run(), and STK::IRegress< Matrix, Matrix >::run().
| virtual void STK::IRegress< YContainer, XContainer >::wregression | ( | ) | [private, pure virtual] |
compute the weighted regression function.
Implemented in STK::AdditiveBSplineRegression, STK::BSplineRegression, and STK::MultidimRegression.
Referenced by STK::IRegress< YContainer, Matrix >::run(), and STK::IRegress< Matrix, Matrix >::run().
| virtual void STK::IRegress< YContainer, XContainer >::prediction | ( | ) | [private, pure virtual] |
Compute the predicted outputs by the regression function and store the result in the p_predicted_ container.
Implemented in STK::AdditiveBSplineRegression, STK::BSplineRegression, and STK::MultidimRegression.
Referenced by STK::IRegress< YContainer, Matrix >::run(), and STK::IRegress< Matrix, Matrix >::run().
| void STK::IRegress< YContainer, XContainer >::clear | ( | ) | [inline, private] |
delete allocated memory.
Definition at line 171 of file STK_IRegress.h.
Referenced by STK::IRegress< Matrix, Matrix >::run(), and STK::IRegress< Matrix, Matrix >::~IRegress().
{
if (p_predicted_) delete p_predicted_;
if (p_residuals_) delete p_residuals_;
p_predicted_ = 0;
p_residuals_ = 0;
}
YContainer const* STK::IRegress< YContainer, XContainer >::p_y_ [protected] |
Container of the output to regress.
Definition at line 54 of file STK_IRegress.h.
Referenced by STK::IRegress< Matrix, Matrix >::residuals(), STK::IRegress< Matrix, Matrix >::setData(), and STK::IRegress< Matrix, Matrix >::setY().
XContainer const* STK::IRegress< YContainer, XContainer >::p_x_ [protected] |
Container of the regressors.
Definition at line 56 of file STK_IRegress.h.
Referenced by STK::IRegress< Matrix, Matrix >::setData(), and STK::IRegress< Matrix, Matrix >::setX().
Vector const* STK::IRegress< YContainer, XContainer >::p_weights_ [protected] |
weigths of the samples.
Definition at line 58 of file STK_IRegress.h.
Referenced by STK::IRegress< YContainer, Matrix >::run(), and STK::IRegress< Matrix, Matrix >::run().
YContainer* STK::IRegress< YContainer, XContainer >::p_predicted_ [protected] |
Container of the predicted output.
Definition at line 60 of file STK_IRegress.h.
Referenced by STK::IRegress< YContainer, Matrix >::clean(), STK::IRegress< Matrix, Matrix >::clear(), STK::IRegress< YContainer, Matrix >::computeResiduals(), STK::IRegress< YContainer, Matrix >::p_predicted(), STK::IRegress< Matrix, Matrix >::p_predicted(), and STK::IRegress< Matrix, Matrix >::residuals().
YContainer* STK::IRegress< YContainer, XContainer >::p_residuals_ [protected] |
Container of the residuals.
Definition at line 62 of file STK_IRegress.h.
Referenced by STK::IRegress< YContainer, Matrix >::clean(), STK::IRegress< Matrix, Matrix >::clear(), STK::IRegress< YContainer, Matrix >::computeResiduals(), STK::IRegress< YContainer, Matrix >::p_residuals(), STK::IRegress< Matrix, Matrix >::p_residuals(), and STK::IRegress< Matrix, Matrix >::residuals().