Deep learning theory - cosine similarity and Euclidean distance is calculated combat Overview

Euclidean distance is calculated based on similarity

       Euclidean distance is a common formula for calculating the distance, which represents the real distance between two points in three-dimensional space. Euclidean similarity calculation is a calculation based on the linear distance between the user, in the calculation, the different items or the user may be defined as a different coordinate points, and targeting a specific origin of coordinates, Euclidean Reed distance formula between the two points is calculated as follows:

        

Know the linear distance between the two coordinates, it calculates the Euclidean similarity also good, and d is inversely proportional to its similarity formula is as follows:

As can be seen from the formula the greater the distance between two items or the user, the degree of similarity is smaller, then the similarity degree is smaller the greater the distance.

                                                           User rating table and the correspondence table article

 
  Items 1 2 items 3 items 4 items
User 1 1 1 3 1
User 2 1 2 3 2
3 users 2 2 1 1

 

 

 

 

The following were calculated degree of similarity between the user 1 and user 2, by the Euclidean distance formula can be obtained:

 

 

As seen from the results, the D12 value is larger than the value d13, it can be concluded, User 2 User 3 more than the similarity to a user.

 

 

Cosine of the angle is calculated based on similarity

Similar to Euclidean distance, cosine similarity is also specifically target, i.e., the article or the user as a point on the coordinate, but not the origin of coordinates. Calculating an angle based on this particular target is calculated.

 

It can be seen from the figure, if the target is similar to two, then the radiation angle which is formed small. If two users do not close, the two rays forming an angle is large, the cosine similarity metric is calculated, the size of the angle can be used to reflect similarities between target. Calculated as follows:

 

Guess you like

Origin www.cnblogs.com/gary-li/p/10926318.html