#include <LinearRegressor.h>
Inheritance diagram for PLearn::LinearRegressor:
Public Member Functions | |
LinearRegressor () | |
virtual void | build () |
simply calls inherited::build() then build_() | |
virtual void | makeDeepCopyFromShallowCopy (map< const void *, void * > &copies) |
Transforms a shallow copy into a deep copy. | |
PLEARN_DECLARE_OBJECT (LinearRegressor) | |
virtual int | outputsize () const |
returns the size of this learner's output, (which typically may depend on its inputsize(), targetsize() and set options) | |
virtual void | forget () |
(Re-)initializes the PLearner in its fresh state (that state may depend on the 'seed' option) And sets 'stage' back to 0 (this is the stage of a fresh learner!) This resizes the XtX and XtY matrices to signify that their content needs to be recomputed. | |
virtual void | train () |
The role of the train method is to bring the learner up to stage==nstages, updating the train_stats collector with training costs measured on-line in the process. | |
virtual void | computeOutput (const Vec &input, Vec &output) const |
Computes the output from the input output = weights * (1, input). | |
virtual void | computeCostsFromOutputs (const Vec &input, const Vec &output, const Vec &target, Vec &costs) const |
Computes the costs from already computed output. | |
virtual TVec< string > | getTestCostNames () const |
Returns the names of the costs computed by computeCostsFromOutpus (and thus the test method). | |
virtual TVec< string > | getTrainCostNames () const |
Returns the names of the objective costs that the train method computes and for which it updates the VecStatsCollector train_stats. | |
Public Attributes | |
bool | cholesky |
real | weight_decay |
factor on the squared norm of parameters penalty | |
Static Protected Member Functions | |
void | declareOptions (OptionList &ol) |
Declares this class' options. | |
Protected Attributes | |
Mat | XtX |
can be re-used if train is called several times on the same data set | |
Mat | XtY |
can be re-used if train is called several times on the same data set | |
real | sum_squared_y |
can be re-used if train is called several times on the same data set | |
real | sum_gammas |
sum of weights if weighted error, also for re-using training set with different weight decays | |
Mat | weights |
The weight matrix computed by the regressor, (inputsize+1) x (outputsize). | |
real | weights_norm |
sum of squares of weights | |
Private Types | |
typedef PLearner | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. | |
Private Attributes | |
Vec | extendedinput |
length 1+inputsize(), first element is 1.0 (used by the use method) | |
Vec | input |
extendedinput.subVec(1,inputsize()) | |
Vec | target |
Vec | train_costs |
|
Reimplemented from PLearn::PLearner. Definition at line 54 of file LinearRegressor.h. |
|
Definition at line 48 of file LinearRegressor.cc. |
|
simply calls inherited::build() then build_()
Reimplemented from PLearn::PLearner. Definition at line 105 of file LinearRegressor.cc. References build_(). |
|
This does the actual building.
Reimplemented from PLearn::PLearner. Definition at line 93 of file LinearRegressor.cc. Referenced by build(). |
|
Computes the costs from already computed output.
Implements PLearn::PLearner. Definition at line 213 of file LinearRegressor.cc. References PLearn::powdistance(), PLearn::TVec< T >::resize(), weight_decay, and weights_norm. |
|
Computes the output from the input output = weights * (1, input).
Implements PLearn::PLearner. Definition at line 198 of file LinearRegressor.cc. References extendedinput, input, PLearn::PLearner::inputsize(), PLearn::TVec< T >::length(), outputsize(), PLearn::TVec< T >::resize(), PLearn::TVec< T >::subVec(), PLearn::transposeProduct(), and weights. |
|
Declares this class' options.
Reimplemented from PLearn::PLearner. Definition at line 73 of file LinearRegressor.cc. References PLearn::declareOption(), and PLearn::OptionList. |
|
(Re-)initializes the PLearner in its fresh state (that state may depend on the 'seed' option) And sets 'stage' back to 0 (this is the stage of a fresh learner!) This resizes the XtX and XtY matrices to signify that their content needs to be recomputed. When train is called repeatedly without an intervening call to forget(), it is assumed that the training set has not changed, and XtX and XtY are not recomputed, avoiding a possibly lengthy pass through the data. This is particarly useful when doing hyper-parameter optimization of the weight_decay. Implements PLearn::PLearner. Definition at line 141 of file LinearRegressor.cc. References PLearn::TMat< T >::resize(), sum_gammas, sum_squared_y, PLearn::TMat< T >::width(), XtX, and XtY. |
|
Returns the names of the costs computed by computeCostsFromOutpus (and thus the test method).
Implements PLearn::PLearner. Definition at line 223 of file LinearRegressor.cc. References getTrainCostNames(). |
|
Returns the names of the objective costs that the train method computes and for which it updates the VecStatsCollector train_stats.
Implements PLearn::PLearner. Definition at line 228 of file LinearRegressor.cc. Referenced by getTestCostNames(). |
|
Transforms a shallow copy into a deep copy.
Definition at line 112 of file LinearRegressor.cc. References PLearn::deepCopyField(), extendedinput, input, target, train_costs, weights, XtX, and XtY. |
|
returns the size of this learner's output, (which typically may depend on its inputsize(), targetsize() and set options)
Implements PLearn::PLearner. Definition at line 129 of file LinearRegressor.cc. References PLearn::PLearner::targetsize(). Referenced by computeOutput(), and train(). |
|
|
|
The role of the train method is to bring the learner up to stage==nstages, updating the train_stats collector with training costs measured on-line in the process. See the forget() comment. Implements PLearn::PLearner. Definition at line 150 of file LinearRegressor.cc. References cholesky, PLearn::dot(), extendedinput, input, PLearn::PLearner::inputsize(), PLearn::VMat::length(), PLearn::TVec< T >::length(), PLearn::TMat< T >::length(), PLearn::linearRegression(), outputsize(), PLERROR, PLearn::TMat< T >::resize(), PLearn::TVec< T >::resize(), PLearn::squared_error(), PLearn::VMat::subMatColumns(), PLearn::TMat< T >::subMatRows(), PLearn::TVec< T >::subVec(), sum_gammas, sum_squared_y, target, PLearn::PLearner::targetsize(), train_costs, weight_decay, PLearn::weightedLinearRegression(), weights, weights_norm, XtX, and XtY. |
|
Definition at line 84 of file LinearRegressor.h. Referenced by train(). |
|
length 1+inputsize(), first element is 1.0 (used by the use method)
Definition at line 57 of file LinearRegressor.h. Referenced by computeOutput(), makeDeepCopyFromShallowCopy(), and train(). |
|
extendedinput.subVec(1,inputsize())
Definition at line 58 of file LinearRegressor.h. Referenced by computeOutput(), makeDeepCopyFromShallowCopy(), and train(). |
|
sum of weights if weighted error, also for re-using training set with different weight decays
Definition at line 67 of file LinearRegressor.h. |
|
can be re-used if train is called several times on the same data set
Definition at line 66 of file LinearRegressor.h. |
|
Definition at line 59 of file LinearRegressor.h. Referenced by makeDeepCopyFromShallowCopy(), and train(). |
|
Definition at line 60 of file LinearRegressor.h. Referenced by makeDeepCopyFromShallowCopy(), and train(). |
|
factor on the squared norm of parameters penalty
Definition at line 85 of file LinearRegressor.h. Referenced by computeCostsFromOutputs(), and train(). |
|
The weight matrix computed by the regressor, (inputsize+1) x (outputsize).
Definition at line 75 of file LinearRegressor.h. Referenced by computeOutput(), makeDeepCopyFromShallowCopy(), and train(). |
|
sum of squares of weights
Definition at line 76 of file LinearRegressor.h. Referenced by computeCostsFromOutputs(), and train(). |
|
can be re-used if train is called several times on the same data set
Definition at line 64 of file LinearRegressor.h. Referenced by forget(), makeDeepCopyFromShallowCopy(), and train(). |
|
can be re-used if train is called several times on the same data set
Definition at line 65 of file LinearRegressor.h. Referenced by forget(), makeDeepCopyFromShallowCopy(), and train(). |