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

#include <ClassDistanceProportionCostFunction.h>

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

List of all members.

Public Member Functions

 ClassDistanceProportionCostFunction ()
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual
ClassDistanceProportionCostFunction
deepCopy (CopiesMap &copies) const
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_

Private Types

typedef Kernel inherited

Detailed Description

This is very similar to ClassMarginCostFunction when output.length()>1, except than rather than return the negated difference between the score of the right class and the highest score among all other classes, we return: WARNING: This doesn't make much sense if scores have different signs (they should either be all positive or all negative)

This is useful for multiclass problems when the scores represent negative distances to each class, It returns distance_to_right_class/(distance_to_right_class+distance_to_closest_other_classes)

Definition at line 64 of file ClassDistanceProportionCostFunction.h.


Member Typedef Documentation

Reimplemented from PLearn::Kernel.

Definition at line 66 of file ClassDistanceProportionCostFunction.h.


Constructor & Destructor Documentation

PLearn::ClassDistanceProportionCostFunction::ClassDistanceProportionCostFunction ( ) [inline]

Definition at line 69 of file ClassDistanceProportionCostFunction.h.

{}

Member Function Documentation

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

Reimplemented from PLearn::Kernel.

Definition at line 49 of file ClassDistanceProportionCostFunction.cc.

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

Reimplemented from PLearn::Kernel.

Definition at line 49 of file ClassDistanceProportionCostFunction.cc.

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

Reimplemented from PLearn::Kernel.

Definition at line 49 of file ClassDistanceProportionCostFunction.cc.

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

Reimplemented from PLearn::Kernel.

Definition at line 49 of file ClassDistanceProportionCostFunction.cc.

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

Reimplemented from PLearn::Object.

Definition at line 49 of file ClassDistanceProportionCostFunction.cc.

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

Reimplemented from PLearn::Kernel.

Definition at line 49 of file ClassDistanceProportionCostFunction.cc.

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

Reimplemented from PLearn::Object.

Definition at line 49 of file ClassDistanceProportionCostFunction.cc.

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

Reimplemented from PLearn::Kernel.

Definition at line 71 of file ClassDistanceProportionCostFunction.h.

{ 
ClassDistanceProportionCostFunction * PLearn::ClassDistanceProportionCostFunction::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::Kernel.

Definition at line 49 of file ClassDistanceProportionCostFunction.cc.

real PLearn::ClassDistanceProportionCostFunction::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 ClassDistanceProportionCostFunction.cc.

References PLearn::argmax(), PLearn::TVec< T >::length(), PLearn::max(), and PLERROR.

{
    if (output.length()==1)
        PLERROR("In ClassDistanceProportionCostFunction::evaluate, output should be multiclass and contain negative distances to each class");

    int trueclass;
    if (target.length()==1)
        trueclass = int(target[0]);
    else
        trueclass = argmax(target);
    
    real trueclass_score = output[trueclass];
    output[trueclass] = -FLT_MAX;
    real otherclass_score = max(output);
    output[trueclass] = trueclass_score;
    return trueclass_score/(trueclass_score+otherclass_score);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 49 of file ClassDistanceProportionCostFunction.cc.

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

Reimplemented from PLearn::Object.

Definition at line 49 of file ClassDistanceProportionCostFunction.cc.

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

Reimplemented from PLearn::Object.

Definition at line 49 of file ClassDistanceProportionCostFunction.cc.


Member Data Documentation

Reimplemented from PLearn::Kernel.

Definition at line 71 of file ClassDistanceProportionCostFunction.h.


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