kernel_poly#

mvpy.math.kernel_poly(x: ndarray | Tensor, y: ndarray | Tensor, γ: float, coef0: float, degree: float, *args: Any) ndarray | Tensor[source]#

Compute the polynomial kernel function.

Parameters:
xUnion[np.ndarray, torch.Tensor]

Matrix x of shape (n_samples, n_features).

yUnion[np.ndarray, torch.Tensor]

Matrix y of shape (n_samples, n_features).

γfloat

Gamma parameter as float.

coef0float

Coefficient parameter as float.

degreefloat

Degree of the polynomial as float.

Returns:
kUnion[np.ndarray, torch.Tensor]

Kernel matrix of shape (n_samples, n_samples).

Notes

The polynomial kernel is computed as:

\[\kappa(x, y) = (c_0 + \gamma x y^T)^d\]

Note that, unlike other math functions, this is specifically for 2D inputs and outputs.