# similarity Package¶

## cos Module¶

Created on Oct 2, 2012

class composes.similarity.cos.CosSimilarity

Computes the cosine similarity of two vectors.

$$sim(\vec{u},\vec{v}) = \frac{<\vec{u},\vec{v}>}{\sqrt{||\vec{u}||||\vec{v}||}}$$

## dot_prod Module¶

Created on Oct 2, 2012

class composes.similarity.dot_prod.DotProdSimilarity
Computes the scalar product (dot product) of two vectors.

$$sim(\vec{u},\vec{v}) = <\vec{u},\vec{v}> = \sum_iu_iv_i$$

## euclidean Module¶

Created on Oct 2, 2012

class composes.similarity.euclidean.EuclideanSimilarity

Computes the euclidean similarity of two vectors as the inverse of their euclidean distance.

$$sim(\vec{u},\vec{v}) = \frac{1}{||\vec{u}-\vec{v}|| + 1}$$

## lin Module¶

Created on Oct 2, 2012

class composes.similarity.lin.LinSimilarity

Computes the Lin similarity of two vectors.

$$sim(\vec{u},\vec{v}) = \frac{\sum_{i \in I}(u_i+v_i)}{\sum_iu_i + \sum_iv_i}$$

Where $$I=\{i | u_i > 0 \text{ and } v_i > 0\}$$, the set of components on which both vectors are strictly positive.

## similarity Module¶

Created on Oct 2, 2012