PLearn 0.1
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions | Private Types | Private Member Functions
PLearn::TestLearner Class Reference

The first sentence should be a BRIEF DESCRIPTION of what the class does. More...

#include <TestLearner.h>

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

List of all members.

Public Member Functions

 TestLearner ()
 ### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!
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!).
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.
virtual void computeCostsFromOutputs (const Vec &input, const Vec &output, const Vec &target, Vec &costs) const
 Computes the costs from already computed output.
virtual TVec< std::string > getTestCostNames () const
 Returns the names of the costs computed by computeCostsFromOutpus (and thus the test method).
virtual TVec< std::string > getTrainCostNames () const
 Returns the names of the objective costs that the train method computes and for which it updates the VecStatsCollector train_stats.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual TestLearnerdeepCopy (CopiesMap &copies) const
virtual void build ()
 Finish building the object; just call inherited::build followed by build_()
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.

Static Public Member Functions

static string _classname_ ()
static OptionList_getOptionList_ ()
static RemoteMethodMap_getRemoteMethodMap_ ()
static Object_new_instance_for_typemap_ ()
static bool _isa_ (const Object *o)
static void _static_initialize_ ()
static const PPathdeclaringFile ()

Public Attributes

std::string dir_path
Vec train_costs

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declares the class options.

Private Types

typedef PLearner inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

The first sentence should be a BRIEF DESCRIPTION of what the class does.

Place the rest of the class programmer documentation here. Doxygen supports Javadoc-style comments. See http://www.doxygen.org/manual.html

Todo:
Write class to-do's here if there are any.
Deprecated:
Write deprecated stuff here if there is any. Indicate what else should be used instead.

Definition at line 61 of file TestLearner.h.


Member Typedef Documentation

Reimplemented from PLearn::PLearner.

Definition at line 63 of file TestLearner.h.


Constructor & Destructor Documentation

PLearn::TestLearner::TestLearner ( )

### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!

Default constructor

Definition at line 54 of file TestLearner.cc.

        {
                // ...

                // ### You may (or not) want to call build_() to finish building the object
                // ### (doing so assumes the parent classes' build_() have been called too
                // ### in the parent classes' constructors, something that you must ensure)
        }

Member Function Documentation

string PLearn::TestLearner::_classname_ ( ) [static]

Reimplemented from PLearn::PLearner.

Definition at line 52 of file TestLearner.cc.

OptionList & PLearn::TestLearner::_getOptionList_ ( ) [static]

Reimplemented from PLearn::PLearner.

Definition at line 52 of file TestLearner.cc.

RemoteMethodMap & PLearn::TestLearner::_getRemoteMethodMap_ ( ) [static]

Reimplemented from PLearn::PLearner.

Definition at line 52 of file TestLearner.cc.

bool PLearn::TestLearner::_isa_ ( const Object o) [static]

Reimplemented from PLearn::PLearner.

Definition at line 52 of file TestLearner.cc.

Object * PLearn::TestLearner::_new_instance_for_typemap_ ( ) [static]

Reimplemented from PLearn::Object.

Definition at line 52 of file TestLearner.cc.

StaticInitializer TestLearner::_static_initializer_ & PLearn::TestLearner::_static_initialize_ ( ) [static]

Reimplemented from PLearn::PLearner.

Definition at line 52 of file TestLearner.cc.

void PLearn::TestLearner::build ( ) [virtual]

Finish building the object; just call inherited::build followed by build_()

Reimplemented from PLearn::PLearner.

Definition at line 96 of file TestLearner.cc.

void PLearn::TestLearner::build_ ( ) [private]

This does the actual building.

Reimplemented from PLearn::PLearner.

Definition at line 84 of file TestLearner.cc.

        {
                // ### This method should do the real building of the object,
                // ### according to set 'options', in *any* situation. 
                // ### Typical situations include:
                // ###  - Initial building of an object from a few user-specified options
                // ###  - Building of a "reloaded" object: i.e. from the complete set of all serialised options.
                // ###  - Updating or "re-building" of an object after a few "tuning" options have been modified.
                // ### You should assume that the parent class' build_() has already been called.
        }
string PLearn::TestLearner::classname ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 52 of file TestLearner.cc.

void PLearn::TestLearner::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 175 of file TestLearner.cc.

References PLearn::TVec< T >::resize().

        {
// Compute the costs from *already* computed output. 
                costs.resize(1) ; 
                costs[0] = 1 ; 
        }                                

Here is the call graph for this function:

void PLearn::TestLearner::computeOutput ( const Vec input,
Vec output 
) const [virtual]

Computes the output from the input.

Reimplemented from PLearn::PLearner.

Definition at line 166 of file TestLearner.cc.

References PLearn::TVec< T >::resize().

        {
                // Compute the output from the input.
                int nout = outputsize();
                output.resize(nout);
                output[0] = 1 ; 
                // ...
        }    

Here is the call graph for this function:

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

Declares the class options.

Reimplemented from PLearn::PLearner.

Definition at line 64 of file TestLearner.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), and dir_path.

        {
                // ### Declare all of this object's options here
                // ### For the "flags" of each option, you should typically specify  
                // ### one of OptionBase::buildoption, OptionBase::learntoption or 
                // ### OptionBase::tuningoption. Another possible flag to be combined with
                // ### is OptionBase::nosave

                // ### ex:
                // declareOption(ol, "myoption", &TestLearner::myoption, OptionBase::buildoption,
                //               "Help text describing this option");
                // ...

                // Now call the parent class' declareOptions

                declareOption(ol,"dir_path", &TestLearner::dir_path, OptionBase::buildoption,
                                          "The Path to the training data");
                inherited::declareOptions(ol);
        }

Here is the call graph for this function:

static const PPath& PLearn::TestLearner::declaringFile ( ) [inline, static]

Reimplemented from PLearn::PLearner.

Definition at line 140 of file TestLearner.h.

:
    //#####  Protected Options  ###############################################
TestLearner * PLearn::TestLearner::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::PLearner.

Definition at line 52 of file TestLearner.cc.

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

(Re-)initialize 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!)

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

Reimplemented from PLearn::PLearner.

Definition at line 127 of file TestLearner.cc.

        {

                stage = 0 ; 
        }
OptionList & PLearn::TestLearner::getOptionList ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 52 of file TestLearner.cc.

OptionMap & PLearn::TestLearner::getOptionMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 52 of file TestLearner.cc.

RemoteMethodMap & PLearn::TestLearner::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 52 of file TestLearner.cc.

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

Returns the names of the costs computed by computeCostsFromOutpus (and thus the test method).

Implements PLearn::PLearner.

Definition at line 183 of file TestLearner.cc.

        {
                // Return the names of the costs computed by computeCostsFromOutpus
                // (these may or may not be exactly the same as what's returned by getTrainCostNames).
                // ...
                TVec<string> t(1) ; 
                t[0] = "binary_class_error" ;           
                return t ; 
        }
TVec< string > PLearn::TestLearner::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 193 of file TestLearner.cc.

        {
                TVec<string> t(1) ; 
                t[0] = "binary_class_error" ;
                return t ; 
                // Return the names of the objective costs that the train method computes and 
                // for which it updates the VecStatsCollector train_stats
                // (these may or may not be exactly the same as what's returned by getTestCostNames).
                // ...
        }
void PLearn::TestLearner::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::PLearner.

Definition at line 103 of file TestLearner.cc.

References PLERROR.

        {
                inherited::makeDeepCopyFromShallowCopy(copies);

                // ### Call deepCopyField on all "pointer-like" fields 
                // ### that you wish to be deepCopied rather than 
                // ### shallow-copied.
                // ### ex:
                // deepCopyField(trainvec, copies);

                // ### Remove this line when you have fully implemented this method.
                PLERROR("TestLearner::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");             
                

        }
int PLearn::TestLearner::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 120 of file TestLearner.cc.

        {
                // Compute and return the size of this learner's output (which typically
                // may depend on its inputsize(), targetsize() and set options).
                return 1 ; 
        }
void PLearn::TestLearner::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.

Implements PLearn::PLearner.

Definition at line 141 of file TestLearner.cc.

        {
                // The role of the train method is to bring the learner up to stage==nstages,
                // updating train_stats with training costs measured on-line in the process.

                /* TYPICAL CODE:
        
                static Vec input  // static so we don't reallocate/deallocate memory each time...
                static Vec target // (but be careful that static means shared!)
                input.resize(inputsize())    // the train_set's inputsize()
                target.resize(targetsize())  // the train_set's targetsize()
                real weight
                */

                if (!train_stats)  // make a default stats collector, in case there's none
                        train_stats = new VecStatsCollector() ;

                train_costs.resize(1);
                train_costs[0] = 0 ; 

                train_stats->update(train_costs) ; 
                train_stats->finalize() ; // finalize statistics for this epoch
        }

Member Data Documentation

Reimplemented from PLearn::PLearner.

Definition at line 140 of file TestLearner.h.

Definition at line 79 of file TestLearner.h.

Referenced by declareOptions().

Definition at line 80 of file TestLearner.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines