mlpack  2.0.1
Public Member Functions | Private Attributes | List of all members
mlpack::kernel::PolynomialKernel Class Reference

The simple polynomial kernel. More...

Public Member Functions

 PolynomialKernel (const double degree=2.0, const double offset=0.0)
 Construct the Polynomial Kernel with the given offset and degree. More...
 
const double & Degree () const
 Get the degree of the polynomial. More...
 
double & Degree ()
 Modify the degree of the polynomial. More...
 
template<typename VecTypeA , typename VecTypeB >
double Evaluate (const VecTypeA &a, const VecTypeB &b) const
 Simple evaluation of the dot product. More...
 
const double & Offset () const
 Get the offset of the dot product of the arguments. More...
 
double & Offset ()
 Modify the offset of the dot product of the arguments. More...
 
template<typename Archive >
void Serialize (Archive &ar, const unsigned int)
 Serialize the kernel. More...
 

Private Attributes

double degree
 The degree of the polynomial. More...
 
double offset
 The offset of the dot product of the arguments. More...
 

Detailed Description

The simple polynomial kernel.

For any two vectors $ x $, $ y $, $ degree $ and $ offset $,

\[ K(x, y) = (x^T * y + offset) ^ {degree}. \]

Definition at line 30 of file polynomial_kernel.hpp.

Constructor & Destructor Documentation

◆ PolynomialKernel()

mlpack::kernel::PolynomialKernel::PolynomialKernel ( const double  degree = 2.0,
const double  offset = 0.0 
)
inline

Construct the Polynomial Kernel with the given offset and degree.

If the arguments are omitted, the default degree is 2 and the default offset is 0.

Parameters
offsetOffset of the dot product of the arguments.
degreeDegree of the polynomial.

Definition at line 40 of file polynomial_kernel.hpp.

Member Function Documentation

◆ Degree() [1/2]

const double& mlpack::kernel::PolynomialKernel::Degree ( ) const
inline

Get the degree of the polynomial.

Definition at line 63 of file polynomial_kernel.hpp.

References degree.

◆ Degree() [2/2]

double& mlpack::kernel::PolynomialKernel::Degree ( )
inline

Modify the degree of the polynomial.

Definition at line 65 of file polynomial_kernel.hpp.

References degree.

◆ Evaluate()

template<typename VecTypeA , typename VecTypeB >
double mlpack::kernel::PolynomialKernel::Evaluate ( const VecTypeA &  a,
const VecTypeB &  b 
) const
inline

Simple evaluation of the dot product.

This evaluation uses Armadillo's dot() function.

Template Parameters
VecTypeAType of first vector (should be arma::vec or arma::sp_vec).
VecTypeBType of second vector (arma::vec / arma::sp_vec).
Parameters
aFirst vector.
bSecond vector.
Returns
K(a, b).

Definition at line 57 of file polynomial_kernel.hpp.

References degree, and offset.

◆ Offset() [1/2]

const double& mlpack::kernel::PolynomialKernel::Offset ( ) const
inline

Get the offset of the dot product of the arguments.

Definition at line 68 of file polynomial_kernel.hpp.

References offset.

◆ Offset() [2/2]

double& mlpack::kernel::PolynomialKernel::Offset ( )
inline

Modify the offset of the dot product of the arguments.

Definition at line 70 of file polynomial_kernel.hpp.

References offset.

◆ Serialize()

template<typename Archive >
void mlpack::kernel::PolynomialKernel::Serialize ( Archive &  ar,
const unsigned  int 
)
inline

Serialize the kernel.

Definition at line 74 of file polynomial_kernel.hpp.

References mlpack::data::CreateNVP(), degree, and offset.

Member Data Documentation

◆ degree

double mlpack::kernel::PolynomialKernel::degree
private

The degree of the polynomial.

Definition at line 82 of file polynomial_kernel.hpp.

Referenced by Degree(), Evaluate(), and Serialize().

◆ offset

double mlpack::kernel::PolynomialKernel::offset
private

The offset of the dot product of the arguments.

Definition at line 84 of file polynomial_kernel.hpp.

Referenced by Evaluate(), Offset(), and Serialize().


The documentation for this class was generated from the following file: