Keywords

1 Introduction

It is difficult for consumers to find products which are truly suitable for them in an assortment of commodity world. It is necessary to use a recommendation system of the electronic mall website to automatically judge the products which have actual demands for consumers according to the consumers’ past consumption records and browsing records. The essence of the recommendation system is the recommendation algorithm, which can infer the items that the user might like. There are many types of recommended algorithms, and collaborative filtering is one of the most widely used personalized recommendation technologies. Collaborative filtering is mainly divided into user-based collaborative filtering and item-based collaborative filtering.

This paper designs two kinds of algorithms based on the user’s collaborative filtering recommendation algorithm and the item-based collaborative filtering recommendation algorithm by introducing the application of a vertical electronic shopping mall website—the watches network mall. It designs collaborative filtering recommendation algorithms and applies these algorithms to the recommendation of products.

2 Collaborative Filtering Recommendation Algorithm

2.1 User-Based Collaborative Filtering Recommended Algorithm

User-based collaborative filtering is the most widely used method in personalized recommendation. It predicts the interest preference of target users based on the interests of neighbor users. The algorithm first uses statistical techniques to find neighbors that have the same preferences as the target user, and then generates recommendations to the target users based on the preferences of the neighbors of target users.

Its basic principle is to use the similarity of user access behavior to recommend resources that users may be interested in. The system calculates the closest users of number N with its access behavior (such as purchased product collection, visited web page sets, etc.) by using a specific similarity function as the nearest neighbor collection. The nearest users of number N combine as the nearest neighbor set of the user, and the neighboring users of the statistics access the resource to generate a candidate recommendation set. Finally calculates the recommendation degree of each resource in the candidate recommendation set to the user, and take the top-K as the recommended set of the user (Fig. 1).

Fig. 1.
figure 1

Example of user-based collaborative filtering recommendation algorithm.

As shown in Formula (1), the favorite items of user A are A and C, the favorite item of user B is B, and the favorite items of user C are A, C and D. Using the cosine similarity algorithm to calculate the similarity between users, we get the result that the user A and user C have the highest similarity. Then find the most similar n users from the user set and extract all the products that the user likes, and remove the user’s own favorite item. For each candidate item, the degree to which the user may be interested in is calculated by a specific formula as shown in Formula (1).

$$ {\text{p}}(u,i) = \sum\limits_{v \in S(u,K) \cap N(i)} {w_{uv} r_{vi} } $$
(1)

In this formula, u is the target user, S is the item set, and rvi is the degree of preference of user v to user i. In a similar system, the user score is substituted, and this user score is formed by user behavior modeling. Finally, according to the neighboring users, the first few items are sorted according to the preference level.

2.2 Item-Based Collaborative Filtering Recommendation Algorithm

The basic idea of the item-based collaborative filtering recommendation algorithm is to calculate the similarity between items based on historical behavior data of all users in advance, and then recommend the items similar to the items that the user likes to the user (Fig. 2).

Fig. 2.
figure 2

Example of item-based collaborative filtering recommendation algorithm recommendation.

As shown in Formula (2), user A has acted on items A and C. User B has acted on items A, B and C, and user C has acted on item A. So we can get that the number of users who both like items A and C is 2. Item A is similar to item C, and then calculate the user’s interest of the item by the formula in Formula (2).

$$ {\text{p}}(u,{\text{j}}) = \sum\limits_{i \in N(u) \cap S(i,K)} {w_{ji} r_{ui} } $$
(2)

In this formula, u is the target user, N is the collection of items that the user likes, S represents the set of K items most similar to item i, wji represents the similarity of item j and item i, and rui represents the interest of user u for item i.

Table 1. Product recommendation module description.

3 Implementation of the Collaborative Filtering Recommendation Algorithm

3.1 Introduction and Design of Recommended Products Function

In an assortment of commodity worlds, it is often difficult for consumers to find products that are truly suitable for them. Therefore, the recommendation system or recommended function of the e-shop website has emerged. This article takes an electronic shopping mall website with watches as its main sales item as its background. One of its featured functions is to recommend the items that users may like to consumers. By adopting the collaborative filtering recommendation algorithm, it quickly guesses the customer’s consumption intention and improves the convenience of customer’s browsing, while increasing the sales of goods. It is mainly divided into user-based collaborative filtering and item-based collaborative filtering.

First, a brief introduction of the function of the collaborative filtering recommendation algorithm using in the electronic mall is given. It is mainly a “commodity recommendation” module. The product recommendation module mainly uses a user-based collaborative filtering recommendation algorithm and an item-based collaborative filtering recommendation algorithm to implement a function of personalizing recommended products to each user. The detailed description is shown in Table 1.

Fig. 3.
figure 3

Personalized recommended product activity chart.

Collaborative filtering recommendation algorithm recommended product function activity design diagram shown in Fig. 3.

The user enters the home page of “Amoy Online” to determine whether the user identity is a registered member. The system recommends the product for each member user in the “Personalized Recommended Products” section of the homepage and “Guess You Like” in the product details page. The system identifies the user identity, and the member id number is processed by the algorithm to obtain the recommended product list. Due to the recommendation mechanism, the recommended product list may be empty. If the recommended product list is empty, the member user is randomly recommended. The corresponding activity diagram and timing diagram of the product are shown in Fig. 4.

Fig. 4.
figure 4

Personalized recommended product timing chart.

3.2 User-Based Collaborative Filtering Recommendation Algorithm Recommended Products

In many cases, users are not really clear about their needs, or their needs are difficult to express with simple keywords. Or they need to be more in line with their personal tastes and preferences. Therefore, using the user-based collaborative filtering recommendation algorithm to learn from other preferences of other similarly high-profile member users, it is possible to personalize the recommended products for each member user, and complete the relevant recommendation of the homepage in the mall. As shown in Fig. 5.

Fig. 5.
figure 5

Personalized recommendation bar before login and personalized recommendation bar after login.

  1. (1)

    The system records the browsing, forwarding, collecting, purchasing and scoring behaviors through the recordBrowse(), recordRepeat(), recordCollect(), recordBuy(), and recordMarking() methods of the BehaviorController control class, passing in the user id and the product id. Each behavior is tagged, with browse, forward, favorite, and purchase using 0 or 1 to flag whether this behavior has occurred, with a score of 0 to 5 being scored.

  2. (2)

    When the user enters the mall page, the system performs the personalized product recommendation by calling the getRecommendGoods() method of the GoodsController control class. First, it is judged whether the user is a member user through the getAttribute() method of the session. If it is the member user, the user id will get into the getRecommendedGoods() method in the UserBased class to get the user’s personalized recommended product list. Finally the product data is encapsulated into json data and returned to the foreground to complete the product recommendation. If the user is a newly registered user or the user behavior data is too small to generate a recommended product list, the merchant product is randomly recommended to the user.

  3. (3)

    The personalized recommendation is mainly based on the user’s behavior to derive a preference for a certain product, and the user-based collaborative filtering recommendation algorithm is substituted to obtain a personalized product recommendation list for each user. Users’ behaviors include browsing, forwarding, collecting, purchasing and scoring. The system sets its behavior weights to 5%, 15%, 20%, 30%, and 30% respectively. Use the triggers in the database to calculate the degree of preference and update the preference field in the user behavior table based on the user’s behavior for each item as a trigger point.

  4. (4)

    Create a DataModel containing the user id, the product id and the user’s preference for the product. Pass the model into the PearsonCorrelationSimilarity() method of Apache Mahout. To calculate the Pearson similarity to get the similarity between users, and pass the returned result to NearestNUserNeighborhood. The () method creates an instance of a neighbor user, and finally the recommended() method in the GenericUserBasedRecommender class gets the recommendation result by calling getTopItems() of the TopItems class.

3.3 Item-Based Collaborative Filtering Recommendation Algorithm

The mall system uses the item-based collaborative filtering recommendation algorithm to calculate the similarity between products by rating the history of the product, and then generating a recommendation list for the user according to the similarity of the item and the historical behavior of the user, which is completed in the mall. The product listing page guesses the recommendation of the column you like, as shown in Fig. 6.

Fig. 6.
figure 6

Product details page guess you like the column to display recommended product results

  1. (1)

    When user confirms the receipt, the system will let the user rate the product, and the content of the rating will be recorded in the comment table. The information in the table includes the user id, the product id, and the user’s comments to the product.

  2. (2)

    When users click on the products’ detail page, the system will grab the user’s session information, get its user id and pass it to the getRecommendedGoods() method of ItemBased which is an implementation class to obtain the recommendation list.

  3. (3)

    Create a DataModel in the getRecommendedGoods() method, encapsulate the user id, product id, and score in the comment table with the DataModel, and then pass the model to the PearsonCorrelationSimilarity() method of Apache Mahout to calculate the Pearson similarity. The similarity between the items, finally pass the similarity information of the model and the item into the GenericItemBasedRecommender class. It calls the recommended() method in the class and call the getTopItems() of the TopItems class to get the recommendation results.

4 Summary of Collaborative Filtering

Here gives the comparison of advantages and disadvantages between UserCF (User-based collaborative filtering recommendation algorithm) and ItemCF (Item-based collaborative filtering recommendation algorithm), as shown in Table 2.

Table 2. Comparison of advantages and disadvantages between UserCF and ItemCF

As a classic recommendation algorithm, collaborative filtering algorithm is widely used in industry. It has many advantages, and the model has strong versatility. It does not require much professional knowledge in the data field. The project is simple to implement and the effect is obvious. These are the reasons why it is popular. Of course, collaborative filtering has some inevitable problems, such as the headache of “cold start”. When we don’t have any data from new users, we can’t recommend items for new users. At the same time, the differences in the situation are not considered, such as the users scene and the users current mood. There is no way to get some niche’s unique preferences. This piece is based on content-based recommendations.