|
STK++ 1.0
|
Partial specialization of the base class IRegress for the Multidimensional case. More...
#include <STK_IRegressMultivariate.h>
Public Types | |
| typedef IContainerBase < YContainer > | YContainer |
Public Member Functions | |
| IRegress (YContainer const *y=0, Matrix const *x=0) | |
| Constructor. | |
| virtual | ~IRegress () |
| Destructor. | |
| void | run () |
| run the computations. | |
| void | run (Vector const *p_weights) |
| run the weighted computations. | |
| void | deleteCol (Integer const &pos) |
| delete a column of the p_x_ container | |
| void | insertCol (Integer const &pos, Vector const &v) |
| insert a column of the p_x_ container | |
| 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 *y, Matrix const *x) |
| Set the data set the regression method should use. | |
| void | clean () |
| delete allocated memory. | |
Protected Member Functions | |
| void | computeResiduals () |
| Compute the residuals of the model. | |
Protected Attributes | |
| YContainer const * | y_ |
| Container of the output to regress. | |
| Matrix const * | 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. | |
Private Attributes | |
| Qr | decomposition |
QR decomposition of the matrix x. | |
Partial specialization of the base class IRegress for the Multidimensional case.
Definition at line 52 of file STK_IRegressMultivariate.h.
| typedef IContainerBase<YContainer> STK::IRegress< YContainer, Matrix >::YContainer |
Definition at line 55 of file STK_IRegressMultivariate.h.
| STK::IRegress< YContainer, Matrix >::IRegress | ( | YContainer const * | y = 0, |
| Matrix const * | x = 0 |
||
| ) | [inline] |
Constructor.
Initialize the data members.
| y | container with the observed output |
| x | container with the predictors of the model |
Definition at line 74 of file STK_IRegressMultivariate.h.
: y_(y) , x_(x) , p_weights_(0) , p_predicted_(0) , p_residuals_(0) , decomposition(*x) { ;}
| virtual STK::IRegress< YContainer, Matrix >::~IRegress | ( | ) | [inline, virtual] |
| void STK::IRegress< YContainer, Matrix >::run | ( | ) | [inline] |
run the computations.
Definition at line 88 of file STK_IRegressMultivariate.h.
References STK::IRegress< YContainer, XContainer >::prediction(), and STK::IRegress< YContainer, XContainer >::regression().
{
// remove any existing storage
clean();
// compute regression
regression();
// predictions
prediction();
// compute residuals
computeResiduals();
}
| void STK::IRegress< YContainer, Matrix >::run | ( | Vector const * | p_weights | ) | [inline] |
run the weighted computations.
| p_weights | pointer on the weights of the samples |
Definition at line 103 of file STK_IRegressMultivariate.h.
References STK::IRegress< YContainer, XContainer >::p_weights_, STK::IRegress< YContainer, XContainer >::prediction(), and STK::IRegress< YContainer, XContainer >::wregression().
{
// set weights
p_weights_ = p_weights;
// remove any existing storage
clean();
// compute weighted regression
wregression();
// create container of the predicted value and compute predictions
prediction();
// create container of the residuals and compute them
computeResiduals();
}
| void STK::IRegress< YContainer, Matrix >::deleteCol | ( | Integer const & | pos | ) |
delete a column of the p_x_ container
| void STK::IRegress< YContainer, Matrix >::insertCol | ( | Integer const & | pos, |
| Vector const & | v | ||
| ) |
insert a column of the p_x_ container
| YContainer* STK::IRegress< YContainer, Matrix >::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 126 of file STK_IRegressMultivariate.h.
References STK::IRegress< YContainer, XContainer >::p_predicted_.
{ return p_predicted_;}
| YContainer* STK::IRegress< YContainer, Matrix >::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 131 of file STK_IRegressMultivariate.h.
References STK::IRegress< YContainer, XContainer >::p_residuals_.
{ return p_residuals_;}
| void STK::IRegress< YContainer, Matrix >::setData | ( | YContainer const * | y, |
| Matrix const * | x | ||
| ) | [inline] |
Set the data set the regression method should use.
| y | data set to adjust |
| x | data set of the predictors |
Definition at line 137 of file STK_IRegressMultivariate.h.
{ y_ = y; x_ = x; decomposition.run(*x);}
| void STK::IRegress< YContainer, Matrix >::clean | ( | ) | [inline] |
delete allocated memory.
Definition at line 141 of file STK_IRegressMultivariate.h.
References STK::IRegress< YContainer, XContainer >::p_predicted_, and STK::IRegress< YContainer, XContainer >::p_residuals_.
{
if (p_predicted_) delete p_predicted_;
if (p_residuals_) delete p_residuals_;
}
| void STK::IRegress< YContainer, Matrix >::computeResiduals | ( | ) | [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 153 of file STK_IRegressMultivariate.h.
References STK::IRecursiveTemplate< Leaf >::asLeaf(), STK::IRecursiveTemplate< Leaf >::clone(), STK::IRegress< YContainer, XContainer >::p_predicted_, and STK::IRegress< YContainer, XContainer >::p_residuals_.
{
if (p_residuals_) delete p_residuals_;
p_residuals_ = y_->clone();
*p_residuals_ = y_->asLeaf() - *p_predicted_;
}
| virtual void STK::IRegress< YContainer, Matrix >::regression | ( | ) | [private, pure virtual] |
compute the regression function.
| virtual void STK::IRegress< YContainer, Matrix >::wregression | ( | ) | [private, pure virtual] |
compute the weighted regression function.
| virtual void STK::IRegress< YContainer, Matrix >::prediction | ( | ) | [private, pure virtual] |
Compute the predicted outputs by the regression function.
YContainer const* STK::IRegress< YContainer, Matrix >::y_ [protected] |
Container of the output to regress.
Definition at line 59 of file STK_IRegressMultivariate.h.
Matrix const* STK::IRegress< YContainer, Matrix >::x_ [protected] |
Container of the regressors.
Definition at line 61 of file STK_IRegressMultivariate.h.
Vector const* STK::IRegress< YContainer, Matrix >::p_weights_ [protected] |
weigths of the samples.
Definition at line 63 of file STK_IRegressMultivariate.h.
YContainer* STK::IRegress< YContainer, Matrix >::p_predicted_ [protected] |
Container of the predicted output.
Definition at line 65 of file STK_IRegressMultivariate.h.
YContainer* STK::IRegress< YContainer, Matrix >::p_residuals_ [protected] |
Container of the residuals.
Definition at line 67 of file STK_IRegressMultivariate.h.
Qr STK::IRegress< YContainer, Matrix >::decomposition [private] |
QR decomposition of the matrix x.
Definition at line 168 of file STK_IRegressMultivariate.h.