PLearn 0.1
Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Protected Member Functions | Protected Attributes | Private Types
PLearn::LiftBinaryCostFunction Class Reference

#include <LiftBinaryCostFunction.h>

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

List of all members.

Public Member Functions

 LiftBinaryCostFunction (bool make_pos_output=false)
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual LiftBinaryCostFunctiondeepCopy (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 PPathdeclaringFile ()

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

Detailed Description

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.


Member Typedef Documentation

Reimplemented from PLearn::Kernel.

Definition at line 65 of file LiftBinaryCostFunction.h.


Constructor & Destructor Documentation

PLearn::LiftBinaryCostFunction::LiftBinaryCostFunction ( bool  make_pos_output = false) [inline]

Definition at line 71 of file LiftBinaryCostFunction.h.

        : make_positive_output(make_pos_output) {}

Member Function Documentation

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.

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

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);
  }
Parameters:
olList 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.

Here is the call graph for this function:

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.

real PLearn::LiftBinaryCostFunction::evaluate ( const Vec x1,
const Vec x2 
) const [virtual]

** 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...
}

Here is the call graph for this function:

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())

Returns:
Information about the object

Reimplemented from PLearn::Object.

Definition at line 76 of file LiftBinaryCostFunction.h.

    { return "lift_binary_function"; }

Member Data Documentation

Reimplemented from PLearn::Kernel.

Definition at line 74 of file LiftBinaryCostFunction.h.

Definition at line 68 of file LiftBinaryCostFunction.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