jina.executors.evaluators.embedding.cosine

class jina.executors.evaluators.embedding.cosine.CosineEvaluator(*args, **kwargs)[source]

Bases: jina.executors.evaluators.embedding.BaseEmbeddingEvaluator

A CosineEvaluator evaluates the distance between actual and desired embeddings computing the cosine distance between them. (The smaller value the closest distance, it is not cosine similarity measure)

\[1 - \frac{u \cdot v} {||u||_2 ||v||_2}.\]
property metric

Get the name of the evaluation metric

evaluate(actual, desired, *args, **kwargs)[source]

” :type actual: array :param actual: the embedding of the document (resulting from an Encoder) :type desired: array :param desired: the expected embedding of the document :return the evaluation metric value for the request document

Return type

float