PLearn 0.1
|
The first sentence should be a BRIEF DESCRIPTION of what the class does. More...
#include <StabilisationLearner.h>
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 OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual StabilisationLearner * | deepCopy (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 PPath & | declaringFile () |
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. |
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
Definition at line 57 of file StabilisationLearner.h.
typedef PLearner PLearn::StabilisationLearner::inherited [private] |
Reimplemented from PLearn::PLearner.
Definition at line 59 of file StabilisationLearner.h.
PLearn::StabilisationLearner::StabilisationLearner | ( | ) |
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.
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_().
{ inherited::build(); build_(); }
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().
{ }
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.
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; }
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); }
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().
{ inherited::forget(); }
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; }
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().
{ inherited::makeDeepCopyFromShallowCopy(copies); }
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.
{ }
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().