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

The first sentence should be a BRIEF DESCRIPTION of what the class does. More...

#include <BinaryKernelDiscrimination.h>

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

List of all members.

Public Member Functions

 BinaryKernelDiscrimination ()
 Default constructor.
virtual real evaluate (const Vec &x1, const Vec &x2) const
 Compute K(x1,x2).
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual
BinaryKernelDiscrimination
deepCopy (CopiesMap &copies) const
virtual void build ()
 Post-constructor.
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 PPathdeclaringFile ()

Public Attributes

float K
 ### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!
float lambda
bool ExpOutput

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declares the class options.

Private Types

typedef Kernel inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

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

Todo:
Write class to-do's here if there are any.
Deprecated:
Write deprecated stuff here if there is any. Indicate what else should be used instead.

Definition at line 61 of file BinaryKernelDiscrimination.h.


Member Typedef Documentation

Reimplemented from PLearn::Kernel.

Definition at line 63 of file BinaryKernelDiscrimination.h.


Constructor & Destructor Documentation

PLearn::BinaryKernelDiscrimination::BinaryKernelDiscrimination ( )

Default constructor.

Definition at line 58 of file BinaryKernelDiscrimination.cc.

                                                       :
/* ### Initialize all fields to their default value here */
    K(1),
    ExpOutput(false)
{
    // ...

    // ### You may (or not) want to call build_() to finish building the object
    // ### (doing so assumes the parent classes' build_() have been called too
    // ### in the parent classes' constructors, something that you must ensure)
}

Member Function Documentation

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

Reimplemented from PLearn::Kernel.

Definition at line 53 of file BinaryKernelDiscrimination.cc.

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

Reimplemented from PLearn::Kernel.

Definition at line 53 of file BinaryKernelDiscrimination.cc.

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

Reimplemented from PLearn::Kernel.

Definition at line 53 of file BinaryKernelDiscrimination.cc.

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

Reimplemented from PLearn::Kernel.

Definition at line 53 of file BinaryKernelDiscrimination.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file BinaryKernelDiscrimination.cc.

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

Reimplemented from PLearn::Kernel.

Definition at line 53 of file BinaryKernelDiscrimination.cc.

void PLearn::BinaryKernelDiscrimination::build ( ) [virtual]

Post-constructor.

The normal implementation should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.

Reimplemented from PLearn::Kernel.

Definition at line 96 of file BinaryKernelDiscrimination.cc.

References PLearn::Kernel::build(), and build_().

{
    // ### Nothing to add here, simply calls build_
    inherited::build();
    build_();
}

Here is the call graph for this function:

void PLearn::BinaryKernelDiscrimination::build_ ( ) [private]

This does the actual building.

Reimplemented from PLearn::Kernel.

Definition at line 106 of file BinaryKernelDiscrimination.cc.

Referenced by build().

{
    // ### This method should do the real building of the object,
    // ### according to set 'options', in *any* situation. 
    // ### Typical situations include:
    // ###  - Initial building of an object from a few user-specified options
    // ###  - Building of a "reloaded" object: i.e. from the complete set of all serialised options.
    // ###  - Updating or "re-building" of an object after a few "tuning" options have been modified.
    // ### You should assume that the parent class' build_() has already been called.
}

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 53 of file BinaryKernelDiscrimination.cc.

void PLearn::BinaryKernelDiscrimination::declareOptions ( OptionList ol) [static, protected]

Declares the class options.

Reimplemented from PLearn::Kernel.

Definition at line 73 of file BinaryKernelDiscrimination.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::Kernel::declareOptions(), ExpOutput, K, and lambda.

{
    // ### Declare all of this object's options here
    // ### For the "flags" of each option, you should typically specify  
    // ### one of OptionBase::buildoption, OptionBase::learntoption or 
    // ### OptionBase::tuningoption. Another possible flag to be combined with
    // ### is OptionBase::nosave

    // ### ex:
    declareOption(ol, "lambda", &BinaryKernelDiscrimination::lambda, OptionBase::buildoption,
                  "The base of the kernel");
    declareOption(ol, "K", &BinaryKernelDiscrimination::K, OptionBase::buildoption,
                  "a constant");
    declareOption(ol, "ExpOutput", &BinaryKernelDiscrimination::ExpOutput, OptionBase::buildoption,
                  "Flag to 1 if you do not want the log of the output. The exponential form will be outputted instead");

    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Kernel.

Definition at line 110 of file BinaryKernelDiscrimination.h.

:
    //#####  Protected Options  ###############################################
BinaryKernelDiscrimination * PLearn::BinaryKernelDiscrimination::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::Kernel.

Definition at line 53 of file BinaryKernelDiscrimination.cc.

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

Compute K(x1,x2).

Implements PLearn::Kernel.

Definition at line 120 of file BinaryKernelDiscrimination.cc.

References ExpOutput, i, K, lambda, PLearn::TVec< T >::length(), N, PLERROR, PLearn::pow(), and PLearn::safeflog().

                                                                            {
    // ### Evaluate the kernel on a pair of points.
    int i;

    if (x1.length() != x2.length()){PLERROR("Vector not of same length");}
    int N= x1.length();
    int dij = 0;
    
    for (i=0; i < x1.length();i++)
    {
        if (x1[i] != x2[i]){dij++;};
    }
    if (ExpOutput)
        return pow(lambda,(K-((K*dij)/N)))*pow(1-lambda,K*dij/N);
    else
        return safeflog(pow(lambda,(K-((K*dij)/N)))*pow(1-lambda,K*dij/N));
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 53 of file BinaryKernelDiscrimination.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file BinaryKernelDiscrimination.cc.

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

Reimplemented from PLearn::Object.

Definition at line 53 of file BinaryKernelDiscrimination.cc.

void PLearn::BinaryKernelDiscrimination::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::Kernel.

Definition at line 150 of file BinaryKernelDiscrimination.cc.

References PLearn::Kernel::makeDeepCopyFromShallowCopy(), and PLERROR.

{
    inherited::makeDeepCopyFromShallowCopy(copies);

    // ### Call deepCopyField on all "pointer-like" fields 
    // ### that you wish to be deepCopied rather than 
    // ### shallow-copied.
    // ### ex:
    // deepCopyField(trainvec, copies);

    // ### Remove this line when you have fully implemented this method.
    PLERROR("BinaryKernelDiscrimination::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::Kernel.

Definition at line 110 of file BinaryKernelDiscrimination.h.

Definition at line 73 of file BinaryKernelDiscrimination.h.

Referenced by declareOptions(), and evaluate().

### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!

Definition at line 71 of file BinaryKernelDiscrimination.h.

Referenced by declareOptions(), and evaluate().

Definition at line 72 of file BinaryKernelDiscrimination.h.

Referenced by declareOptions(), and evaluate().


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