A product recommendation method based on matrix factorization recommendation algorithm
Patent Information
- Application Number
- CN202311335495.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-13
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2043-10-13
AI Technical Summary
此外,由于用户偏爱某些类别的产品,给这些类别的产品打高分,而对另一些不喜爱类别的产品打低分,造成了用户对产品评分的偏差,影响了推荐算法的准确性
[0038] Beneficial effects: Compared with the prior art, the significant effect of the present invention is that the present invention utilizes the product category distribution provided by the historical dataset of all users and the product category distribution provided by the user dataset of a single user, and defines the difference between the two through Wasserstein distance, thereby quantifying the concept of tolerance, introducing tolerance into the user rating system, and using matrix factorization recommendation algorithm to realize product recommendation, reducing the rating bias caused by user subjective factors, and improving the accuracy and objectivity of recommendation.
Smart Images

Figure CN117370658B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a product recommendation method, specifically a product recommendation method based on a matrix factorization recommendation algorithm. Background Technology
[0002] The rapid development of the Internet has led to an explosive growth and rapid spread of information. Traditional proactive search can no longer meet the needs of users and the market. Based on users' search history, recommendation algorithms are used to process and integrate user needs, and content that users are interested in is directly pushed to customers.
[0003] Matrix factorization is an important technique in recommendation algorithms. Based on user preferences for products, it maps user and product features into a low-dimensional latent space, capturing the relationships between users and products. Matrix factorization can effectively handle large-scale user-product datasets and does not rely on specific domain knowledge. It can be applied to different types of recommendation tasks, including digital media products such as movies and music, as well as physical products, demonstrating efficiency, versatility, and flexibility.
[0004] Traditional matrix factorization only explores the relationship between users and product ratings, neglecting the product's own attributes. For example, for movies, attributes include genre, actors, and director. Furthermore, users' preference for certain product categories, resulting in high ratings for those categories and low ratings for disliked categories, creates bias in user product ratings and affects the accuracy of recommendation algorithms. Summary of the Invention
[0005] Purpose of the invention: The purpose of this invention is to provide a product recommendation method based on a matrix factorization recommendation algorithm with high accuracy.
[0006] Technical solution: A product recommendation method based on matrix factorization recommendation algorithm, comprising the following steps:
[0007] S1. Obtain the historical dataset and user dataset of the target product;
[0008] S2. Using the historical dataset obtained in step S1, calculate the proportion of different ratings for each category of products in the overall market to obtain the market sample;
[0009] S3. Using the user dataset obtained in step S1, calculate the proportion of different ratings for each category of products by a single user to obtain a user sample.
[0010] S4. Use Wasserstein distance to measure the difference between the market sample in step S2 and the user sample in step S3;
[0011] S5. Calculate the user's tolerance for each category of products using the difference values from step S4.
[0012] S6. Construct a user product rating based on the tolerance obtained in step S5, and further process it to obtain the subject prediction rating;
[0013] S7. Using the subject prediction score from step S6, apply the minimum quadratic loss to the objective function to obtain the corresponding user feature matrix and product feature matrix, obtain the user's predicted score for the product, and recommend the corresponding product to the user based on the predicted score.
[0014] Specifically, in step S2, the proportion of different ratings given to each product category by the overall market is calculated using historical datasets.
[0015]
[0016] In the formula: Indicates category as Among the products, the rating is The proportion of products, ; Representing historical datasets In, the category is The product was rated as The number of; Representing historical datasets Above, the category is The total number of products.
[0017] Specifically, in step S3, the proportion of different ratings given by a single user to each category of products is calculated using the user dataset.
[0018]
[0019] In the formula: Indicates to the user In other words, the category is Among the products, the rating is The proportion of products; Indicates user Historical datasets The above category is Among the products, the rating is The number of; Indicates user Historical datasets Above, the category is The total number of products;
[0020] Specifically, in step S4, the Wasserstein distance is used to measure... and Differences between
[0021]
[0022] In the formula: Is for category Products, users The difference between the rating distribution and the overall rating distribution; It is a category The weight, with a default value of 1; hour, The value range is [0, 2].
[0023] Specifically, in step S5, the user's tolerance for a single category of products is calculated.
[0024]
[0025] In the formula: For users Category The tolerance level ranges from [-1, 1]. A smaller value indicates that the user is less tolerant of the category, while a higher value indicates that the user is more tolerant of the category.
[0026] Specifically, in step S6, the user product rating formula based on tolerance is...
[0027]
[0028] In the formula: For users For the product The rating; For user feature vectors, For product feature vectors, The main prediction score, For fluctuation score, For control parameters, ;
[0029] The above formula, when transformed, yields the subject prediction score formula as follows:
[0030]
[0031] Specifically, in step S7, the objective function is processed using the least quadratic loss method to obtain the corresponding user feature matrix and product feature matrix.
[0032]
[0033] In the formula: To return the minimum value of the function to be found The function; This refers to all user feature vectors The user feature matrix is composed of This refers to the feature vectors of all products. The product feature matrix is composed of for , The user-product space constitutes It is a vector consisting of user u's tolerance for all categories; , , express , , The 2-norm, These are control parameters, initial settings. Then, increase the step size by 0.02 each time.
[0034] get , Then, through calculation The system obtains the predicted rating of a single product from user u and selects the product with the highest predicted rating to recommend to the user.
[0035] A product recommendation system based on matrix factorization recommendation algorithm, constructed using the aforementioned product recommendation method based on matrix factorization recommendation algorithm.
[0036] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the steps of the product recommendation method based on the matrix factorization recommendation algorithm.
[0037] A computer-readable storage medium having a computer program stored thereon, characterized in that, when the computer program is executed by a processor, it implements the steps of the product recommendation method based on the matrix factorization recommendation algorithm.
[0038] Beneficial effects: Compared with the prior art, the significant effect of the present invention is that the present invention utilizes the product category distribution provided by the historical dataset of all users and the product category distribution provided by the user dataset of a single user, and defines the difference between the two through Wasserstein distance, thereby quantifying the concept of tolerance, introducing tolerance into the user rating system, and using matrix factorization recommendation algorithm to realize product recommendation, reducing the rating bias caused by user subjective factors, and improving the accuracy and objectivity of recommendation. Attached Figure Description
[0039] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation
[0040] The present invention will be further explained below with reference to the accompanying drawings and specific embodiments.
[0041] Please see Figure 1 As shown, this embodiment provides a product recommendation method based on a matrix factorization recommendation algorithm, including the following steps:
[0042] S1. Obtain the historical dataset and user dataset of the target product;
[0043] S2. Using the historical dataset obtained in step S1, calculate the proportion of different ratings for each category of products in the overall market to obtain the market sample;
[0044] S3. Using the user dataset obtained in step S1, calculate the proportion of different ratings for each category of products by a single user to obtain a user sample.
[0045] S4. Use Wasserstein distance to measure the difference between the market sample in step S2 and the user sample in step S3;
[0046] S5. Calculate the user's tolerance for each category of products using the difference values from step S4.
[0047] S6. Construct a user product rating based on the tolerance obtained in step S5, and further process it to obtain the subject prediction rating;
[0048] S7. Using the subject prediction score from step S6, apply the minimum quadratic loss to the objective function to obtain the corresponding user feature matrix and product feature matrix, obtain the user's predicted score for the product, and recommend the corresponding product to the user based on the predicted score.
[0049] In this implementation, the classic dataset from the GroupLens website, the movielens-latest-small dataset, is used as an example. User ratings for movies can be obtained from this dataset, and the corresponding movie category information can be found. Historical datasets are then used to calculate the proportion of different ratings for each category in the overall market.
[0050]
[0051] In the formula: Indicates category as Among the products, the rating is The proportion of products, ; Representing historical datasets In, the category is The product was rated as The number of elements, in this embodiment, is an integer with a score of 1 to 5 in the movielens-latest-small dataset; Representing historical datasets Above, the category is Total number of products. When a category has no rated [number]... When it comes to products, we believe Since real-world datasets are usually quite large, this situation is almost never encountered.
[0052] For a single user dataset For example, given user interaction data with user ID 1, if user 1 rates movie 1 as 4 points, and the movie with ID 1 is named "Toy Story," which contains five categories (when a movie contains multiple categories, each category is treated equally, with the same percentage as when a movie contains only one category, all considered as 1), then the proportion of different ratings for each category by a single user can be calculated using the user dataset.
[0053]
[0054] In the formula: Indicates to the user In other words, the category is Among the products, the rating is The proportion of products; Indicates user Historical datasets The above category is Among the products, the rating is The number of; Indicates user Historical datasets Above, the category is The total number of products; specifically, when a user has never interacted with a category, or a category has no rating. When it comes to products, we believe .
[0055] Then, the Wasserstein distance was used to measure... and Differences between
[0056]
[0057] In the formula: Is for category Products, users The difference between the rating distribution and the overall rating distribution; It is a category The weight, with a default value of 1; hour, The value range is [0, 2].
[0058] Define user tolerance for a single product category
[0059]
[0060] In the formula: For users Category The tolerance level ranges from [-1, 1]. A smaller value indicates that the user is less tolerant of the category, while a higher value indicates that the user is more tolerant of the category.
[0061] Table 1 shows the tolerance of user 1 for all categories in the movielens-latest-small dataset calculated using the method described above.
[0062] 1 Action movies 0.400158 2 Adventure movies 0.286914 3 Animated films -0.179034 4 Children's films 0.170389 5 Comedy films 0.2889 6 Crime films 0.331566 7 Documentary film 0 8 Drama Film 0.171209 9 Fantasy films 0.465915 10 Film Noir -0.539534 11 Horror Movies 0.520529 12 Music Video -0.280697 13 Mysterious Film -0.133653 14 Romance films 0.134342 15 Science fiction films 0.496198 16 Thriller Movies 0.336845 17 War films 0.453322 18 Western films 0.045929
[0063] Table 1
[0064] After obtaining users' tolerance values for different product categories, we begin to construct the objective function, first deriving the user product rating formula based on tolerance.
[0065]
[0066] In the formula: For users For the product The rating; For user feature vectors, For product feature vectors, The main prediction score, For fluctuation score, For control parameters, , It should be as small as possible to ensure the stability of the model. This embodiment uses... Starting with a value of 0.02, the iteration proceeds with a step size of 0.02. This shows the user's tolerance for this product category. When greater than 0, (i.e., the predicted score for the main body) will be less than the user score. Fluctuation scores mitigate the impact of users giving high scores to products they like; similarly, when a user's tolerance is less than 0, greater than Fluctuation scores mitigate the impact of users giving low scores to products they dislike.
[0067] The above formula, when transformed, yields the subject prediction score formula as follows:
[0068]
[0069] The objective function is processed using the least quadratic loss method to obtain the corresponding user feature matrix and product feature matrix.
[0070]
[0071] In the formula: To return the minimum value of the function to be found The function; This refers to all user feature vectors The user feature matrix is composed of This refers to the feature vectors of all products. The product feature matrix is composed of for , The user-product space constitutes It is a vector consisting of user u's tolerance for all categories; , , express , , The 2-norm, These are control parameters, initial settings. Then, the step size is increased by 0.02 each time.
[0072] In this embodiment, the user feature vector and the product feature vector have the same dimension. An initial dimension of 20 is set for experimentation, with 5 dimensions added each time. The maximum number of iterations is set to 200 to find the optimal control parameters. And the optimal feature vector dimension here, to obtain the locally optimal minimum objective function, and return the corresponding , Matrix, then calculate The system obtains the user's predicted rating for the product and selects the corresponding number of products with the highest predicted ratings to recommend to the user based on the required number of recommended products.
[0073] As shown in Table 2, in this embodiment, the above method is applied to obtain a predicted rating from the tolerance data obtained from User 1's personal dataset, and 10 recommended movies are provided to User 1.
[0074] 1 902 3.85 Breakfast at Tiffany's (1961) 2 1298 3.71 Pink Floyd: The Wall (1982) 3 898 3.66 The Philadelphia Story (1940) 4 1934 3.64 You Can't Take It with You (1938) 5 1068 3.43 Shall We Dance (1937) 6 959 3.41 Of Human Bondage (1934) 7 1243 3.40 Rosencrantz and Guildenstern Are Dead (1990) 8 914 3.37 My Fair Lady (1964) 9 900 3.36 An American in Paris (1951) 10 314 3.36 The Secret of Roan Inish (1994)
[0075] Table 2
[0076] This embodiment also provides a product recommendation system based on matrix factorization recommendation algorithm constructed using the aforementioned product recommendation method based on matrix factorization recommendation algorithm.
[0077] This embodiment also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the steps of the product recommendation method based on the matrix factorization recommendation algorithm.
[0078] This embodiment also provides a computer-readable storage medium storing a computer program thereon, characterized in that the computer program, when executed by a processor, implements the steps of the product recommendation method based on the matrix factorization recommendation algorithm.
Claims
1. A product recommendation method based on matrix factorization recommendation algorithm, characterized in that, Includes the following steps: S1. Obtain the historical dataset and user dataset of the target product; S2. Using the historical dataset obtained in step S1, calculate the proportion of different ratings for each category of products in the overall market to obtain the market sample; S3. Using the user dataset obtained in step S1, calculate the proportion of different ratings for each category of products by a single user to obtain a user sample. S4. Use Wasserstein distance to measure the difference between the market sample in step S2 and the user sample in step S3; S5. Calculate the user's tolerance for each product category using the difference values from step S4. The formula is: In the formula: For users Category The tolerance level ranges from [-1, 1]. The smaller the value, the less tolerant the user is of the category; the higher the value, the more tolerant the user is of the category. Is for category Products, users The difference between the user sample and the market sample; S6. Construct a user product rating based on the tolerance obtained in step S5, and further process it to obtain the main predicted rating, using the following formula: In the formula: For users For the product The rating; For user feature vectors, For product feature vectors, The main prediction score, For fluctuation score, For control parameters, ; S7. Using the subject prediction score from step S6, apply the minimum quadratic loss to the objective function, as shown in the formula: In the formula: To return the minimum value of the function to be found The function; This refers to all user feature vectors The user feature matrix is composed of This refers to the feature vectors of all products. The product feature matrix is composed of for , The user-product space constitutes It is a vector consisting of user u's tolerance for all categories; , , express , , The 2-norm, These are control parameters, initial settings. Then, increase the step size by 0.02 each time. get , Then, through calculation The system obtains the predicted rating of a single product from user u and selects the product with the highest predicted rating to recommend to the user.
2. The product recommendation method according to claim 1, characterized in that: In step S2, the proportion of different ratings given to each product category by the overall market is calculated using historical datasets. In the formula: Indicates category as Among the products, the rating is The proportion of products, ; Representing historical datasets In, the category is The product was rated as The number of; Representing historical datasets Above, the category is The total number of products.
3. The product recommendation method according to claim 2, characterized in that, In step S3, the proportion of different ratings given by a single user to each product category is calculated using the user dataset. In the formula: Indicates to the user In other words, the category is Among the products, the rating is The proportion of products; Indicates user Historical datasets The above category is Among the products, the rating is The number of; Indicates user Historical datasets Above, the category is The total number of products.
4. The product recommendation method according to claim 3, characterized in that, In step S4, Wasserstein distance is used as a metric. and Differences between In the formula: Is for category Products, users The difference between the rating distribution and the overall rating distribution; It is a category The weight, with a default value of 1; hour, The value range is [0, 2].
5. A product recommendation system based on matrix factorization recommendation algorithm constructed using the product recommendation method based on matrix factorization recommendation algorithm as described in any one of claims 1-4.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
User-based recommendation method, device and equipment, and computer readable storage medium
CN112182407A
Intelligent recommendation method and system based on user preference correction
CN114021020A