Table Of Contents

Previous topic

clfs.gpr

Next topic

clfs.knn

This content refers to the previous stable release of PyMVPA. Please visit www.pymvpa.org for the most recent version of PyMVPA and its documentation.

clfs.kernel

Module: clfs.kernel

Inheritance diagram for mvpa.clfs.kernel:

Kernels for Gaussian Process Regression and Classification.

Classes

Kernel

class mvpa.clfs.kernel.Kernel

Bases: object

Kernel function base class.

compute(data1, data2=None)
compute_gradient(alphaalphaTK)
compute_lml_gradient(alphaalphaT_Kinv, data)
compute_lml_gradient_logscale(alphaalphaT_Kinv, data)
reset()

Resets the kernel dropping internal variables to the original values

KernelConstant

class mvpa.clfs.kernel.KernelConstant(sigma_0=1.0, **kwargs)

Bases: mvpa.clfs.kernel.Kernel

The constant kernel class.

Initialize the constant kernel instance.

Parameters:sigma_0 (float) – standard deviation of the Gaussian prior probability N(0,sigma_0**2) of the intercept of the constant regression. (Defaults to 1.0)
compute(data1, data2=None)

Compute kernel matrix.

Parameters:
  • data1 (numpy.ndarray) – data
  • data2 (numpy.ndarray) – data (Defaults to None)
compute_lml_gradient(alphaalphaT_Kinv, data)
compute_lml_gradient_logscale(alphaalphaT_Kinv, data)
set_hyperparameters(hyperparameter)

KernelExponential

class mvpa.clfs.kernel.KernelExponential(length_scale=1.0, sigma_f=1.0, **kwargs)

Bases: mvpa.clfs.kernel.Kernel

The Exponential kernel class.

Note that it can handle a length scale for each dimension for Automtic Relevance Determination.

Initialize an Exponential kernel instance.

Parameters:
  • length_scale (float OR numpy.ndarray) – the characteristic length-scale (or length-scales) of the phenomenon under investigation. (Defaults to 1.0)
  • sigma_f (float) – Signal standard deviation. (Defaults to 1.0)
compute(data1, data2=None)

Compute kernel matrix.

Parameters:
  • data1 (numpy.ndarray) – data
  • data2 (numpy.ndarray) – data (Defaults to None)
compute_lml_gradient(alphaalphaT_Kinv, data)

Compute grandient of the kernel and return the portion of log marginal likelihood gradient due to the kernel. Shorter formula. Allows vector of lengthscales (ARD) BUT THIS LAST OPTION SEEMS NOT TO WORK FOR (CURRENTLY) UNKNOWN REASONS.

compute_lml_gradient_logscale(alphaalphaT_Kinv, data)

Compute grandient of the kernel and return the portion of log marginal likelihood gradient due to the kernel. Shorter formula. Allows vector of lengthscales (ARD). BUT THIS LAST OPTION SEEMS NOT TO WORK FOR (CURRENTLY) UNKNOWN REASONS.

gradient(data1, data2)

Compute gradient of the kernel matrix. A must for fast model selection with high-dimensional data.

set_hyperparameters(hyperparameter)

Set hyperaparmeters from a vector.

Used by model selection.

KernelLinear

class mvpa.clfs.kernel.KernelLinear(Sigma_p=None, sigma_0=1.0, **kwargs)

Bases: mvpa.clfs.kernel.Kernel

The linear kernel class.

Initialize the linear kernel instance.

Parameters:
  • Sigma_p (numpy.ndarray) – Covariance matrix of the Gaussian prior probability N(0,Sigma_p) on the weights of the linear regression. (Defaults to None)
  • sigma_0 (float) – the standard deviation of the Gaussian prior N(0,sigma_0**2) of the intercept of the linear regression. (Deafults to 1.0)
Sigma_p
compute(data1, data2=None)

Compute kernel matrix. Set Sigma_p to correct dimensions and default value if necessary.

Parameters:
  • data1 (numpy.ndarray) – data
  • data2 (numpy.ndarray) – data (Defaults to None)
compute_lml_gradient(alphaalphaT_Kinv, data)
compute_lml_gradient_logscale(alphaalphaT_Kinv, data)
reset()
set_hyperparameters(hyperparameter)

KernelMatern_3_2

class mvpa.clfs.kernel.KernelMatern_3_2(length_scale=1.0, sigma_f=1.0, numerator=3.0, **kwargs)

Bases: mvpa.clfs.kernel.Kernel

The Matern kernel class for the case ni=3/2 or ni=5/2.

Note that it can handle a length scale for each dimension for Automtic Relevance Determination.

Initialize a Squared Exponential kernel instance.

Parameters:
  • length_scale (float OR numpy.ndarray) – the characteristic length-scale (or length-scales) of the phenomenon under investigation. (Defaults to 1.0)
  • sigma_f (float) – Signal standard deviation. (Defaults to 1.0)
  • numerator (float) – the numerator of parameter ni of Matern covariance functions. Currently only numerator=3.0 and numerator=5.0 are implemented. (Defaults to 3.0)
compute(data1, data2=None)

Compute kernel matrix.

Parameters:
  • data1 (numpy.ndarray) – data
  • data2 (numpy.ndarray) – data (Defaults to None)
gradient(data1, data2)

Compute gradient of the kernel matrix. A must for fast model selection with high-dimensional data.

set_hyperparameters(hyperparameter)

Set hyperaparmeters from a vector.

Used by model selection. Note: ‘numerator’ is not considered as an hyperparameter.

KernelMatern_5_2

class mvpa.clfs.kernel.KernelMatern_5_2(**kwargs)

Bases: mvpa.clfs.kernel.KernelMatern_3_2

The Matern kernel class for the case ni=5/2.

This kernel is just KernelMatern_3_2(numerator=5.0).

Initialize a Squared Exponential kernel instance.

Parameters:length_scale (float OR numpy.ndarray) – the characteristic length-scale (or length-scales) of the phenomenon under investigation. (Defaults to 1.0)

KernelRationalQuadratic

class mvpa.clfs.kernel.KernelRationalQuadratic(length_scale=1.0, sigma_f=1.0, alpha=0.5, **kwargs)

Bases: mvpa.clfs.kernel.Kernel

The Rational Quadratic (RQ) kernel class.

Note that it can handle a length scale for each dimension for Automtic Relevance Determination.

Initialize a Squared Exponential kernel instance.

Parameters:
  • length_scale (float OR numpy.ndarray) – the characteristic length-scale (or length-scales) of the phenomenon under investigation. (Defaults to 1.0)
  • sigma_f (float) – Signal standard deviation. (Defaults to 1.0)
  • alpha (float) – The parameter of the RQ functions family. (Defaults to 2.0)
compute(data1, data2=None)

Compute kernel matrix.

Parameters:
  • data1 (numpy.ndarray) – data
  • data2 (numpy.ndarray) – data (Defaults to None)
gradient(data1, data2)

Compute gradient of the kernel matrix. A must for fast model selection with high-dimensional data.

set_hyperparameters(hyperparameter)

Set hyperaparmeters from a vector.

Used by model selection. Note: ‘alpha’ is not considered as an hyperparameter.

KernelSquaredExponential

class mvpa.clfs.kernel.KernelSquaredExponential(length_scale=1.0, sigma_f=1.0, **kwargs)

Bases: mvpa.clfs.kernel.Kernel

The Squared Exponential kernel class.

Note that it can handle a length scale for each dimension for Automtic Relevance Determination.

Initialize a Squared Exponential kernel instance.

Parameters:
  • length_scale (float OR numpy.ndarray) – the characteristic length-scale (or length-scales) of the phenomenon under investigation. (Defaults to 1.0)
  • sigma_f (float) – Signal standard deviation. (Defaults to 1.0)
compute(data1, data2=None)

Compute kernel matrix.

Parameters:
  • data1 (numpy.ndarray) – data
  • data2 (numpy.ndarray) – data (Defaults to None)
compute_lml_gradient(alphaalphaT_Kinv, data)

Compute grandient of the kernel and return the portion of log marginal likelihood gradient due to the kernel. Shorter formula. Allows vector of lengthscales (ARD).

compute_lml_gradient_logscale(alphaalphaT_Kinv, data)

Compute grandient of the kernel and return the portion of log marginal likelihood gradient due to the kernel. Hyperparameters are in log scale which is sometimes more stable. Shorter formula. Allows vector of lengthscales (ARD).

length_scale
reset()
set_hyperparameters(hyperparameter)

Set hyperaparmeters from a vector.

Used by model selection.