PLearn 0.1
|
#include <ClassDistanceProportionCostFunction.h>
Public Member Functions | |
ClassDistanceProportionCostFunction () | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () 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 PPath & | declaringFile () |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Private Types | |
typedef Kernel | inherited |
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.
typedef Kernel PLearn::ClassDistanceProportionCostFunction::inherited [private] |
Reimplemented from PLearn::Kernel.
Definition at line 66 of file ClassDistanceProportionCostFunction.h.
PLearn::ClassDistanceProportionCostFunction::ClassDistanceProportionCostFunction | ( | ) | [inline] |
Definition at line 69 of file ClassDistanceProportionCostFunction.h.
{}
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.
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); }
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.
Reimplemented from PLearn::Kernel.
Definition at line 71 of file ClassDistanceProportionCostFunction.h.