mlpy.knowledgerep.cbr.similarity.CosineSimilarity¶
-
class
mlpy.knowledgerep.cbr.similarity.
CosineSimilarity
(**kwargs)[source]¶ Bases:
mlpy.knowledgerep.cbr.similarity.ISimilarity
The cosine similarity model.
Cosine similarity is a measure of similarity between two vectors of an inner product space that measures the cosine of the angle between them. The cosine of 0 degree is 1, and it is less than 1 for any other angle. It is thus a judgement of orientation and not magnitude: tow vectors with the same orientation have a cosine similarity of 1, two vectors at 90 degrees have a similarity of 0, and two vectors diametrically opposed have a similarity of -1, independent of their magnitude [R1].
The cosine model employs the cosine_similarity function from the
sklearn.metrics.pairwise
module to determine similarity.References
[R1] (1, 2) Wikipidia::cosine_similarity Methods
build_indexing_structure
(data, id_map)Build the indexing structure. compute_similarity
(data_point)Computes the similarity.