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::TestingLearner Class Reference

#include <TestingLearner.h>

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

List of all members.

Public Member Functions

 TestingLearner ()
 Default constructor.
virtual void build ()
 Simply calls inherited::build() then build_().
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual TestingLearnerdeepCopy (CopiesMap &copies) const
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< 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.
virtual void setTrainingSet (VMat training_set, bool call_forget=true)
 Declares the training set.
void setExperimentDirectory (const PPath &the_expdir)
 The experiment directory is the directory in which files related to this model are to be saved.

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

PP< PTestertester

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

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

Private Types

typedef PLearner inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Definition at line 53 of file TestingLearner.h.


Member Typedef Documentation

Reimplemented from PLearn::PLearner.

Definition at line 58 of file TestingLearner.h.


Constructor & Destructor Documentation

PLearn::TestingLearner::TestingLearner ( )

Default constructor.

Definition at line 49 of file TestingLearner.cc.

{
    // ...

    // ### You may or may not want to call build_() to finish building the object
    // build_();
}

Member Function Documentation

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

Reimplemented from PLearn::PLearner.

Definition at line 62 of file TestingLearner.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 62 of file TestingLearner.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 62 of file TestingLearner.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 62 of file TestingLearner.cc.

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

Reimplemented from PLearn::Object.

Definition at line 62 of file TestingLearner.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 62 of file TestingLearner.cc.

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

Simply calls inherited::build() then build_().

Reimplemented from PLearn::PLearner.

Definition at line 85 of file TestingLearner.cc.

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

This does the actual building.

Reimplemented from PLearn::PLearner.

Definition at line 80 of file TestingLearner.cc.

{
}
string PLearn::TestingLearner::classname ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 62 of file TestingLearner.cc.

void PLearn::TestingLearner::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 134 of file TestingLearner.cc.

{
// Compute the costs from *already* computed output. 
// ...
}                                
void PLearn::TestingLearner::computeOutput ( const Vec input,
Vec output 
) const [virtual]

Computes the output from the input.

Reimplemented from PLearn::PLearner.

Definition at line 129 of file TestingLearner.cc.

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

{
    output.resize(0);
}    

Here is the call graph for this function:

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

Declares this class' options.

Reimplemented from PLearn::PLearner.

Definition at line 64 of file TestingLearner.cc.

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

{
    // ### 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

 
    declareOption(ol, "tester", &TestingLearner::tester, OptionBase::buildoption,
                  "The tester used by the TestingLearner.");

    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::PLearner.

Definition at line 115 of file TestingLearner.h.

TestingLearner * PLearn::TestingLearner::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::PLearner.

Definition at line 62 of file TestingLearner.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 112 of file TestingLearner.cc.

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

Reimplemented from PLearn::Object.

Definition at line 62 of file TestingLearner.cc.

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

Reimplemented from PLearn::Object.

Definition at line 62 of file TestingLearner.cc.

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

Reimplemented from PLearn::Object.

Definition at line 62 of file TestingLearner.cc.

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

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

Implements PLearn::PLearner.

Definition at line 141 of file TestingLearner.cc.

{
    static TVec<string> no_cost;
    return no_cost;
}
TVec< string > PLearn::TestingLearner::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 147 of file TestingLearner.cc.

{
    return tester->getStatNames();
}
void PLearn::TestingLearner::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::PLearner.

Definition at line 92 of file TestingLearner.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("TestingLearner::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
}
int PLearn::TestingLearner::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 107 of file TestingLearner.cc.

{
    return 0;
}
void PLearn::TestingLearner::setExperimentDirectory ( const PPath the_expdir) [virtual]

The experiment directory is the directory in which files related to this model are to be saved.

If it is an empty string, it is understood to mean that the user doesn't want any file created by this learner.

Reimplemented from PLearn::PLearner.

Definition at line 158 of file TestingLearner.cc.

{
    tester->setExperimentDirectory(the_expdir);
}
void PLearn::TestingLearner::setTrainingSet ( VMat  training_set,
bool  call_forget = true 
) [virtual]

Declares the training set.

Then calls build() and forget() if necessary. Also sets this learner's inputsize_ targetsize_ weightsize_ from those of the training_set. Note: You shouldn't have to override this in subclasses, except in maybe to forward the call to an underlying learner.

Reimplemented from PLearn::PLearner.

Definition at line 152 of file TestingLearner.cc.

{
    inherited::setTrainingSet(training_set, call_forget);
    tester->dataset = training_set;
}
void PLearn::TestingLearner::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 117 of file TestingLearner.cc.

References PLWARNING.

{
    if (stage > 0) {
        PLWARNING("In TestingLearner::train - Learner has already been trained");
        return;
    }
    train_stats->update(tester->perform(true));
    train_stats->setFieldNames(tester->getStatNames());
    stage = 1;
}

Member Data Documentation

Reimplemented from PLearn::PLearner.

Definition at line 115 of file TestingLearner.h.

Definition at line 72 of file TestingLearner.h.

Referenced by declareOptions().


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