Spectre.Classifier.Math (Spectre v0.3.0)

Copy Markdown View Source

Small vector math helpers used by classifier and embedding strategies.

These functions stay pure and dependency-free so classifier scoring can be tested without loading embedding models or Vettore indexes.

Summary

Functions

Returns a normalized centroid for vectors.

Returns cosine similarity in [-1.0, 1.0].

Normalizes a vector to unit length.

Returns Vettore's raw cosine score.

Functions

centroid(vectors)

@spec centroid([[number()]]) :: [float()]

Returns a normalized centroid for vectors.

cosine(left, right)

@spec cosine([number()], [number()]) :: float()

Returns cosine similarity in [-1.0, 1.0].

normalize(vector)

@spec normalize([number()]) :: [float()]

Normalizes a vector to unit length.

raw_cosine_score(score)

@spec raw_cosine_score(term()) :: float()

Returns Vettore's raw cosine score.