Skip to main content

gram_matrix

Function gram_matrix 

Source
pub fn gram_matrix<S>(
    x: &ArrayBase<S, Ix2>,
    kernel: &KernelType,
) -> Result<Array2<f64>>
where S: Data, S::Elem: Float + NumCast,
Expand description

Compute the Gram matrix (kernel matrix) for a dataset

The Gram matrix K has entries K[i,j] = k(x_i, x_j).

§Arguments

  • x - Input data matrix, shape (n_samples, n_features)
  • kernel - The kernel function type

§Returns

  • Result<Array2<f64>> - The Gram matrix, shape (n_samples, n_samples)