Dimension of item vectors.
Dimension of item vectors.
Numeric id to item key mapping.
Numeric id to item key mapping.
Item key to numeric id mapping.
Item key to numeric id mapping.
Lookup nearest neighbors of a vector.
Lookup nearest neighbors of a vector. The vector should be normalized.
Name of the nearest neighbor method.
Raw item vectors.
Raw item vectors.
Lookup nearest neighbors of an existing vector.
Immutable index for fast nearest neighbor look up.
{{ import com.spotify.scio.extra.nn._
// Tuples of (item ID, vector) to look up from val vectors: Seq[(String, DenseVector[Double])] = // ...
// Builder for a nearest neighbor index backed by a matrix val builder = NearestNeighbor.newMatrixBuilder[String, Double](40) vectors.foreach(kv => builder.addVector(kv._1, kv._2)) val nn = builder.build
// Candidate to loo up nearest neighbors from val candidate: DenseVector[Double] = // ...
// Look up top 10 most similar items nn.lookup(candidate, 10) }}