Principle:Rapidsai Cuml Pairwise Kernel Computation
| Knowledge Sources | |
|---|---|
| Domains | Machine_Learning, Kernel_Methods, Linear_Algebra |
| Last Updated | 2026-02-08 12:00 GMT |
Overview
Pairwise kernel computation evaluates a kernel function between all pairs of data points to produce a kernel matrix (Gram matrix), which implicitly maps data into a high-dimensional feature space for use in kernel-based learning algorithms.
Description
Kernel methods are a class of machine learning algorithms that operate in an implicitly defined high-dimensional feature space without ever computing the feature vectors explicitly. The key computational primitive is the kernel function , which computes the inner product between the images of two data points in the feature space. The matrix of all pairwise kernel evaluations is called the Gram matrix or kernel matrix.
The following standard kernels are supported:
Linear Kernel: The simplest kernel, equivalent to the standard inner product in the input space. It is used when the data is already linearly separable or when no non-linear transformation is needed.
Polynomial Kernel: Maps data into a feature space of polynomial combinations of features up to a given degree. This captures interaction effects between features.
RBF (Radial Basis Function) Kernel: Also known as the Gaussian kernel, this is the most widely used kernel. It maps data into an infinite-dimensional feature space and produces a similarity measure that decays exponentially with the squared Euclidean distance between points. The gamma parameter controls the width of the Gaussian.
Sigmoid (Tanh) Kernel: Based on the hyperbolic tangent function, this kernel relates to neural network activation functions. It is not positive semi-definite for all parameter choices, so care must be taken with parameter selection.
Precomputed Kernel: When the kernel matrix has already been computed externally, it can be passed directly to kernel-based algorithms. This allows the use of custom or domain-specific kernels.
The kernel parameters are encapsulated in a parameter structure containing the kernel type, polynomial degree, gamma coefficient, and coef0 bias term. An internal conversion layer translates these parameters to the cuVS distance kernels library for GPU-accelerated computation.
Usage
Pairwise kernel computation is the right choice when:
- Using kernel-based algorithms such as Support Vector Machines (SVM), Kernel PCA, or Gaussian Processes.
- The relationship between features and targets is non-linear and requires an implicit mapping to a higher-dimensional space.
- RBF kernel is the default choice for general-purpose non-linear classification and regression.
- Polynomial kernel is preferred when interaction terms between features are important.
- Linear kernel is preferred for high-dimensional sparse data where non-linear kernels are computationally expensive or unnecessary.
Theoretical Basis
Linear Kernel:
Polynomial Kernel:
where is the scale factor, is the bias (coef0), and is the polynomial degree.
RBF (Gaussian) Kernel:
where controls the kernel bandwidth. A common default is .
Sigmoid (Tanh) Kernel:
Kernel Matrix (Gram Matrix):
For a valid (Mercer) kernel, is symmetric positive semi-definite.