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

PLearn::MovingAverage Class Reference

This SequentialLearner only takes the n previous target to predict the next one. More...

#include <MovingAverage.h>

Inheritance diagram for PLearn::MovingAverage:

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

Collaboration graph
[legend]
List of all members.

Public Types

typedef SequentialLearner inherited
 Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be.


Public Member Functions

 MovingAverage ()
 Constructor.

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

virtual void train ()
virtual void test (VMat testset, PP< VecStatsCollector > test_stats, VMat testoutputs=0, VMat testcosts=0) const
virtual void computeCostsFromOutputs (const Vec &inputs, const Vec &outputs, const Vec &targets, Vec &costs) const
 *** SUBCLASS WRITING: *** This should be defined in subclasses to compute the weighted costs from already computed output.

virtual TVec< stringgetTrainCostNames () const
 *** SUBCLASS WRITING: *** This should return the names of the objective costs that the train method computes and for which it updates the VecStatsCollector train_stats

virtual TVec< stringgetTestCostNames () const
 *** SUBCLASS WRITING: *** This should return the names of the costs computed by computeCostsFromOutpus

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!)

 PLEARN_DECLARE_OBJECT (MovingAverage)

Public Attributes

int window_length
Array< stringcost_funcs

Static Protected Member Functions

void declareOptions (OptionList &ol)
 Declare this class' options.


Private Member Functions

void build_ ()
 This does the actual building.


Detailed Description

This SequentialLearner only takes the n previous target to predict the next one.

This is a memoryless learner!

Definition at line 49 of file MovingAverage.h.


Member Typedef Documentation

typedef SequentialLearner PLearn::MovingAverage::inherited
 

Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be.

Reimplemented from PLearn::SequentialLearner.

Definition at line 87 of file MovingAverage.h.


Constructor & Destructor Documentation

PLearn::MovingAverage::MovingAverage  ) 
 

Constructor.

Definition at line 48 of file MovingAverage.cc.


Member Function Documentation

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

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

Reimplemented from PLearn::SequentialLearner.

Definition at line 64 of file MovingAverage.cc.

References build_().

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

This does the actual building.

Reimplemented from PLearn::SequentialLearner.

Definition at line 52 of file MovingAverage.cc.

References cost_funcs, forget(), PLERROR, PLearn::TVec< string >::size(), and window_length.

Referenced by build().

void PLearn::MovingAverage::computeCostsFromOutputs const Vec inputs,
const Vec outputs,
const Vec targets,
Vec costs
const [virtual]
 

*** SUBCLASS WRITING: *** This should be defined in subclasses to compute the weighted costs from already computed output.

The costs should correspond to the cost names returned by getTestCostNames() NOTE: In exotic cases, the cost may also depend on some info in the input, that's why the method also gets so see it.

Reimplemented from PLearn::SequentialLearner.

Definition at line 183 of file MovingAverage.cc.

References cost_funcs, PLERROR, PLearn::TVec< string >::size(), and PLearn::square().

Referenced by test(), and train().

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

Declare this class' options.

Reimplemented from PLearn::SequentialLearner.

Definition at line 70 of file MovingAverage.cc.

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

void PLearn::MovingAverage::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!)

*** SUBCLASS WRITING: *** A typical forget() method should do the following:

  • initialize a random number generator with the seed option
  • initialize the learner's parameters, using this random generator
  • stage = 0; This method is typically called by the build_() method, after it has finished setting up the parameters, and if it deemed useful to set or reset the learner in its fresh state. (remember build may be called after modifying options that do not necessarily require the learner to restart from a fresh state...) forget is also called by the setTrainingSet method, after calling build(), so it will generally be called TWICE during setTrainingSet!

Reimplemented from PLearn::SequentialLearner.

Definition at line 201 of file MovingAverage.cc.

Referenced by build_().

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

*** SUBCLASS WRITING: *** This should return the names of the costs computed by computeCostsFromOutpus

Implements PLearn::PLearner.

Definition at line 198 of file MovingAverage.cc.

References getTrainCostNames().

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

*** SUBCLASS WRITING: *** This should return 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 195 of file MovingAverage.cc.

References cost_funcs.

Referenced by getTestCostNames().

PLearn::MovingAverage::PLEARN_DECLARE_OBJECT MovingAverage   ) 
 

void PLearn::MovingAverage::test VMat  testset,
PP< VecStatsCollector test_stats,
VMat  testoutputs = 0,
VMat  testcosts = 0
const [virtual]
 

*** SUBCLASS WRITING: *** The method should:

  • call computeOutputAndCosts on the test set
  • save the outputs and the costs in the predictions & errors matrices, beginning at position last_call_train_t

Implements PLearn::SequentialLearner.

Definition at line 130 of file MovingAverage.cc.

References PLearn::columnMean(), computeCostsFromOutputs(), PLearn::endl(), PLearn::VMat::getSubRow(), PLearn::TVec< T >::hasMissing(), PLearn::PLearner::inputsize(), PLearn::VMat::length(), MAX, PLearn::SequentialLearner::outputsize(), PLearn::VMat::subMat(), PLearn::PLearner::targetsize(), PLearn::VMat::toMat(), PLearn::ProgressBar::update(), and window_length.

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

*** SUBCLASS WRITING: *** Does the actual training. Subclasses must implement this method. The method should upon entry, call setTrainingSet(training_set); The method should:

  • do nothing if we already called it with this value of train.length or a value between [last_train_t-train_step+1,last_train_t]
  • if not, train and update the value of last_train_t
  • in either case, update the value of last_call_train_t

Implements PLearn::SequentialLearner.

Definition at line 81 of file MovingAverage.cc.

References PLearn::columnMean(), computeCostsFromOutputs(), PLearn::endl(), PLearn::VMat::getSubRow(), PLearn::TVec< T >::hasMissing(), PLearn::PLearner::inputsize(), PLearn::VMat::length(), PLearn::Mat, MAX, PLearn::SequentialLearner::outputsize(), PLearn::VMat::subMat(), PLearn::PLearner::targetsize(), PLearn::ProgressBar::update(), PLearn::Vec, and window_length.


Member Data Documentation

Array<string> PLearn::MovingAverage::cost_funcs
 

Definition at line 54 of file MovingAverage.h.

Referenced by build_(), computeCostsFromOutputs(), and getTrainCostNames().

int PLearn::MovingAverage::window_length
 

Definition at line 53 of file MovingAverage.h.

Referenced by build_(), test(), and train().


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