swarmauri.core.distances.IDistanceSimilarity module

class swarmauri.core.distances.IDistanceSimilarity.IDistanceSimilarity[source]

Bases: ABC

Interface for computing distances and similarities between high-dimensional data vectors. This interface abstracts the method for calculating the distance and similarity, allowing for the implementation of various distance metrics such as Euclidean, Manhattan, Cosine similarity, etc.

abstract distance(vector_a, vector_b)[source]

Computes the distance between two vectors.

Parameters:
  • vector_a (IVector) – The first vector in the comparison.

  • vector_b (IVector) – The second vector in the comparison.

Returns:

The computed distance between vector_a and vector_b.

Return type:

float

abstract distances(vector_a, vectors_b)[source]
Return type:

float

abstract similarities(vector_a, vectors_b)[source]
Return type:

float

abstract similarity(vector_a, vector_b)[source]

Compute the similarity between two vectors. The definition of similarity (e.g., cosine similarity) should be implemented in concrete classes.

Parameters:
  • vector_a (IVector) – The first vector.

  • vector_b (IVector) – The second vector to compare with the first vector.

Returns:

A similarity score between vector_a and vector_b.

Return type:

float