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::WeightedQuadraticPolynomialKernel Class Reference

#include <WeightedQuadraticPolynomialKernel.h>

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

List of all members.

Public Member Functions

 WeightedQuadraticPolynomialKernel (real the_alph=1.0, real the_beta=1.0, bool call_build_=true)
 Convenient constructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual
WeightedQuadraticPolynomialKernel
deepCopy (CopiesMap &copies) const
virtual real evaluate (const Vec &x1, const Vec &x2) const
 ** Subclasses must override this method **
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

real alpha
 Weight on correlation features.
real beta
 Weight on second degree features.

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

Definition at line 51 of file WeightedQuadraticPolynomialKernel.h.


Member Typedef Documentation

Reimplemented from PLearn::Kernel.

Definition at line 53 of file WeightedQuadraticPolynomialKernel.h.


Constructor & Destructor Documentation

PLearn::WeightedQuadraticPolynomialKernel::WeightedQuadraticPolynomialKernel ( real  the_alph = 1.0,
real  the_beta = 1.0,
bool  call_build_ = true 
)

Convenient constructor.

Definition at line 66 of file WeightedQuadraticPolynomialKernel.cc.

References build_().

                     :
    inherited(true, call_build_),
    alpha(the_alpha),
    beta(the_beta)
{
    if (call_build_)
        build_();
}

Here is the call graph for this function:


Member Function Documentation

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

Reimplemented from PLearn::Kernel.

Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.

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

Reimplemented from PLearn::Kernel.

Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.

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

Reimplemented from PLearn::Kernel.

Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.

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

Reimplemented from PLearn::Kernel.

Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.

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

Reimplemented from PLearn::Object.

Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.

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

Reimplemented from PLearn::Kernel.

Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.

void PLearn::WeightedQuadraticPolynomialKernel::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 98 of file WeightedQuadraticPolynomialKernel.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::Kernel.

Definition at line 107 of file WeightedQuadraticPolynomialKernel.cc.

Referenced by build(), and WeightedQuadraticPolynomialKernel().

{}

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.

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

Declares the class options.

Reimplemented from PLearn::Kernel.

Definition at line 80 of file WeightedQuadraticPolynomialKernel.cc.

References alpha, beta, PLearn::OptionBase::buildoption, PLearn::declareOption(), and PLearn::Kernel::declareOptions().

{
    declareOption(ol, "alpha", &WeightedQuadraticPolynomialKernel::alpha, 
                  OptionBase::buildoption,
                  "Weight on correlation features.");

    declareOption(ol, "beta", &WeightedQuadraticPolynomialKernel::beta, 
                  OptionBase::buildoption,
                  "Weight on second degree features.");

    // Declare options inherited from parent class.
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Kernel.

Definition at line 67 of file WeightedQuadraticPolynomialKernel.h.

:

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

Reimplemented from PLearn::Kernel.

Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.

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

** Subclasses must override this method **

returns K(x1,x2)

Implements PLearn::Kernel.

Definition at line 113 of file WeightedQuadraticPolynomialKernel.cc.

References alpha, beta, PLearn::TVec< T >::data(), i, PLearn::ipow(), PLearn::TVec< T >::length(), PLERROR, and PLearn::TVec< T >::size().

{ 
#ifdef BOUNDCHECK
    if(x1.length()!=x2.length())
        PLERROR("In WeightedQuadraticPolynomialKernel::evaluate(): "
            "x1 and x2 have different lengths.");
#endif
    real res = 0;
    real corr = 0;
    if (x1.size() > 0 && x2.size() > 0) {
        real* v1 = x1.data();
        real* v2 = x2.data();
        real v1i = 0;
        real v2i = 0;
        for(int i=0; i<x1.length(); i++)
        {
            v1i = v1[i];
            v2i = v2[i];
            res += v1i*v2i;
            corr += v1i*v2i*v1i*v2i;
        }
    }
    
    //Computes K(x,y) = 0.5 * ( alpha (1 + <x,y>)^2 - alpha \n"
    //                          + 2*(1 - alpha) * \sum_i x_i y_i\n"
    //                          + (2*beta - alpha) * \sum_i x_i^2 y_i^2 )\n"
    return 0.5 * (alpha * ipow(res + real(1.0), 2) - alpha + 2*(1 - alpha)*res + 
                  (2*beta - alpha)*corr);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.

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

Reimplemented from PLearn::Object.

Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.

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

Reimplemented from PLearn::Object.

Definition at line 60 of file WeightedQuadraticPolynomialKernel.cc.

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

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::Kernel.

Definition at line 146 of file WeightedQuadraticPolynomialKernel.cc.

References PLearn::Kernel::makeDeepCopyFromShallowCopy().

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::Kernel.

Definition at line 67 of file WeightedQuadraticPolynomialKernel.h.

Weight on correlation features.

Definition at line 58 of file WeightedQuadraticPolynomialKernel.h.

Referenced by declareOptions(), and evaluate().

Weight on second degree features.

Definition at line 60 of file WeightedQuadraticPolynomialKernel.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