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

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

#include <StabilisationLearner.h>

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

List of all members.

Public Member Functions

 StabilisationLearner ()
 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 TVec< std::string > getOutputNames () const
 Returns a vector of length outputsize() containing the outputs' names.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual StabilisationLearnerdeepCopy (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

real threshold
 the threshold value. i.e. the distance needed from 0.5 to accept the change.

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 57 of file StabilisationLearner.h.


Member Typedef Documentation

Reimplemented from PLearn::PLearner.

Definition at line 59 of file StabilisationLearner.h.


Constructor & Destructor Documentation

PLearn::StabilisationLearner::StabilisationLearner ( )

Default constructor.

Definition at line 53 of file StabilisationLearner.cc.

    :threshold(0)
{
}

Member Function Documentation

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

Reimplemented from PLearn::PLearner.

Definition at line 51 of file StabilisationLearner.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 51 of file StabilisationLearner.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 51 of file StabilisationLearner.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 51 of file StabilisationLearner.cc.

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

Reimplemented from PLearn::Object.

Definition at line 51 of file StabilisationLearner.cc.

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

Reimplemented from PLearn::PLearner.

Definition at line 51 of file StabilisationLearner.cc.

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

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

Reimplemented from PLearn::PLearner.

Definition at line 72 of file StabilisationLearner.cc.

References PLearn::PLearner::build(), and build_().

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::PLearner.

Definition at line 67 of file StabilisationLearner.cc.

Referenced by build().

{
}

Here is the caller graph for this function:

string PLearn::StabilisationLearner::classname ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 51 of file StabilisationLearner.cc.

void PLearn::StabilisationLearner::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 StabilisationLearner.cc.

{
    costs[0]=target[0]!=output[0];
    real old_=int(input[3]);
    real old;
    if(old_==3) old=2;
    else old=old_;
    costs[1]=output[0]!=old;
}
void PLearn::StabilisationLearner::computeOutput ( const Vec input,
Vec output 
) const [virtual]

Computes the output from the input.

Reimplemented from PLearn::PLearner.

Definition at line 100 of file StabilisationLearner.cc.

References PLearn::endl(), PLearn::is_missing(), NORMAL_LOG, and threshold.

{
    real pred_=input[0];
    
    real l1=input[1];
    real l2=input[2];
    real old_=input[3];
    int old,pred;
    real ret;

    pred=int(pred_);
    old=int(old_);
    if(old==3)                old=2;

    if (is_missing(old_))       ret=pred;
    else if(old==pred)          ret = pred;
    else if(old==0 and pred==2) ret = 1;
    else if(old==2 and pred==0) ret = 1;
    else if(old==0 and pred==1)
        ret = (l1-threshold)>=0.5;//#(l1-0.5)>threshold
    else if(old==1 and pred==0)
        ret = (l1+threshold)>=0.5;
    else if(old==1 and pred==2)
        ret = ((l2-threshold)>=0.5)+1;
    else if(old==2 and pred==1)
        ret = ((l2+threshold)>=0.5)+1;
    else{
        ret = pred;
        NORMAL_LOG<< "We don't know what to do with old="<<old<<" and pred="<<pred<<endl;    
    }
    output[0]=ret;

}

Here is the call graph for this function:

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

Declares the class options.

Reimplemented from PLearn::PLearner.

Definition at line 58 of file StabilisationLearner.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::PLearner::declareOptions(), and threshold.

{
    declareOption(ol, "threshold", &StabilisationLearner::threshold,
                  OptionBase::buildoption,
                  "The distance needed from 0.5 to accept the change");

    inherited::declareOptions(ol);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::PLearner.

Definition at line 113 of file StabilisationLearner.h.

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

Reimplemented from PLearn::PLearner.

Definition at line 51 of file StabilisationLearner.cc.

void PLearn::StabilisationLearner::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 90 of file StabilisationLearner.cc.

References PLearn::PLearner::forget().

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 51 of file StabilisationLearner.cc.

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

Reimplemented from PLearn::Object.

Definition at line 51 of file StabilisationLearner.cc.

TVec< string > PLearn::StabilisationLearner::getOutputNames ( ) const [virtual]

Returns a vector of length outputsize() containing the outputs' names.

Default version returns ["out0", "out1", ...] Don't forget name should not have space or it will cause trouble when they are saved in the file {metadatadir}/fieldnames

Reimplemented from PLearn::PLearner.

Definition at line 159 of file StabilisationLearner.cc.

{
    TVec<string> names(1);
    names[0]="SALES_CATEG_STAB";
    return names;
}
RemoteMethodMap & PLearn::StabilisationLearner::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 51 of file StabilisationLearner.cc.

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

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

Implements PLearn::PLearner.

Definition at line 145 of file StabilisationLearner.cc.

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

{
    TVec<string> names;
    names.append("class_error");
    names.append("changed");
    return names;
}

Here is the call graph for this function:

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

{
    TVec<string> names;
    return names;
}
void PLearn::StabilisationLearner::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::PLearner.

Definition at line 79 of file StabilisationLearner.cc.

References PLearn::PLearner::makeDeepCopyFromShallowCopy().

Here is the call graph for this function:

int PLearn::StabilisationLearner::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 85 of file StabilisationLearner.cc.

{
    return 1;
}
void PLearn::StabilisationLearner::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 95 of file StabilisationLearner.cc.

{
}

Member Data Documentation

Reimplemented from PLearn::PLearner.

Definition at line 113 of file StabilisationLearner.h.

the threshold value. i.e. the distance needed from 0.5 to accept the change.

Definition at line 65 of file StabilisationLearner.h.

Referenced by computeOutput(), and declareOptions().


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