nearestNeighbours

public final List<Pair<String, Float>> nearestNeighbours(    NDArray<Float, D1> vector,     Set<String> inSet,     Set<String> outSet,     Integer N)

Find N closest terms in the vocab to the given vector, using only words from the in-set (if defined) and excluding all words from the out-set (if non-empty). Although you can, it doesn't make much sense to define both in and out sets.

Return

The N closest terms in the vocab to the given vector and their associated cosine similarity scores.

Parameters

vector

The vector.

inSet

Set of words to consider. Specify None to use all words in the vocab (default behavior).

outSet

Set of words to exclude (default to empty).

N

The maximum number of terms to return (default to 40).