Numeric kernels

class kernelmethods.numeric_kernels.Chi2Kernel(gamma=1.0, skip_input_checks=False)[source]

Bases: kernelmethods.base.BaseKernelFunction

Chi-squared kernel function

This kernel is implemented as:

k(x, y) = exp(-gamma Sum [(x - y)^2 / (x + y)])

x and y must have non-negative values (>=0).

As a division is involved, when x+y is 0 or when x+y and x-y are both 0 for a particular dimension, the division results in a NaN, which is currently being ignored, by summing only non-NaN values. If your feature sets have many zeros, you may want investigate the effect of this kernel on your dataset carefully to ensure you understand this kernel meets your needs and expectations.

Parameters
  • gamma (float) – scale factor

  • skip_input_checks (bool) – Flag to skip input validation to save time. Skipping validation is strongly discouraged for normal use, unless you know exactly what you are doing (expert users).

class kernelmethods.numeric_kernels.GaussianKernel(sigma=2.0, skip_input_checks=False)[source]

Bases: kernelmethods.base.BaseKernelFunction

Gaussian kernel function

Parameters
  • sigma (float) – bandwidth

  • skip_input_checks (bool) – Flag to skip input validation to save time. Skipping validation is strongly discouraged for normal use, unless you know exactly what you are doing (expert users).

class kernelmethods.numeric_kernels.LaplacianKernel(gamma=1.0, skip_input_checks=False)[source]

Bases: kernelmethods.base.BaseKernelFunction

Laplacian kernel function

Parameters
  • gamma (float) – scale factor

  • skip_input_checks (bool) – Flag to skip input validation to save time. Skipping validation is strongly discouraged for normal use, unless you know exactly what you are doing (expert users).

class kernelmethods.numeric_kernels.LinearKernel(skip_input_checks=False)[source]

Bases: kernelmethods.base.BaseKernelFunction

Linear kernel function

Parameters

skip_input_checks (bool) – Flag to skip input validation to save time. Skipping validation is strongly discouraged for normal use, unless you know exactly what you are doing (expert users).

class kernelmethods.numeric_kernels.PolyKernel(degree=3, gamma=1.0, b=1.0, skip_input_checks=False)[source]

Bases: kernelmethods.base.BaseKernelFunction

Polynomial kernel function

Formula::

K(x, y) = ( b + gamma*<x, y> )^degree

Parameters
  • degree (int) – degree to raise the inner product

  • gamma (float) – scaling factor

  • b (float) – intercept

  • skip_input_checks (bool) – Flag to skip input validation to save time. Skipping validation is strongly discouraged for normal use, unless you know exactly what you are doing (expert users).

class kernelmethods.numeric_kernels.SigmoidKernel(gamma=1.0, offset=1.0, skip_input_checks=False)[source]

Bases: kernelmethods.base.BaseKernelFunction

Sigmoid kernel function (also known as hyperbolic tangent kernel)

NOTE: This kernel is not always PSD, and normalizing its kernel matrix can result in numerical issues or errors.

Parameters
  • gamma (float) – scale factor

  • offset (float) – value of offset/bias

  • skip_input_checks (bool) – Flag to skip input validation to save time. Skipping validation is strongly discouraged for normal use, unless you know exactly what you are doing (expert users).