Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::LinearRegressor Class Reference

#include <LinearRegressor.h>

Inheritance diagram for PLearn::LinearRegressor:

Inheritance graph
[legend]
Collaboration diagram for PLearn::LinearRegressor:

Collaboration graph
[legend]
List of all members.

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< stringgetTestCostNames () const
 Returns the names of the costs computed by computeCostsFromOutpus (and thus the test method).

virtual TVec< stringgetTrainCostNames () 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

Member Typedef Documentation

typedef PLearner PLearn::LinearRegressor::inherited [private]
 

Reimplemented from PLearn::PLearner.

Definition at line 54 of file LinearRegressor.h.


Constructor & Destructor Documentation

PLearn::LinearRegressor::LinearRegressor  ) 
 

Definition at line 48 of file LinearRegressor.cc.


Member Function Documentation

void PLearn::LinearRegressor::build  )  [virtual]
 

simply calls inherited::build() then build_()

Reimplemented from PLearn::PLearner.

Definition at line 105 of file LinearRegressor.cc.

References build_().

void PLearn::LinearRegressor::build_  )  [private]
 

This does the actual building.

Reimplemented from PLearn::PLearner.

Definition at line 93 of file LinearRegressor.cc.

Referenced by build().

void PLearn::LinearRegressor::computeCostsFromOutputs const Vec input,
const Vec output,
const Vec target,
Vec costs
const [virtual]
 

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.

void PLearn::LinearRegressor::computeOutput const Vec input,
Vec output
const [virtual]
 

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.

void PLearn::LinearRegressor::declareOptions OptionList ol  )  [static, protected]
 

Declares this class' options.

Reimplemented from PLearn::PLearner.

Definition at line 73 of file LinearRegressor.cc.

References PLearn::declareOption(), and PLearn::OptionList.

void PLearn::LinearRegressor::forget  )  [virtual]
 

(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.

TVec< string > PLearn::LinearRegressor::getTestCostNames  )  const [virtual]
 

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().

TVec< string > PLearn::LinearRegressor::getTrainCostNames  )  const [virtual]
 

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().

void PLearn::LinearRegressor::makeDeepCopyFromShallowCopy map< const void *, void * > &  copies  )  [virtual]
 

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.

int PLearn::LinearRegressor::outputsize  )  const [virtual]
 

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().

PLearn::LinearRegressor::PLEARN_DECLARE_OBJECT LinearRegressor   ) 
 

void PLearn::LinearRegressor::train  )  [virtual]
 

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.


Member Data Documentation

bool PLearn::LinearRegressor::cholesky
 

Definition at line 84 of file LinearRegressor.h.

Referenced by train().

Vec PLearn::LinearRegressor::extendedinput [mutable, private]
 

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().

Vec PLearn::LinearRegressor::input [mutable, private]
 

extendedinput.subVec(1,inputsize())

Definition at line 58 of file LinearRegressor.h.

Referenced by computeOutput(), makeDeepCopyFromShallowCopy(), and train().

real PLearn::LinearRegressor::sum_gammas [protected]
 

sum of weights if weighted error, also for re-using training set with different weight decays

Definition at line 67 of file LinearRegressor.h.

Referenced by forget(), and train().

real PLearn::LinearRegressor::sum_squared_y [protected]
 

can be re-used if train is called several times on the same data set

Definition at line 66 of file LinearRegressor.h.

Referenced by forget(), and train().

Vec PLearn::LinearRegressor::target [private]
 

Definition at line 59 of file LinearRegressor.h.

Referenced by makeDeepCopyFromShallowCopy(), and train().

Vec PLearn::LinearRegressor::train_costs [private]
 

Definition at line 60 of file LinearRegressor.h.

Referenced by makeDeepCopyFromShallowCopy(), and train().

real PLearn::LinearRegressor::weight_decay
 

factor on the squared norm of parameters penalty

Definition at line 85 of file LinearRegressor.h.

Referenced by computeCostsFromOutputs(), and train().

Mat PLearn::LinearRegressor::weights [protected]
 

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().

real PLearn::LinearRegressor::weights_norm [protected]
 

sum of squares of weights

Definition at line 76 of file LinearRegressor.h.

Referenced by computeCostsFromOutputs(), and train().

Mat PLearn::LinearRegressor::XtX [protected]
 

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().

Mat PLearn::LinearRegressor::XtY [protected]
 

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().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:27:45 2004 for PLearn by doxygen 1.3.7