When shopping online, reading novels or buying movie tickets, we will encounter all kinds of recommendations, recommending some products of the same type that we have bought or collected, or recommending some novels of the same theme that we have read. So how do these product recommendations work? We’re going to talk about these “boring” algorithms today.
In Internet applications, common recommendation algorithms include Collaborative Filtering
Recommendation, content-based Recommendation, Similarity Recommendation algorithm
Recommendation, Association Rule Based algorithm
Recommendaion). Different algorithms have different application scenarios. Reasonable application of these algorithms can bring us more economic benefits.
Collaborative Filtering Recommendation Algorithm
If you have a problem with C/C++ one item is a very enthusiastic one (● ‘◡’ ●).
Collaborative filtering algorithm can be said to be very hot in the field of e-commerce, many e-commerce platforms are using it to do their own platform commodity recommendation.
What is collaborative filtering?
In short, it is to find a group of people with the same interest and recommend other information of interest to users in this group.
Let’s use a simple example to illustrate this algorithm:
I like reading network novels, but what is the most annoying thing about reading network novels? The shortage of books. When you finish a book, what should you read next? How many chapters do you open one by one? Waste of time. Read the book reviews. It’s either a troll or a con.
This is where collaborative filtering comes in.
I am user A, I like to watch “The Best”, “Fight against the Sky”, “Jade Dynasty”, these are my interests. How do I define my interests? It could be a book that I’ve read more than 100 chapters, it could be a book that I’ve collected, it could be a book that I’ve given good reviews, but anyway, we’re going to define a latitude first.
Once my interest is established, other users will have the same interest. When other users have the same interest as mine, they can recommend all the books they are interested in to me.
The specific implementation steps are as follows:
We start by creating a large table, on which the X-axis is all of our novels (available from the database) and on the Y-axis is all of our users (available from the database).
Then we mark the intersections of XY (available in the log) for each user interested in the novel as follows:
After it is marked out, we can see that uncle Ge’s hobbies are “The Best”, “Fighting against the Sky” and “The Jade Dynasty”, while Uncle Zhang and Uncle Li share the same interests with me. Uncle Zhang and Uncle Li also read more novels than I did, and the extra part, in addition to reflecting synergy, can also be used as my recommendation.
Next time, when I open the APP of reading novels, the system can recommend these two novels to me, and I have a great possibility to open and watch them.
Content-based Recommendation Algorithm
What is a content recommendation algorithm?
Content recommendation algorithm is actually an algorithm that analyzes the historical data of users, abstracts the commonness of content, and then makes recommendations based on these commonness.
Here’s an example:
I still like to read novels, I often through some conditions to search novels, I often search: complete, fantasy, more than 2 million words. And my search becomes my history log. According to my log records, I abstracted the common content, and then searched for novels based on the common content abstracted, and then recommended these novels to me.
The specific implementation steps are as follows:
I searched, selected three books and read them, and I searched them separately
Fantasy, male frequency, this, more than 2 million words
Fantasy, male frequency, this, 1 -2 million words
Fantasy, male frequency, serialization, no limit
Abstract according to the appeal content, can I have a final result, is the result of the fantasy, male frequency, unlimited, unlimited, according to the results, we can go to search, and then according to the latest update or novel heat after sorting result set is recommended to the user, in this way, the result can meet the needs of users.
Of course, if the user queries too many times, resulting in poor accuracy, we can also use other methods to improve accuracy, such as only using the last 3 days of the query records or only using the last 3 times of the query records.
Similarity Recommendation Algorithm
Both collaborative filtering recommendation algorithm and content recommendation algorithm require users to have a certain amount of historical data, and then make recommendations based on the analysis of these historical data.
So what about new users? Then the similarity recommendation algorithm can solve this problem.
What is similarity recommendation algorithm?
Similarity recommendation algorithm, also known as similarity recommendation algorithm, is an algorithm to recommend similar items by analyzing the characteristics of the items.
In the similarity algorithm, there is a concept of Distance. The closer the Distance between the two is, the higher the similarity between them is; the farther the Distance is, the lower the similarity is. The idea is that if I click on a novel, the system can recommend it to me based on how similar it is to other novels.
And there are many different ways to compute this distance, which is the core of the similarity algorithm. There is Eucledian distance
Distance Manhattan Distance (Minkowski
Distance, Cosine, Cosine
Similarity), etc., I am not talking about the algorithm (I also don’t understand, haha, you can search your own).
The specific implementation steps are as follows:
I still like reading novels. I opened the book “Jade Queen”. What are the attributes of this book?
We set 8 attributes for the novel, which is equivalent to 8 dimensions. We took all attributes of The book “Jade Dynasty” as the origin, and then calculated the distance between these attributes through the distance algorithm. After summarizing, the nearest one is the most recommended one.
Assumption: the distance of the same attribute is 0, and vice versa is 1.
Distance = f(subject matter)+f(author)+f(status)+… +f(type);
Let’s go through all the novels and calculate this distance. Find a book called “The First Chronicles of the Devil: The Journey to the Wilderness”. Six attributes of this book are the same as those of Jade Dynasty, and two are different. Finally, we calculate that distance is 2, which is the closest book, so we recommend it.
Although we assume that the weights of different attributes are the same, in reality, the weights of different attributes are different. Because this recommendation is not based on the user’s historical data, the recommendation result of each user is the same.
Association Rule Based Recommendaion
Association rule recommendation is a recommendation algorithm widely used in e-commerce. The most classic case is that placing beer next to diapers can improve the sales of beer.
What is association rule recommendation?
To understand association rule recommendations, first understand association rules. Association rules are to find out the association between objects through data mining and analysis. Association rule recommendation is a kind of recommendation based on the association between objects.
Let’s take the example of me reading a novel
When I find a book I like to read, the book is “Jade Queen”, I add it to my book list, at this time, the system recommends several other books (” The Tomb of God “, “Coiling Dragon”, etc.), and tells me that I can also add them to the shelf. Such recommendation is generally the recommendation of association rules.
How are association rule recommendations implemented? Let’s talk about the specific implementation steps:
First, we need to find the data to analyze.
We found all the books on the list and listed them one by one.
Then, it is time to calculate the support for the association rules.
What is Support? Support is the percentage of a book or a combination of books on a list. For example, if “Jade Queen” is on all the lists, its support rate is 100%, and if “The Tomb of God” is on only two lists, its support rate is 40%.
Once we calculate the support for a single item, then we need to calculate the support for a combination of items. We calculate support by combining items in pairs, only when the combination appears in the list at the same time. We have six books, so the number of combinations is 15 (5+4+3+2+1=15).
At this point, we can actually make recommendations, we can recommend a book or combination of books that are highly supported to the user, so that the book is more easily accepted by the user.
Next, we begin to calculate the confidence of the association rules.
What is Confidence? When a user adds Tomb to their list, what is the probability that they will add Tomb Raider? This probability is the confidence level of Tomb of god -> Tomb Raiders.
Sepulcher has a 40% support rating, and Sepulcher and Tomb Raider have a 20% support rating, so sepulcher -> Tomb Raider has a 50% confidence rating.
Finally, we will analyze the promotion degree of association rules
According to the calculation of support degree, we find that 100% of the people who collect The book “Winding Dragon” will collect “Jade Jade Fairy”. So does it mean that when the users collect “Winding Dragon”, we recommend “Jade Jade Fairy” as the best?
No, that’s not true. Why should we recommend Jade Dynasty? That’s because we want to increase the number of readers of Jade Queen. However, after analyzing the data, we found that although users recommend “Jade Devil” when they collect “Winding Dragon”, users will collect 100% of them, but users will also collect “Jade Devil Devil” when they recommend it alone. The recommendation of association rules cannot bring higher reading volume for Jade Dynasty, so there is no direct relationship between users’ collection of Jade Dynasty and collection of Coining Dragon.
How to judge the effect of association rule recommendation? That’s the degree of elevation.
We compare the confidence degree of book A-> book B with the support degree of book B to calculate:
When the ratio is greater than 1, it means that recommendation book B is valid when collecting book A.
When the ratio is equal to 1, it means that recommendation book B is meaningless when collecting book A, and there is no correlation between the two.
When the ratio is less than 1, it means that recommending book B is invalid when collecting book A, so it is better to recommend book B directly.