Dsxir. Retrieval. Cosine
(dsxir v0.4.0)
Copy Markdown
Brute-force cosine similarity over two flat float lists.
Pulled out of Dsxir.Retrieval.InMemory so the Dsxir.DemoStrategy.KNN
strategy can share the same math without copy-pasting. Returns 0.0 when
either vector is the zero vector, mirroring the original semantics.
Summary
Functions
Cosine similarity in [-1.0, 1.0]. Returns 0.0 when either input is the
zero vector. Raises Dsxir.Errors.Framework.PredictorError when vector
lengths differ.
Functions
Cosine similarity in [-1.0, 1.0]. Returns 0.0 when either input is the
zero vector. Raises Dsxir.Errors.Framework.PredictorError when vector
lengths differ.