A kernel is a positive definite function k(x,y), which can be understood as a generalized scalar product. Kernel methods. like support vector machines or gaussian processes rely on the kernels.
Classes | |
class | shark::AbstractKernelFunction< InputTypeT > |
Base class of all Kernel functions. More... | |
class | shark::AbstractMetric< InputTypeT > |
Base-class for metrics. More... | |
class | shark::ARDKernelUnconstrained< InputType > |
Automatic relevance detection kernel for unconstrained parameter optimization. More... | |
class | shark::DiscreteKernel |
Kernel on a finite, discrete space. More... | |
class | shark::GaussianRbfKernel< InputType > |
Gaussian radial basis function kernel. More... | |
class | shark::LinearKernel< InputType > |
Linear Kernel, parameter free. More... | |
class | shark::MklKernel< InputType > |
Weighted sum of kernel functions. More... | |
class | shark::ModelKernel< InputType > |
Kernel function that uses a Model as transformation function for another kernel. More... | |
class | shark::MonomialKernel< InputType > |
Monomial kernel. Calculates \( \left\langle x_1, x_2 \right\rangle^m_exponent \). More... | |
struct | shark::MultiTaskSample< InputTypeT > |
Aggregation of input data and task index. More... | |
class | shark::GaussianTaskKernel< InputTypeT > |
Special "Gaussian-like" kernel function on tasks. More... | |
class | shark::NormalizedKernel< InputType > |
Normalized version of a kernel function. More... | |
class | shark::PointSetKernel< InputType > |
Normalized version of a kernel function. More... | |
class | shark::PolynomialKernel< InputType > |
Polynomial kernel. More... | |
class | shark::ProductKernel< InputType > |
Product of kernel functions. More... | |
class | shark::ScaledKernel< InputType > |
Scaled version of a kernel function. More... | |
class | shark::WeightedSumKernel< InputType > |
Weighted sum of kernel functions. More... | |
Modules | |
Kernel Optimization | |
All kinds of objective functions to optimize kernel functions. | |
Functions | |
template<typename InputType , typename InputTypeT1 , typename InputTypeT2 > | |
double | shark::evalSkipMissingFeatures (const AbstractKernelFunction< InputType > &kernelFunction, const InputTypeT1 &inputA, const InputTypeT2 &inputB) |
template<typename InputType , typename InputTypeT1 , typename InputTypeT2 , typename InputTypeT3 > | |
double | shark::evalSkipMissingFeatures (const AbstractKernelFunction< InputType > &kernelFunction, const InputTypeT1 &inputA, const InputTypeT2 &inputB, InputTypeT3 const &missingness) |
template<class InputType , class M , class Device > | |
void | shark::calculateRegularizedKernelMatrix (AbstractKernelFunction< InputType >const &kernel, Data< InputType > const &dataset, blas::matrix_expression< M, Device > &matrix, double regularizer=0) |
Calculates the regularized kernel gram matrix of the points stored inside a dataset. | |
template<class InputType , class M , class Device > | |
void | shark::calculateMixedKernelMatrix (AbstractKernelFunction< InputType >const &kernel, Data< InputType > const &dataset1, Data< InputType > const &dataset2, blas::matrix_expression< M, Device > &matrix) |
Calculates the kernel gram matrix between two data sets. | |
template<class InputType > | |
RealMatrix | shark::calculateRegularizedKernelMatrix (AbstractKernelFunction< InputType >const &kernel, Data< InputType > const &dataset, double regularizer=0) |
Calculates the regularized kernel gram matrix of the points stored inside a dataset. | |
template<class InputType > | |
RealMatrix | shark::calculateMixedKernelMatrix (AbstractKernelFunction< InputType >const &kernel, Data< InputType > const &dataset1, Data< InputType > const &dataset2) |
Calculates the kernel gram matrix between two data sets. | |
template<class InputType , class WeightMatrix > | |
RealVector | shark::calculateKernelMatrixParameterDerivative (AbstractKernelFunction< InputType > const &kernel, Data< InputType > const &dataset, WeightMatrix const &weights) |
Efficiently calculates the weighted derivative of a Kernel Gram Matrix w.r.t the Kernel Parameters. | |
RealVector shark::calculateKernelMatrixParameterDerivative | ( | AbstractKernelFunction< InputType > const & | kernel, |
Data< InputType > const & | dataset, | ||
WeightMatrix const & | weights | ||
) |
Efficiently calculates the weighted derivative of a Kernel Gram Matrix w.r.t the Kernel Parameters.
The formula is \( \sum_i \sum_j w_{ij} k(x_i,x_j)\) where w_ij are the weights of the gradient and x_i x_j are the datapoints defining the gram matrix and k is the kernel. For efficiency it is assumd that w_ij = w_ji. This method is only useful when the whole Kernel Gram Matrix neds to be computed to get the weights w_ij and only computing smaller blocks is not sufficient.
kernel | the kernel for which to calculate the kernel gram matrix |
dataset | the set of points used in the gram matrix |
weights | the weights of the derivative, they must be symmetric! |
Definition at line 186 of file KernelHelpers.h.
References shark::Data< Type >::batch(), shark::batchSize(), shark::AbstractKernelFunction< InputTypeT >::createState(), shark::AbstractKernelFunction< InputTypeT >::eval(), shark::Data< Type >::numberOfBatches(), shark::IParameterizable< VectorType >::numberOfParameters(), and shark::AbstractKernelFunction< InputTypeT >::weightedParameterDerivative().
Referenced by shark::NegativeGaussianProcessEvidence< InputType, OutputType, LabelType >::evalDerivative(), and shark::RadiusMarginQuotient< InputType, CacheType >::evalDerivative().
RealMatrix shark::calculateMixedKernelMatrix | ( | AbstractKernelFunction< InputType >const & | kernel, |
Data< InputType > const & | dataset1, | ||
Data< InputType > const & | dataset2 | ||
) |
Calculates the kernel gram matrix between two data sets.
kernel | the kernel for which to calculate the kernel gram matrix |
dataset1 | the set of points corresponding to rows of the Gram matrix |
dataset2 | the set of points corresponding to columns of the Gram matrix |
Definition at line 163 of file KernelHelpers.h.
References shark::calculateMixedKernelMatrix().
void shark::calculateMixedKernelMatrix | ( | AbstractKernelFunction< InputType >const & | kernel, |
Data< InputType > const & | dataset1, | ||
Data< InputType > const & | dataset2, | ||
blas::matrix_expression< M, Device > & | matrix | ||
) |
Calculates the kernel gram matrix between two data sets.
kernel | the kernel for which to calculate the kernel gram matrix |
dataset1 | the set of points corresponding to rows of the Gram matrix |
dataset2 | the set of points corresponding to columns of the Gram matrix |
matrix | the target kernel matrix |
Definition at line 97 of file KernelHelpers.h.
References shark::Data< Type >::batch(), shark::batchSize(), shark::Data< Type >::numberOfBatches(), shark::Data< Type >::numberOfElements(), SHARK_PARALLEL_FOR, and SIZE_CHECK.
Referenced by shark::calculateMixedKernelMatrix().
void shark::calculateRegularizedKernelMatrix | ( | AbstractKernelFunction< InputType >const & | kernel, |
Data< InputType > const & | dataset, | ||
blas::matrix_expression< M, Device > & | matrix, | ||
double | regularizer = 0 |
||
) |
Calculates the regularized kernel gram matrix of the points stored inside a dataset.
Regularization is applied by adding the regularizer on the diagonal
kernel | the kernel for which to calculate the kernel gram matrix |
dataset | the set of points used in the gram matrix |
matrix | the target kernel matrix |
regularizer | the regularizer of the matrix which is always >= 0. default is 0. |
Definition at line 53 of file KernelHelpers.h.
References shark::Data< Type >::batch(), shark::batchSize(), shark::Data< Type >::numberOfBatches(), shark::Data< Type >::numberOfElements(), SHARK_PARALLEL_FOR, SHARK_RUNTIME_CHECK, and SIZE_CHECK.
Referenced by shark::calculateRegularizedKernelMatrix(), shark::NegativeGaussianProcessEvidence< InputType, OutputType, LabelType >::eval(), shark::NegativeGaussianProcessEvidence< InputType, OutputType, LabelType >::evalDerivative(), shark::kMeans(), shark::KernelMatrix< InputType, CacheType >::matrix(), and shark::RegularizationNetworkTrainer< InputType >::train().
RealMatrix shark::calculateRegularizedKernelMatrix | ( | AbstractKernelFunction< InputType >const & | kernel, |
Data< InputType > const & | dataset, | ||
double | regularizer = 0 |
||
) |
Calculates the regularized kernel gram matrix of the points stored inside a dataset.
Regularization is applied by adding the regularizer on the diagonal
kernel | the kernel for which to calculate the kernel gram matrix |
dataset | the set of points used in the gram matrix |
regularizer | the regularizer of the matrix which is always >= 0. default is 0. |
Definition at line 144 of file KernelHelpers.h.
References shark::calculateRegularizedKernelMatrix(), and SHARK_RUNTIME_CHECK.
double shark::evalSkipMissingFeatures | ( | const AbstractKernelFunction< InputType > & | kernelFunction, |
const InputTypeT1 & | inputA, | ||
const InputTypeT2 & | inputB | ||
) |
Does a kernel function evaluation with Missing features in the inputs
kernelFunction | The kernel function used to do evaluation |
inputA | a input |
inputB | another input |
The kernel k(x,y) is evaluated taking missing features into account. For this it is checked whether a feature of x or y is nan and in this case the corresponding features in inputA and inputB won't be considered.
Definition at line 59 of file EvalSkipMissingFeatures.h.
References shark::AbstractKernelFunction< InputTypeT >::eval(), SHARK_RUNTIME_CHECK, SIZE_CHECK, and shark::AbstractKernelFunction< InputTypeT >::supportsVariableInputSize().
Referenced by shark::MissingFeaturesKernelExpansion< InputType >::computeNorm(), shark::MissingFeaturesKernelExpansion< InputType >::computeNorm(), shark::ExampleModifiedKernelMatrix< InputType, CacheType >::entry(), and shark::MissingFeaturesKernelExpansion< InputType >::eval().
double shark::evalSkipMissingFeatures | ( | const AbstractKernelFunction< InputType > & | kernelFunction, |
const InputTypeT1 & | inputA, | ||
const InputTypeT2 & | inputB, | ||
InputTypeT3 const & | missingness | ||
) |
Do kernel function evaluation while Missing features in the inputs
kernelFunction | The kernel function used to do evaluation |
inputA | a input |
inputB | another input |
missingness | used to decide which features in the inputs to take into consideration for the purpose of evaluation. If a feature is NaN, then the corresponding features in inputA and inputB won't be considered. |
Definition at line 106 of file EvalSkipMissingFeatures.h.
References shark::AbstractKernelFunction< InputTypeT >::eval(), SHARK_RUNTIME_CHECK, SIZE_CHECK, and shark::AbstractKernelFunction< InputTypeT >::supportsVariableInputSize().