Cosine similarity is a method used in building machine learning applications such as recommender systems. It is a technique to find the similarities between the two documents. In this article, I’ll give you an introduction to Cosine Similarity in Machine Learning and its implementation using Python.

## Cosine Similarity in Machine Learning

Cosine similarity is used to find similarities between the two documents. It does this by calculating the similarity score between the vectors, which is done by finding the angles between them. The range of similarities is between 0 and 1. If the value of the similarity score between two vectors is 1, it means that there is a greater similarity between the two vectors.

On the other hand, if the value of the similarity score between two vectors is 0, it means that there is no similarity between the two vectors. When the similarity score is one, the angle between two vectors is 0 and when the similarity score is 0, the angle between two vectors is 90 degrees.

In machine learning applications, this technique is mainly used in ** recommendation systems** to find the similarities between the description of two products so that we can recommend the most similar product to the user to provide a better user experience. In this section below, I will walk you through how to calculate cosine similarity using Python.

## Cosine Similarity using Python

I hope till now you must have understood that the concept behind Cosine Similarity is to calculate similarities between two documents. Now, let’s see how to implement it using Python. To implement it using Python, we can use the “cosine_similarity” method provided by scikit-Learn.

The idea is to create two arrays and then implement the “cosine_similarity” method provided in the Scikit-Learn library to find the similarities between them. Below is how to calculate Cosine Similarity using Python:

[[0.92925111]]

So, the similarity score received between the two arrays (a and b) is 0.92 (approximately), which is close to 1. So we can say that the arrays are similar to some extent.

## Summary

So we need to calculate the similarity score for finding the similarities between the two documents. In machine learning, Cosine Similarity is one of the methods to find similarities between the two documents. I hope you liked this article on the concept of finding Cosine Similarities in machine learning and its implementation using Python. Feel free to ask your valuable questions in the comments section below.