sklearn.metrics.pairwise.cosine_distances

sklearn.metrics.pairwise.cosine_distances(X, Y=None) [source]

Compute cosine distance between samples in X and Y.

Cosine distance is defined as 1.0 minus the cosine similarity.

Read more in the User Guide.

Parameters
X{array-like, sparse matrix} of shape (n_samples_X, n_features)

Matrix X.

Y{array-like, sparse matrix} of shape (n_samples_Y, n_features), default=None

Matrix Y.

Returns
distance matrixndarray of shape (n_samples_X, n_samples_Y)

See also

cosine_similarity
scipy.spatial.distance.cosine

Dense matrices only.

© 2007–2020 The scikit-learn developers
Licensed under the 3-clause BSD License.
https://scikit-learn.org/0.24/modules/generated/sklearn.metrics.pairwise.cosine_distances.html