The algorithm (Collaborative filtering) of the "product recommendation" system is divided into two categories. The first category is people-oriented. First find people who are similar to you, and then see what they bought that you did not buy. The most classic implementation of this type of algorithm is the "cosine formula of the angle between two vectors in a multi-dimensional space"; the second type is to directly establish the similarity relationship matrix between each product based on the object. The most classic algorithm of this type is 'Slope=1' (Slope One). Amazon invented the second type of algorithm for violent simplification, "People who bought this product also bought xxx". Let's take a look at the first category first. The biggest problem is how to judge and quantify the similarity between two people. The idea is this - Example: There are 3 songs there, "The Most Dazzling National Style", "Sunny Day", and "Hero" 》. Mr. A has collected "The Most Dazzling Ethnic Style", but when he encounters "Sunny Day", "Hero" is always skipped; Mr. B often plays "The Most Dazzling Ethnic Style" on a single loop, and "Sunny Day" will be played until the end, and " Hero" blocked Mr. C, blocked "The Most Dazzling Ethnic Style", and collected both "Sunny Day" and "Hero". We can all see that A and B have similar tastes, but C is very different from them. So the question is, if A and B are similar, how similar are they and how to quantify them? We imagine the three songs as three dimensions of a three-dimensional space. "The Most Dazzling National Style" is the x-axis, "Sunny Day" is the y-axis, and "Hero" is the z-axis. The degree of liking for each song is the Coordinates, and quantify the degree of liking (for example: single loop = 5, sharing = 4, collection = 3, active play = 2, ? finished listening = 1, ? skip = -1, blocked = -5). Then the overall taste of each person is a vector, Mr. A is (3, -1, -1), Mr. B is (5, 1, -5), and Mr. C is (-5, 3, 3). ? (Sorry, I can’t draw a three-dimensional diagram) We can use the cosine of the angle between the vectors to express the degree of similarity between the two vectors. The cosine of an angle of 0 degrees (meaning that the two people are completely consistent) is 1, and an angle of 180 degrees (meaning that the two people are completely opposite) ) is -1. According to the cosine formula, ? Cosine of the included angle = vector dot product / (cross product of vector lengths) = ?( Square)) It can be seen that the cosine of the angle between A and B is 0.81, and the cosine of the angle between A and C is -0.97. The formula does not deceive me. The above is the case of three dimensions (three songs). The situation of N-dimension and N songs is the same in the same way. Suppose we select 100 seed songs and calculate the similarity values ??between each of them. Then when we find that Mr. A also likes to listen to "Little Apple" but Mr. B has never heard of it, I believe everyone knows how to recommend it to Mr. B. Come on.