himalaya.kernel_ridge.cosine_similarity_kernel

himalaya.kernel_ridge.cosine_similarity_kernel(X, Y=None)[source]

Compute cosine similarity between samples in X and Y.

Cosine similarity, or the cosine kernel, computes similarity as the normalized dot product of X and Y:

K(X, Y) = <X, Y> / (||X||*||Y||)

On L2-normalized data, this function is equivalent to linear_kernel.

Parameters
Xarray of shape (n_samples_X, n_features)

Train or test features.

Yarray of shape (n_samples_Y, n_features)

Train features.

Returns
Karray of shape (n_samples_X, n_samples_Y)

Computed kernel.