PLearn 0.1
|
#include <LiftBinaryCostFunction.h>
Public Member Functions | |
LiftBinaryCostFunction (bool make_pos_output=false) | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual LiftBinaryCostFunction * | deepCopy (CopiesMap &copies) const |
virtual string | info () const |
Returns a bit more informative string about object (default returns classname()) | |
virtual real | evaluate (const Vec &output, const Vec &target) const |
** Subclasses must override this method ** | |
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 () |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declare options (data fields) for the class. | |
Protected Attributes | |
bool | make_positive_output |
Private Types | |
typedef Kernel | inherited |
This class allows us to compute the lift (used by Bell Canada) of a binary classification problem. Since we need the output AND the target to be represented by a single cost (the method evaluate returns only a real), we will use a trick. cost = output[class#1], if target = 1 = -output[class#1], if target = 0 or, if the make_positive_output flag is true: cost = sigmoid(output[class#1]), if target = 1 = -sigmoid(output[class#1]), if target = 0
Definition at line 63 of file LiftBinaryCostFunction.h.
typedef Kernel PLearn::LiftBinaryCostFunction::inherited [private] |
Reimplemented from PLearn::Kernel.
Definition at line 65 of file LiftBinaryCostFunction.h.
PLearn::LiftBinaryCostFunction::LiftBinaryCostFunction | ( | bool | make_pos_output = false | ) | [inline] |
Definition at line 71 of file LiftBinaryCostFunction.h.
: make_positive_output(make_pos_output) {}
string PLearn::LiftBinaryCostFunction::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::Kernel.
Definition at line 49 of file LiftBinaryCostFunction.cc.
OptionList & PLearn::LiftBinaryCostFunction::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::Kernel.
Definition at line 49 of file LiftBinaryCostFunction.cc.
RemoteMethodMap & PLearn::LiftBinaryCostFunction::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::Kernel.
Definition at line 49 of file LiftBinaryCostFunction.cc.
Reimplemented from PLearn::Kernel.
Definition at line 49 of file LiftBinaryCostFunction.cc.
Object * PLearn::LiftBinaryCostFunction::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 49 of file LiftBinaryCostFunction.cc.
StaticInitializer LiftBinaryCostFunction::_static_initializer_ & PLearn::LiftBinaryCostFunction::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::Kernel.
Definition at line 49 of file LiftBinaryCostFunction.cc.
string PLearn::LiftBinaryCostFunction::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 49 of file LiftBinaryCostFunction.cc.
void PLearn::LiftBinaryCostFunction::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declare options (data fields) for the class.
Redefine this in subclasses: call declareOption
(...) for each option, and then call inherited::declareOptions(options)
. Please call the inherited
method AT THE END to get the options listed in a consistent order (from most recently defined to least recently defined).
static void MyDerivedClass::declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "The size of the input; it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "The learned model weights"); inherited::declareOptions(ol); }
ol | List of options that is progressively being constructed for the current class. |
Reimplemented from PLearn::Kernel.
Definition at line 76 of file LiftBinaryCostFunction.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), and make_positive_output.
{ declareOption(ol, "make_positive_output", &LiftBinaryCostFunction::make_positive_output, OptionBase::buildoption, "TODO: Some comments"); inherited::declareOptions(ol); }
static const PPath& PLearn::LiftBinaryCostFunction::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::Kernel.
Definition at line 74 of file LiftBinaryCostFunction.h.
{ return "lift_binary_function"; }
LiftBinaryCostFunction * PLearn::LiftBinaryCostFunction::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::Kernel.
Definition at line 49 of file LiftBinaryCostFunction.cc.
** Subclasses must override this method **
returns K(x1,x2)
Implements PLearn::Kernel.
Definition at line 51 of file LiftBinaryCostFunction.cc.
References PLearn::TVec< T >::length(), PLERROR, and PLearn::sigmoid().
{ int len = output.length(); if ((target.length()!=1 && target.length()!=2) || len>2) PLERROR("For binary problems, the output and binary vectors must have length 1 or 2 (%d)", len); if (len == 1) { real out0 = output[0]; if (make_positive_output) out0 = sigmoid(out0); return (target[0]>0.5) ? out0 : -out0; } else { real out1 = output[1]; if (make_positive_output) out1 = sigmoid(out1); if (target.length()==2) return (target[1]>target[0]) ? out1 : -out1; else return (target[0]>0.5) ? out1 : -out1; } return 0.0; // to make the compiler happy... }
OptionList & PLearn::LiftBinaryCostFunction::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 49 of file LiftBinaryCostFunction.cc.
OptionMap & PLearn::LiftBinaryCostFunction::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 49 of file LiftBinaryCostFunction.cc.
RemoteMethodMap & PLearn::LiftBinaryCostFunction::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 49 of file LiftBinaryCostFunction.cc.
virtual string PLearn::LiftBinaryCostFunction::info | ( | ) | const [inline, virtual] |
Returns a bit more informative string about object (default returns classname())
Reimplemented from PLearn::Object.
Definition at line 76 of file LiftBinaryCostFunction.h.
{ return "lift_binary_function"; }
Reimplemented from PLearn::Kernel.
Definition at line 74 of file LiftBinaryCostFunction.h.
Definition at line 68 of file LiftBinaryCostFunction.h.
Referenced by declareOptions().