calculateSimilarity

fun calculateSimilarity(otherEmbeddings: FaceEmbedding): Float

Calculate cosine similarity between two normalized vectors as similarity = (A ⋅ B) / (||A|| * ||B||).

Return

The cosine similarity between the two normalized vectors in the multidimensional space. See the rationale explained here: https://facerec.gjung.com/ComparingFaces

  • Value of 1: The angle between the vectors is 0 degrees. This means the vectors point in the exact same direction. In the context of face embeddings, this indicates maximum similarity – the two faces are considered identical by the model.

  • Value of 0: The angle is 90 degrees. The vectors are orthogonal (perpendicular). This means they are independent or have no similarity in terms of direction. For face embeddings, this would mean the faces are very different.

  • Value of -1: The angle is 180 degrees. The vectors point in opposite directions. This indicates maximum dissimilarity.•Values between -1 and 1 represent varying degrees of similarity or dissimilarity.

In terms of faces matching values above 0.4f should be considered as a "good match" result for given faces.

Parameters

otherEmbeddings

The other normalized embeddings vector to calculate similarity with.