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

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

#include <RegressorFromDistribution.h>

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

List of all members.

Public Member Functions

 RegressorFromDistribution ()
 Default constructor.
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 void setTrainingSet (VMat training_set, bool call_forget=true)
 Overridden to forward to the underlying distribution.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual RegressorFromDistributiondeepCopy (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

PP< PDistributiondistribution

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 58 of file RegressorFromDistribution.h.


Member Typedef Documentation

Reimplemented from PLearn::PLearner.

Definition at line 60 of file RegressorFromDistribution.h.


Constructor & Destructor Documentation

PLearn::RegressorFromDistribution::RegressorFromDistribution ( )

Default constructor.

Definition at line 58 of file RegressorFromDistribution.cc.

{}

Member Function Documentation

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

Reimplemented from PLearn::PLearner.

Definition at line 53 of file RegressorFromDistribution.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 53 of file RegressorFromDistribution.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 53 of file RegressorFromDistribution.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 53 of file RegressorFromDistribution.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file RegressorFromDistribution.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 53 of file RegressorFromDistribution.cc.

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

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

Reimplemented from PLearn::PLearner.

Definition at line 75 of file RegressorFromDistribution.cc.

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

This does the actual building.

Reimplemented from PLearn::PLearner.

Definition at line 84 of file RegressorFromDistribution.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file RegressorFromDistribution.cc.

void PLearn::RegressorFromDistribution::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 142 of file RegressorFromDistribution.cc.

References PLearn::powdistance(), and PLearn::TVec< T >::resize().

{
    costs.resize(1);
    costs[0] = powdistance(target, output);
}

Here is the call graph for this function:

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

Computes the output from the input.

Reimplemented from PLearn::PLearner.

Definition at line 132 of file RegressorFromDistribution.cc.

References PLASSERT.

{
    PLASSERT( distribution );
    distribution->setPredictor(input);
    distribution->expectation(output);
}
void PLearn::RegressorFromDistribution::declareOptions ( OptionList ol) [static, protected]

Declares the class options.

Reimplemented from PLearn::PLearner.

Definition at line 61 of file RegressorFromDistribution.cc.

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

{
    declareOption(ol, "distribution", &RegressorFromDistribution::distribution,
                                      OptionBase::buildoption,
        "The underlying (conditional) distribution. Its predictor and\n"
        "predicted sizes will be set automatically.");

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

Here is the call graph for this function:

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

Reimplemented from PLearn::PLearner.

Definition at line 138 of file RegressorFromDistribution.h.

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

Reimplemented from PLearn::PLearner.

Definition at line 53 of file RegressorFromDistribution.cc.

void PLearn::RegressorFromDistribution::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 111 of file RegressorFromDistribution.cc.

OptionList & PLearn::RegressorFromDistribution::getOptionList ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 53 of file RegressorFromDistribution.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file RegressorFromDistribution.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file RegressorFromDistribution.cc.

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

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

Implements PLearn::PLearner.

Definition at line 153 of file RegressorFromDistribution.cc.

References PLearn::TVec< T >::append(), and PLearn::TVec< T >::isEmpty().

{
    static TVec<string> test_costs;
    if (test_costs.isEmpty())
        test_costs.append("mse");
    return test_costs;
}

Here is the call graph for this function:

TVec< string > PLearn::RegressorFromDistribution::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 164 of file RegressorFromDistribution.cc.

{
    static TVec<string> no_train_cost;
    return no_train_cost;
}
void PLearn::RegressorFromDistribution::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::PLearner.

Definition at line 91 of file RegressorFromDistribution.cc.

References PLearn::deepCopyField().

Here is the call graph for this function:

int PLearn::RegressorFromDistribution::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 100 of file RegressorFromDistribution.cc.

{
    if (!distribution)
        return -1;
    else
        return distribution->getNPredicted();
}
void PLearn::RegressorFromDistribution::setTrainingSet ( VMat  training_set,
bool  call_forget = true 
) [virtual]

Overridden to forward to the underlying distribution.

Reimplemented from PLearn::PLearner.

Definition at line 173 of file RegressorFromDistribution.cc.

References PLASSERT.

{
    inherited::setTrainingSet(training_set, call_forget);
    PLASSERT( training_set->inputsize()  >= 0 &&
            training_set->targetsize() >= 1    );
    // Create a dataset whose input part is the concatenation of the input and
    // target parts of the training set.
    VMat all_input_trainset = new ForwardVMatrix(training_set);
    all_input_trainset->build();
    all_input_trainset->defineSizes(training_set->inputsize() +
            training_set->targetsize(), 0, training_set->weightsize(),
            training_set->extrasize());
    PLASSERT( distribution );
    // Note that 'call_forget' is set to false in the following call, because
    // if it was true, then distribution->forget() would have already been
    // called in this->forget().
    distribution->setTrainingSet(all_input_trainset, false);
    // Set sizes for the underlying distribution.
    distribution->setPredictorPredictedSizes(training_set->inputsize(),
                                             training_set->targetsize());
}
void PLearn::RegressorFromDistribution::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 121 of file RegressorFromDistribution.cc.

References PLERROR.

{
    if (!distribution)
        PLERROR("In RegressorFromDistribution::train - You need to specify a "
                "distribution before calling the train() method");
    distribution->train();
}

Member Data Documentation

Reimplemented from PLearn::PLearner.

Definition at line 138 of file RegressorFromDistribution.h.

Definition at line 65 of file RegressorFromDistribution.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