metrics.pairwise.word_movers_distance

pai4sk.metrics.pairwise.word_movers_distance(W, X, Y=None, use_gpu=True, optimization_level=1, num_cpu_threads=None)

Computes word movers distance between samples in X and Y.

The details of the approximation algorithm can be found here: “http://export.arxiv.org/abs/1812.02091”.

Parameters
  • W (ndarray, shape: (n_features, n_dimensions)) – Embedding vectors

  • X (array-like, sparse-matrix, shape (n_samples_x, n_features)) – Input dataset. When MPI is used, it is preferred to have X of larger size than Y when X and Y are of unequal sizes as the MPI distribution of data is performed for X only.

  • Y (array-like, sparse-matrix, shape (n_samples_y, n_features), optional) – Input dataset. If None, the output will be the pairwise similarities between all samples in X.

  • optimization_level (integer, mimimum is 0 and maximum is 4. Using a higher value increases runtime.) –

  • num_cpu_threads (integer, maximum number of CPU threads used by each process.) –

Returns

D – Word Movers Distance

Return type

array-like, shape (n_samples_x, n_samples_y)