Project recommendation method and apparatus, computer-readable storage medium, and electronic device
By randomly generating and updating the initial matrix during matrix factorization, the problem of low recommendation accuracy in matrix factorization methods is solved, achieving more accurate user item recommendations.
Patent Information
- Application Number
- CN202411696588.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2044-11-25
AI Technical Summary
Existing matrix factorization methods have low recommendation accuracy when recommending items to users, and have failed to effectively solve the problems of data sparsity and cold start.
By randomly generating an initial user feature matrix, an initial latent vector matrix, and an initial item feature matrix, and updating them based on a matrix factorization method until the preset conditions are met, the user's predicted rating for the item is determined, and items are recommended based on the predicted rating.
It improves the ability to reflect the potential relationships between users and items in matrix factorization, thereby enhancing recommendation accuracy.
Smart Images

Figure CN119539059B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of recommendation algorithms, and in particular, to an item recommendation method and device, a computer readable storage medium and an electronic device. BACKGROUND
[0002] With the rapid development of Internet technology, personalized recommendation systems have become an indispensable part of many fields such as e-commerce, social media, online entertainment, etc. Recommendation algorithms aim to predict and recommend content or goods that may be of interest to users by analyzing their historical behavior and preferences, thereby improving user experience and satisfaction. Traditional recommendation methods such as content-based recommendation and collaborative filtering have been widely applied, but they often face challenges such as data sparsity and cold start problems.
[0003] In order to solve the above problems, in recent years researchers have begun to explore more advanced technical means to improve the performance of recommendation systems. Among them, matrix factorization (MF) as an effective solution has received widespread attention. The basic idea of matrix factorization is to decompose the user-item rating matrix into two low-rank matrices: one represents the user's latent vectors, and the other represents the item's latent vectors. In this way, the potential relationship between users and items can be captured, and more accurate recommendations can be made accordingly. However, when recommending items to users based on traditional matrix factorization, there is still a problem of low recommendation accuracy.
[0004] In view of the above problems, no effective solution has been proposed so far. SUMMARY
[0005] The embodiments of the present application provide an item recommendation method and device, a computer readable storage medium and an electronic device to at least solve the technical problem of low recommendation accuracy when recommending items to users based on matrix factorization in related technologies.
[0006] According to an aspect of some embodiments of the present application, there is provided a method for recommending items, comprising: obtaining ratings of at least some of M items by each of N users, and constructing a rating matrix according to the ratings, wherein a single element in the rating matrix represents a rating of a single item by a single user; randomly generating an initial user feature matrix, an initial latent vector matrix and an initial item feature matrix, wherein the initial user feature matrix comprises user feature vectors of the users, the initial item feature matrix comprises item feature vectors of the items, and the initial latent vector matrix is used to represent association between features in the user feature vectors and features in the item feature vectors; updating the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix based on a matrix decomposition method, until an iteration of the matrix decomposition method meets a preset iteration condition, determining predicted ratings of all of the M items by each of the N users according to the updated user feature matrix, latent vector matrix and item feature matrix, and determining items to be recommended to each of the N users according to the predicted ratings, and recommending the items to be recommended to the N users.
[0007] Further, the method for recommending items further comprises: determining a target value according to target information, wherein the target information comprises at least one of the following: a number of the users, a number of the items, a total number of ratings of the N users, and the target value is positively correlated with the number in the target information; and determining a number of dimensions of features in the user feature vectors according to the target value, wherein the target value is positively correlated with the number of dimensions.
[0008] Further, the method for recommending items further comprises: calculating a loss value according to a preset objective function, the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix; in a case where the loss value is greater than a target threshold, updating the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix using a gradient descent method to obtain the user feature matrix, the latent vector matrix and the item feature matrix; and repeatedly performing the step of calculating the loss value according to the preset objective function, the user feature matrix, the latent vector matrix and the item feature matrix until the loss value is less than or equal to the target threshold, and determining that the iteration of the matrix decomposition method meets the preset iteration condition.
[0009] Further, the method for recommending items further comprises: determining N*M user-item pairs based on the N users and the M items; for each user-item pair, calculating a predicted error value corresponding to the user-item pair according to the rating matrix, the initial item feature matrix, a user feature vector associated with the user-item pair and an item feature vector associated with the user-item pair; and updating the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix according to the predicted error value to obtain the user feature matrix, the latent vector matrix and the item feature matrix.
[0010] Further, the item recommendation method further comprises: updating the user feature vector according to the prediction error value of the user-item pair associated with the user feature vector in the initial user feature matrix, to obtain a user feature matrix; updating the initial latent vector matrix according to the prediction error value of the user-item pair, to obtain a latent vector matrix; updating the item feature vector according to the prediction error value of the user-item pair associated with the item feature vector in the initial item feature matrix, to obtain an item feature matrix.
[0011] Further, the item recommendation method further comprises: multiplying the user feature matrix and the latent vector matrix to obtain a first matrix; multiplying the first matrix and the transpose matrix of the item feature matrix to obtain a target score matrix, wherein the target score matrix comprises the predicted scores of all items in the M items for each user.
[0012] Further, the item recommendation method further comprises: for each user, determining a plurality of target unrated items associated with the user according to the score matrix, determining the predicted scores of the plurality of target unrated items for the user according to the target score matrix, and determining the corresponding recommended item for the user from the plurality of target unrated items according to the predicted scores of the plurality of target unrated items, to obtain the corresponding recommended item for each of the N users.
[0013] According to another aspect of the embodiments of the present application, an item recommendation device is also provided, comprising: an acquisition module configured to acquire the scores of at least part of the M items for each of the N users, and construct a score matrix according to the scores, wherein a single element in the score matrix represents the score of a single item for a single user; a generation module configured to randomly generate an initial user feature matrix, an initial latent vector matrix and an initial item feature matrix, wherein the initial user feature matrix comprises user feature vectors of each user, the initial item feature matrix comprises item feature vectors of each item, and the initial latent vector matrix is used to represent the association between the features in the user feature vectors and the features in the item feature vectors; and a processing module configured to update the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix based on a matrix decomposition method, until the iteration of the matrix decomposition method meets a preset iteration condition, determine the predicted scores of all items in the M items for each user according to the updated user feature matrix, latent vector matrix and item feature matrix, determine the corresponding recommended item for each of the N users according to the predicted scores, and recommend the recommended item to the N users.
[0014] According to another aspect of the embodiments of the present application, a computer readable storage medium is also provided, which stores a computer program, wherein the computer program is configured to execute the above-mentioned item recommendation method when running.
[0015] According to another aspect of the embodiments of the present application, an electronic device is also provided, which includes one or more processors; and a memory storing one or more programs, which when executed by the one or more processors, cause the one or more processors to implement a program for running, wherein the program is configured to perform the item recommendation method described above when running.
[0016] In the embodiments of the present application, the way of recommending items for users based on information of multiple dimensions in matrix decomposition is adopted, the ratings of each user in N users to at least part of M items are obtained, and a rating matrix is constructed according to the ratings. Then, an initial user feature matrix, an initial latent vector matrix and an initial item feature matrix are randomly generated. Then, the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix are updated based on a matrix decomposition method. Until the iteration of the matrix decomposition method meets a preset iteration condition, the predicted ratings of each user to all the M items are determined according to the updated user feature matrix, the latent vector matrix and the item feature matrix. The items to be recommended corresponding to the N users are determined according to the predicted ratings, and the N users are recommended with the items to be recommended. A single element in the rating matrix represents the rating of a single user to a single item. The initial user feature matrix includes user feature vectors of each user, the initial item feature matrix includes item feature vectors of each item, and the initial latent vector matrix is used to represent the association relationship between the features in the user feature vectors and the features in the item feature vectors.
[0017] In the above process, the random determination of the user features, the item features and the association relationship between the user features and the item features is realized by randomly generating the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix. The effective update of the information of multiple dimensions based on the matrix decomposition method is realized by updating the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix based on the matrix decomposition method, so that the potential relationship between the users and the items can be more accurately reflected. The ratings of the users to the items are determined based on the information of multiple dimensions in the matrix decomposition by determining the predicted ratings of each user to all the M items according to the updated user feature matrix, the latent vector matrix and the item feature matrix when the iteration of the matrix decomposition method meets the preset iteration condition, so that the accuracy of the determined ratings can be improved, and the recommendation accuracy can be improved.
[0018] Therefore, the scheme provided in the present application achieves the purpose of recommending items for users based on information of multiple dimensions in matrix decomposition, thereby realizing the technical effect of improving the recommendation accuracy, and further solving the technical problem of low recommendation accuracy when recommending items for users based on matrix decomposition in the related art. BRIEF DESCRIPTION OF DRAWINGS
[0019] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application. In the drawings:
[0020] Figure 1 is a flow of an optional item recommendation method according to an embodiment of the application Figure 1 ;
[0021] Figure 2 is a flow of an optional item recommendation method according to an embodiment of the application Figure 2 ;
[0022] Figure 3 is a schematic diagram of an optional item recommendation device according to an embodiment of the application
[0023] Figure 4 is a schematic diagram of an optional electronic device according to an embodiment of the application DETAILED DESCRIPTION
[0024] In order to make persons skilled in the art better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all the other embodiments obtained by persons of ordinary skill in the art without creative work should fall within the protection scope of the present application.
[0025] It should be noted that the terms "first", "second", and the like in the description and claims of the present application and the above drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units need not be limited to those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0026] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis (such as user ratings for projects), stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards in the relevant region, and provide corresponding operation portal for user to choose authorization or refusal.
[0027] Embodiment 1
[0028] According to an embodiment of the present application, an embodiment of a project recommendation method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from here.
[0029] Figure 1 is a flow of an optional project recommendation method according to an embodiment of the present application Figure 1 As shown in Figure 1 , the method comprises the following steps:
[0030] Step S101, obtaining the ratings of each user in N users to at least part of M projects, and constructing a rating matrix according to the ratings, wherein a single element in the rating matrix represents the rating of a single user to a single project.
[0031] Optionally, electronic devices, application systems, servers and other devices can be used as the execution subject of the present application. In the present embodiment, the target recommendation system is used as the execution subject to execute the project recommendation method described above.
[0032] Optionally, the projects described above are different according to different actual application scenarios. For example, in the shopping scenario, the project can be different kinds of goods, in the financial scenario, the project can be different types of financial products, in the aviation scenario, the project can be different types of coupons, or the project can also be different types of aviation insurance, etc. Therefore, in the present embodiment, the content of the project is not limited specifically.
[0033] Optionally, the target recommendation system can read the original user-item rating data from the database, i.e., obtain the ratings of each of the N users to at least part of the M items. Among them, for each of the N users, the user can only have rated part of the M items, i.e., there can be items in the M items that the user has not rated, and the target recommendation system can predict the rating of the user to the unrated item through the item recommendation method provided in the embodiment, so as to recommend the item to the user based on the rating after the prediction is completed. Among them, the aforementioned M and N are positive integers greater than 1.
[0034] Optionally, after obtaining the original user-item rating data, the target recommendation system can perform integrity check on the data to ensure that each record has a valid user ID, item ID and rating value. For missing fields, the system records logs and marks as abnormal data. In addition, the system can use statistical methods to identify outliers, such as ratings exceeding a reasonable range (for example, ratings between 1 and 5, but 0 or ratings exceeding 5), and delete or replace them with a reasonable default value. In order to reduce the impact of duplicate data, the system can only keep the latest one or the average value for multiple rating records of the same user to the same item, thereby obtaining updated user-item rating data.
[0035] In some embodiments, the database directly stores the ratings of the user to the item, so that the target recommendation system can directly obtain the ratings.
[0036] In some embodiments, the database does not directly store the ratings of the user to the item, but stores the behavior records of the user to the item, such as clicking, purchasing, collecting, etc. The target recommendation system can obtain these behavior records, and then determine the rating of the user to the item based on the preset rating rules according to the behavior records of the user to the item.
[0037] Optionally, after obtaining the original user-item rating data or the updated user-item rating data, the target recommendation system can construct a rating matrix based on the ratings of each of the N users to at least part of the M items. For example, the rating of a user to an item is taken as an element, and the elements corresponding to the same user are set to belong to the same row, and the elements corresponding to the same item are set to belong to the same column, thereby constructing an MxN rating matrix. The rating matrix is a sparse matrix, in which the row represents the user and the column represents the item, and each element r ui represents the rating of the user u to the item i. For the items that the user has not rated, the element at the corresponding position in the rating matrix can be represented by 0. Since the user-item rating data is usually highly sparse, the system uses a sparse matrix to represent it to save a lot of storage space.
[0038] In step S102, an initial user feature matrix, an initial latent vector matrix and an initial item feature matrix are randomly generated, where the initial user feature matrix includes user feature vectors of respective users, the initial item feature matrix includes item feature vectors of respective items, and the initial latent vector matrix is used to represent the association between features in the user feature vectors and features in the item feature vectors.
[0039] Optionally, the target recommendation system can use a normal distribution to randomly initialize the initial user feature matrix U (of size M x k), the initial latent vector matrix V (of size k x l) and the initial item feature matrix I (of size N x l), where each row in the initial user feature matrix U represents a latent vector of a user, each column in the initial item feature matrix I represents a latent vector of an item, and the initial latent vector matrix V is used to represent the association between k features in the user feature vectors and l features in the item feature vectors. The latent vector can capture the key features of each entity without directly relying on explicit attribute descriptions. For example, in the movie recommendation scenario, although a user can not explicitly indicate which type of movie they like, we can infer that the user may have a preference for certain specific styles or themes of films by analyzing their viewing history. Similarly, for a movie itself, even if there is a lack of detailed classification information, implicit features reflecting its characteristics can be extracted from the collective evaluation patterns of the audience. Therefore, the method based on the latent vector not only helps to alleviate the impact of data sparsity, but also discovers deep interest matching relationships, thereby improving the recommendation quality.
[0040] In some embodiments, the target recommendation system can also use other initialization strategies to generate the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix.
[0041] In step S103, the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix are updated based on a matrix decomposition method, until the iteration of the matrix decomposition method meets a preset iteration condition. Then, the predicted scores of all items in the M items for respective users are determined according to the updated user feature matrix, the latent vector matrix and the item feature matrix, and the to-be-recommended items corresponding to the N users are determined according to the predicted scores, so as to recommend the to-be-recommended items to the N users.
[0042] Optionally, the target recommendation system can update the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix based on the matrix decomposition method until the iteration of the matrix decomposition method satisfies the preset iteration condition. For example, the preset iteration condition of the matrix decomposition method is that the loss value calculated based on the target function is less than or equal to a target threshold value. The target recommendation system can calculate the loss value based on the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix and the target function, so as to determine that the iteration of the matrix decomposition method satisfies the preset iteration condition in the case that the loss value is less than or equal to the target threshold value, update the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix in the case that the loss value is greater than the target threshold value, and calculate the loss value again, thereby continuously iterating until it is determined that the iteration of the matrix decomposition method satisfies the preset iteration condition.
[0043] Optionally, in the case that the iteration of the matrix decomposition method satisfies the preset iteration condition, the target recommendation system can determine the ratings of all the items in the M items by each user according to the user feature matrix, the latent vector matrix and the item feature matrix obtained after the last update. For example, the target recommendation system determines a target rating matrix of size MxN based on the user feature matrix, the latent vector matrix and the item feature matrix, determines the elements in the target rating matrix as the predicted ratings of a single user to a single item, and thus determines the predicted ratings of all the items in the M items by each user according to the target rating matrix.
[0044] Optionally, after the predicted ratings of all the items in the M items by each user are determined, the target recommendation system can determine the to-be-recommended items corresponding to the N users respectively according to the predicted ratings, and recommend the to-be-recommended items to the N users. For example, for each user, the M items are sorted in descending order of the predicted ratings, and thus the items ranked in the top D are determined as the to-be-recommended items. For another example, for each user, the items that have not been rated by the user are sorted in descending order of the predicted ratings, and thus the items ranked in the top E are determined as the to-be-recommended items. Wherein, D and E are positive integers, and D and E can be the same or different.
[0045] Based on the scheme defined in steps S101 to S103, it can be known that, in the embodiment of the present application, the way of recommending items to users based on information of multiple dimensions in matrix decomposition is adopted, the ratings of each user in N users to at least part of the M items are obtained, and a rating matrix is constructed according to the ratings, then an initial user feature matrix, an initial latent vector matrix and an initial item feature matrix are randomly generated, then the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix are updated based on the matrix decomposition method, until the iteration of the matrix decomposition method meets the preset iteration condition, the predicted ratings of each user to all the M items are determined according to the updated user feature matrix, latent vector matrix and item feature matrix, and the to-be-recommended items corresponding to the N users are determined according to the predicted ratings, and the to-be-recommended items are recommended to the N users. A single element in the rating matrix represents the rating of a single user to a single item, wherein the initial user feature matrix includes user feature vectors of each user, the initial item feature matrix includes item feature vectors of each item, and the initial latent vector matrix is used to represent the association relationship between the features in the user feature vectors and the features in the item feature vectors.
[0046] It is easy to note that, in the above process, the random determination of the user features, item features and the association relationship between the user features and the item features is realized by randomly generating the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix, the effective update of the information of multiple dimensions based on the matrix decomposition method is realized by updating the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix based on the matrix decomposition method, so that it can more accurately reflect the potential relationship between the users and the items, the ratings of the users to the items based on the information of multiple dimensions in the matrix decomposition are determined by determining the predicted ratings of each user to all the M items according to the updated user feature matrix, latent vector matrix and item feature matrix when the iteration of the matrix decomposition method meets the preset iteration condition, so that the accuracy of the determined ratings can be improved, and the recommendation accuracy can be improved.
[0047] Therefore, the scheme provided in the present application achieves the purpose of recommending items to users based on information of multiple dimensions in matrix decomposition, thereby realizing the technical effect of improving the recommendation accuracy, and further solving the technical problem of low recommendation accuracy when recommending items to users based on matrix decomposition in the related art.
[0048] In an optional embodiment, the target recommendation system can determine the dimension number of the features in the user feature vector by: determining a target value according to target information, wherein the target information comprises at least one of the following: the number of users N, the number of items M, the total number of ratings, and the target value is positively correlated with the value in the target information; and determining the dimension number of the features in the user feature vector according to the target value, wherein the target value is positively correlated with the dimension number.
[0049] Optionally, the target recommendation system can determine the dimension number k of the features in the user feature vector according to the size and complexity of the data set, for example, the calculation formula of k can be as follows:
[0050] k=min(max(c1 log(x+c2),k min ),k max )
[0051] wherein c1 is a proportional constant for controlling the speed of growth, c2 is an offset for ensuring that log(x+c2) is still positive in the case of small data volume, k min is the minimum value of the dimension number, k max is the maximum value of the dimension number, and x represents the target value.
[0052] Optionally, the target value can be measured according to the total number of users (i.e., the number of users N), the total number of items (i.e., the number of items M), and the total number of ratings. For example, the target recommendation system has a preset mapping relationship between the value in the target information and the target value, and one optional mapping relationship can be "add 1 to the target value when the number of users is in the interval (10, 100)", and the initial value of the target value can be 0, so that the target recommendation system can determine the target value according to the mapping relationship and the target information. For example, a specific calculation formula of k can be as follows:
[0053] k=min(max(5log(x+1),5),50)
[0054] It should be noted that through the above process, the dimension number of the features in the user feature vector is dynamically adjusted according to the data volume that the target recommendation system needs to process, and by setting the dimension number to grow with the increase of the data volume and to decrease with the decrease of the data volume, not only the unnecessary computational load and processing time are effectively reduced, the efficiency of the system is improved, but also when the data set grows, the user preferences can be captured more finely, the expression ability of the user features is enhanced, and thus the accuracy of the recommendation algorithm is significantly improved. This flexible mechanism according to the data size enables the recommendation system to maintain high performance when facing massive data, and provides more personalized and accurate services for users.
[0055] In an optional embodiment, in the process of updating the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix based on the matrix decomposition method, the target recommendation system can calculate a loss value according to the preset target function, the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix, and then update the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix by using the gradient descent method in the case that the loss value is greater than a target threshold, so as to repeatedly execute the step of calculating the loss value according to the preset target function, the user feature matrix, the latent vector matrix and the item feature matrix until the loss value is less than or equal to the target threshold, and it is determined that the iteration of the matrix decomposition method meets the preset iteration condition.
[0056] An optional target function can be as follows:
[0057]
[0058] wherein Ω is a set of known ratings, r ui is an element in the rating matrix, indicating the rating of the user u to the item i, U u is the user feature vector of the user u in the initial user feature matrix U, I i is the item feature vector of the item i in the initial item feature matrix I, V is the initial latent vector matrix, and λ is a regularization parameter. By introducing an L2 regularization term in the target function, overfitting can be prevented. L2 regularization limits the model complexity by imposing a penalty term on the model parameters.
[0059] Optionally, the target processing system can calculate the loss value based on the above calculation formula, so as to update the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix by using the gradient descent method in the case that the loss value is greater than a target threshold, so as to obtain the user feature matrix, the latent vector matrix and the item feature matrix.
[0060] After the user feature matrix, the latent vector matrix and the item feature matrix are determined, the target recommendation system can calculate a new loss value according to the preset target function, the user feature matrix, the latent vector matrix and the item feature matrix, and continue to update the user feature matrix, the latent vector matrix and the item feature matrix by using the gradient descent method in the case that the new loss value is greater than a target threshold, so as to constantly iterate until the loss value is less than or equal to the target threshold, and it is determined that the iteration of the matrix decomposition method meets the preset iteration condition.
[0061] In some embodiments, other optimization algorithms can also be used instead of the gradient descent method.
[0062] It should be noted that through the above process, the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix are effectively updated, so that the accuracy of the ratings of each user to all items in the M items determined subsequently can be improved, and then the recommendation accuracy is improved.
[0063] In an optional embodiment, in the process of updating the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix by using the gradient descent method to obtain the user feature matrix, the latent vector matrix and the item feature matrix, the target recommendation system can determine N*M user-item pairs based on the N users and the M items, and then for each user-item pair, calculate the prediction error value corresponding to the user-item pair according to the rating matrix, the initial item feature matrix, the user feature vector associated with the user-item pair and the item feature vector associated with the user-item pair, so as to update the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix according to the prediction error value to obtain the user feature matrix, the latent vector matrix and the item feature matrix.
[0064] Optionally, a user-item pair includes one user and one item.
[0065] For example, an optional prediction error value calculation formula is as follows:
[0066] e ui =r ui -(U u ·V·I i T )
[0067] Wherein, e ui represents the prediction error value corresponding to the user-item pair composed of the user u and the item i, r ui is an element in the rating matrix, indicating the rating of the user u to the item i, U u is the user feature vector of the user u in the initial user feature matrix U, I i is the item feature vector of the item i in the initial item feature matrix I, and V is the initial latent vector matrix.
[0068] Optionally, the user feature vector associated with the user-item pair refers to the user feature vector of the user in the user-item pair, and the item feature vector associated with the user-item pair refers to the item feature vector of the item in the user-item pair.
[0069] In some embodiments, after the prediction error values of the user-item pairs are determined, the target recommendation system can select target user-item pairs from all the user-item pairs according to the rating matrix, wherein the target user-item pairs refer to the user-item pairs corresponding to the ratings (i.e. non-zero ratings) in the rating matrix. Then, the target processing system can update the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix according to the prediction error values of the target user-item pairs to obtain the user feature matrix, the latent vector matrix and the item feature matrix.
[0070] It should be noted that by updating the initial matrices according to the prediction error values of the user-item pairs, the updating accuracy can be further improved, thereby improving the recommendation accuracy.
[0071] In an alternative embodiment, in the process of updating the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix according to the prediction error values to obtain the user feature matrix, the latent vector matrix and the item feature matrix, the target recommendation system can update the user feature vectors in the initial user feature matrix according to the prediction error values of the user-item pairs associated with the user feature vectors to obtain the user feature matrix, update the initial latent vector matrix according to the prediction error values of the user-item pairs to obtain the latent vector matrix, and update the item feature vectors in the initial item feature matrix according to the prediction error values of the user-item pairs associated with the item feature vectors to obtain the item feature matrix.
[0072] Optionally, the target recommendation system can update the user feature vectors according to the following formula:
[0073]
[0074] wherein U u ′ denotes the updated user feature vector of user u, U u denotes the user feature vector of user u, a is the learning rate, e ui denotes the prediction error value corresponding to the user-item pair composed of user u and item i. The user-item pair associated with the user feature vector refers to the user-item pair including the target user, wherein the target user refers to the user to which the user feature vector belongs, and Ω is the set of known ratings, i.e. the set of target user-item pairs.
[0075] Optionally, after the updated user feature vectors of the users are obtained, the user feature matrix can be composed of the updated user feature vectors of the users.
[0076] Optionally, the target recommendation system can update the latent vector matrix according to the following formula:
[0077]
[0078] wherein V ′ denotes the updated latent vector matrix, and V denotes the latent vector matrix.
[0079] Optionally, the target recommendation system can update the item feature vector according to the following formula:
[0080]
[0081] wherein I i ′ denotes the updated item feature vector of item i, and I i denotes the item feature vector of item i, and the user-item pair associated with the item feature vector refers to the user-item pair including the target item, and the target item refers to the item to which the item feature vector belongs.
[0082] Optionally, after obtaining the updated item feature vector of each item, the target recommendation system can form an item feature matrix composed of the updated item feature vector of each item.
[0083] In some embodiments, during the iteration process of matrix decomposition, the target recommendation system can use the AdaGrad optimizer to update the parameters, and the AdaGrad optimizer is an adaptive learning rate optimizer that can dynamically adjust the learning rate according to historical gradient information, so that each parameter has a different learning rate. Specifically, the AdaGrad maintains a cumulative sum of the square of the gradient to adjust the learning rate. In some embodiments, the system can also attach a timestamp to each user-item pair based on the rating time of the user-item pair, and calculate a time weight factor ω(t) for the timestamp, which is multiplied when updating the vector to better capture the change of user interest over time.
[0084] It should be noted that through the above process, the update of each user feature vector and each item feature vector is targeted, so as to further improve the update accuracy and thus improve the accuracy of item recommendation.
[0085] In an optional embodiment, in the process of determining the predicted ratings of all items in the M items by each user according to the updated user feature matrix, latent vector matrix and item feature matrix, the target recommendation system can multiply the user feature matrix and the latent vector matrix to obtain a first matrix, multiply the first matrix and the transpose matrix of the item feature matrix to obtain a target rating matrix, wherein the target rating matrix includes the predicted ratings of all items in the M items by each user.
[0086] For example, the target recommendation system can calculate the target rating matrix according to the following formula:
[0087]
[0088] wherein, represents a target score matrix, U" represents a user feature matrix obtained after the last update, V" represents an implicit vector matrix obtained after the last update, I" represents an item feature matrix obtained after the last update, I" represents a transposed matrix of I", and U"·V" is equivalent to the first matrix described above. Each element in the target score matrix T represents a predicted score of the user u to the item i. represents a predicted score of the user u to the item i.
[0089] It should be noted that through the above process, the predicted scores of each user to all items in the M items are accurately determined.
[0090] In an alternative embodiment, in the process of determining the to-be-recommended items corresponding to the N users respectively according to the predicted scores, the target recommendation system can determine, for each user, the un-scored items associated with the user according to the score matrix, obtain a plurality of target un-scored items, determine the predicted scores of the user to the plurality of target un-scored items according to the target score matrix, and then determine the to-be-recommended items corresponding to the user from the plurality of target un-scored items according to the predicted scores of the plurality of target un-scored items, so as to obtain the to-be-recommended items corresponding to the N users respectively.
[0091] Optionally, for each user, the target recommendation system can determine the elements with a value of 0 in the score matrix corresponding to the user as the un-scored items of the user, thereby obtaining a plurality of target un-scored items. Then, the target recommendation system can determine the predicted scores of the user to the plurality of target un-scored items according to the target score matrix.
[0092] Optionally, after determining the predicted scores of the user to the plurality of target un-scored items, the target recommendation system can sort the target un-scored items in descending order of the predicted scores, and then determine the target un-scored items ranked in the top E as the to-be-recommended items.
[0093] It should be noted that through the above process, the to-be-recommended items are accurately determined, thereby improving the recommendation accuracy. In addition, by recommending the un-scored items to the user, the recommendation effect can be further improved.
[0094] In an alternative embodiment, Figure 2 is a flow of an alternative item recommendation method according to an embodiment of the present application Figure 2 , according to Figure 2 An alternative application process of the present embodiment is described. Optionally, the target recommendation system can include a data preprocessing module, a model initialization module, an implicit vector optimization module, a recommendation generation module, and a performance evaluation module, such as Figure 3As shown, the target recommendation system can collect and clean the user rating data through the data preprocessing module, and then build a rating matrix. Then, the model initialization module calculates the dimension number k, and randomly generates an initial user feature matrix, an initial latent vector matrix and an initial item feature matrix. Then, the latent vector optimization module updates the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix by using the gradient descent method, until the preset iteration condition is met. In this case, the recommendation generation module generates a target rating matrix according to the updated user feature matrix, latent vector matrix and item feature matrix, thereby determining the recommended items. Optionally, the functions of the aforementioned performance evaluation module include evaluation index calculation and model parameter adjustment. The target recommendation system can use standard evaluation indexes to quantitatively analyze the performance of the model. For example, the difference between the recommended rating and the true rating is calculated to measure the prediction accuracy, the absolute difference between the recommended rating and the true rating is calculated to measure the prediction stability, and the proportion of truly relevant items in the total relevant items in the recommended list is calculated, so that the system adjusts the latent vector dimension k, the learning rate a, the regularization parameter l, etc. according to the evaluation results to further optimize the recommendation effect.
[0095] Therefore, the scheme provided in the application achieves the purpose of recommending items to users based on information in multiple dimensions in matrix decomposition, thereby achieving the technical effect of improving recommendation accuracy, and further solving the technical problem of low recommendation accuracy in recommending items to users based on matrix decomposition in the related art.
[0096] Embodiment 2
[0097] According to an embodiment of the application, an embodiment of an item recommendation device is provided, wherein, Figure 3 is a schematic diagram of an optional item recommendation device according to an embodiment of the application, as Figure 4 shown, the device comprises:
[0098] The acquisition module 301 is configured to acquire ratings of at least part of the M items by each user in the N users, and construct a rating matrix according to the ratings, wherein a single element in the rating matrix represents the rating of a single item by a single user.
[0099] The generation module 302 is configured to randomly generate an initial user feature matrix, an initial latent vector matrix and an initial item feature matrix, wherein the initial user feature matrix comprises user feature vectors of each user, the initial item feature matrix comprises item feature vectors of each item, and the initial latent vector matrix is used to represent the association between the features in the user feature vectors and the features in the item feature vectors.
[0100] The processing module 303 is configured to update the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix based on the matrix decomposition method, and determine predicted scores of all items in the M items for each user according to the updated user feature matrix, the latent vector matrix and the item feature matrix in a case where iteration of the matrix decomposition method meets a preset iteration condition, and determine the to-be-recommended items corresponding to the N users respectively according to the predicted scores, and recommend the to-be-recommended items to the N users.
[0101] It should be noted that the obtaining module 301, the generating module 302 and the processing module 303 correspond to steps S101 to S103 in the above embodiment, and the three modules have the same examples and application scenarios as the corresponding steps, but are not limited to the content disclosed in the above embodiment 1.
[0102] Optionally, the item recommendation apparatus further includes a first determining module configured to determine a target value according to target information, wherein the target information includes at least one of the following: a user quantity of the N users, a quantity of the M items, a total number of scores of the N users, and the target value is positively correlated with the values in the target information; and a second determining module configured to determine a dimension quantity of features in the user feature vector according to the target value, wherein the target value is positively correlated with the dimension quantity.
[0103] Optionally, the processing module further includes a calculation sub-module configured to calculate a loss value according to a preset target function, the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix; an updating sub-module configured to update the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix by using a gradient descent method in a case where the loss value is greater than a target threshold value, to obtain the user feature matrix, the latent vector matrix and the item feature matrix; and a first processing sub-module configured to repeatedly perform the step of calculating the loss value according to the preset target function, the user feature matrix, the latent vector matrix and the item feature matrix until the loss value is less than or equal to the target threshold value, to determine that the iteration of the matrix decomposition method meets the preset iteration condition.
[0104] Optionally, the updating sub-module further includes a determining unit configured to determine N*M user-item pairs based on the N users and the M items; a calculation unit configured to calculate, for each user-item pair, a predicted error value corresponding to the user-item pair according to the rating matrix, the initial item feature matrix, a user feature vector associated with the user-item pair and an item feature vector associated with the user-item pair; and an updating unit configured to update the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix according to the predicted error value, to obtain the user feature matrix, the latent vector matrix and the item feature matrix.
[0105] Optionally, the updating unit further comprises: a first updating subunit, configured to update the user feature vector according to the prediction error value of the user-item pair associated with the user feature vector in the initial user feature matrix, to obtain the user feature matrix; a second updating subunit, configured to update the initial hidden vector matrix according to the prediction error value of the user-item pair, to obtain the hidden vector matrix; and a third updating subunit, configured to update the item feature vector according to the prediction error value of the user-item pair associated with the item feature vector in the initial item feature matrix, to obtain the item feature matrix.
[0106] Optionally, the processing module further comprises: a second processing sub-module, configured to multiply the user feature matrix and the hidden vector matrix to obtain a first matrix; and a third processing sub-module, configured to multiply the first matrix and the transposed matrix of the item feature matrix to obtain the target score matrix, wherein the target score matrix comprises the predicted scores of all the items in the M items for each user.
[0107] Optionally, the processing module further comprises: a first determining sub-module, configured to determine, for each user, the un-scored items associated with the user according to the score matrix, to obtain a plurality of target un-scored items; a second determining sub-module, configured to determine the predicted scores of the plurality of target un-scored items for the user according to the target score matrix; and a third determining sub-module, configured to determine the to-be-recommended items corresponding to the user from the plurality of target un-scored items according to the predicted scores of the plurality of target un-scored items, to obtain the to-be-recommended items corresponding to the N users respectively.
[0108] Embodiment 3
[0109] According to another aspect of the embodiments of the present application, a computer readable storage medium is further provided, and the computer readable storage medium stores a computer program, wherein the computer program is configured to execute the item recommendation method when running.
[0110] Embodiment 4
[0111] According to another aspect of the embodiments of the present application, an electronic device is further provided, and the electronic device comprises: Figure 4 is a schematic diagram of an optional electronic device according to the embodiments of the present application, as shown, the electronic device comprises one or more processors; a memory configured to store one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement a program for running, wherein the program is configured to execute the item recommendation method when running.
[0112] The above-mentioned serial numbers of the embodiments of the present application are only for description, and do not represent the advantages and disadvantages of the embodiments.
[0113] In the above-mentioned embodiments of the present application, the description of each embodiment is focused on, and the part not described in detail in a certain embodiment can be referred to the relevant description of other embodiments.
[0114] In several embodiments provided in the present application, it should be understood that the disclosed technical content can be implemented by other ways. Among them, the above-mentioned device embodiments are only schematic, for example, the division of units can be a logical function division, and actual implementation can have another division way, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units or modules shown or discussed can be indirect coupling or communication connection through some interfaces, and can be electrical or other forms.
[0115] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed to multiple units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0116] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The above integrated unit can be realized in the form of hardware or in the form of software functional unit.
[0117] If the integrated unit is realized in the form of software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the part of the prior art or the whole or part of the technical solutions can be embodied in the form of software product, and the computer software product is stored in a storage medium, including a plurality of instructions to make a computer device (which can be a personal computer, a server or a network device, etc.) execute all or part of the steps of the embodiments of the present application. The foregoing storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and various program codes can be stored in the medium.
[0118] The above is only the preferred embodiment of the present application, and it should be pointed out that for ordinary skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, and these improvements and refinements should be regarded as the protection scope of the present application.
Claims
1. A project recommendation method characterized by comprising: The method comprises the following steps: obtaining scores of each user in N users on at least part of M items, and constructing a score matrix according to the scores, wherein a single element in the score matrix represents the score of a single user on a single item; randomly generating an initial user feature matrix, an initial latent vector matrix and an initial item feature matrix, wherein the initial user feature matrix comprises user feature vectors of each user, the initial item feature matrix comprises item feature vectors of each item, and the initial latent vector matrix is used to represent the association between features in the user feature vectors and features in the item feature vectors, wherein the size of the initial user feature matrix is M*k; updating the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix based on a matrix decomposition method, and determining the predicted scores of each user on all the M items according to the updated user feature matrix, latent vector matrix and item feature matrix when the iteration of the matrix decomposition method meets the preset iteration condition, and determining the to-be-recommended items corresponding to the N users respectively according to the predicted scores, and recommending the to-be-recommended items to the N users, wherein the initial user feature matrix and the initial item feature matrix are updated based on the complete information in the initial latent vector matrix; wherein the dimension number k of the features in the user feature vectors is determined in the following way: determining a target value according to target information, wherein the target information comprises the number of users, the number of items, and the total number of scores of the N users, and the target value is positively correlated with the values in the target information; determining the dimension number of the features in the user feature vectors according to the target value, wherein the target value is positively correlated with the dimension number; the calculation formula of the dimension number k is: ; wherein, is a proportionality constant for controlling the speed of growth, is an offset for making is kept positive, is the minimum value of the number of dimensions, is the maximum value of the number of dimensions, and x represents the target value.
2. The method of claim 1, wherein, updating the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix based on a matrix decomposition method comprises: calculating a loss value according to a preset objective function, the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix; updating the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix by using a gradient descent method when the loss value is greater than a target threshold, to obtain a user feature matrix, a latent vector matrix and an item feature matrix; repeating the step of calculating a loss value according to a preset objective function, the user feature matrix, the latent vector matrix and the item feature matrix until the loss value is less than or equal to the target threshold, to determine that the iteration of the matrix decomposition method meets the preset iteration condition.
3. The method of claim 2, wherein, updating the initial user feature matrix, the initial latent vector matrix and the initial item feature matrix by using a gradient descent method to obtain a user feature matrix, a latent vector matrix and an item feature matrix comprises: determining N*M user-item pairs based on the N users and the M items; For each user-item pair, a prediction error value corresponding to the user-item pair is calculated according to the rating matrix, the initial item feature matrix, a user feature vector associated with the user-item pair, and an item feature vector associated with the user-item pair; The initial user feature matrix, the initial latent vector matrix, and the initial item feature matrix are updated according to the prediction error value to obtain the user feature matrix, the latent vector matrix, and the item feature matrix.
4. The method of claim 3, wherein, The initial user feature matrix, the initial latent vector matrix, and the initial item feature matrix are updated according to the prediction error value to obtain the user feature matrix, the latent vector matrix, and the item feature matrix, including: The user feature vector in the initial user feature matrix is updated according to the prediction error value of the user-item pair associated with the user feature vector to obtain the user feature matrix; The initial latent vector matrix is updated according to the prediction error value of the user-item pair to obtain the latent vector matrix; The item feature vector in the initial item feature matrix is updated according to the prediction error value of the user-item pair associated with the item feature vector to obtain the item feature matrix.
5. The method of claim 1, wherein, The prediction ratings of all items in the M items by each user are determined according to the updated user feature matrix, latent vector matrix, and item feature matrix, including: The user feature matrix and the latent vector matrix are multiplied to obtain a first matrix; The first matrix and the transpose matrix of the item feature matrix are multiplied to obtain a target rating matrix, wherein the target rating matrix includes the prediction ratings of all items in the M items by each user.
6. The method of claim 5, wherein, The to-be-recommended items corresponding to the N users are determined according to the prediction ratings, including: For each user, the un-rated items associated with the user are determined according to the rating matrix to obtain a plurality of target un-rated items; The prediction ratings of the plurality of target un-rated items by the user are determined according to the target rating matrix; The to-be-recommended items corresponding to the user are determined from the plurality of target un-rated items according to the prediction ratings of the plurality of target un-rated items, to obtain the to-be-recommended items corresponding to the N users.
7. An item recommendation device characterized by comprising: including: An acquisition module is configured to acquire ratings of at least part of M items by each user in N users, and construct a rating matrix according to the ratings, wherein a single element in the rating matrix represents a rating of a single item by a single user; An generation module is configured to randomly generate an initial user feature matrix, an initial latent vector matrix, and an initial item feature matrix, wherein the initial user feature matrix includes user feature vectors of the users, the initial item feature matrix includes item feature vectors of the items, and the initial latent vector matrix is used to represent an association relationship between features in the user feature vectors and features in the item feature vectors, wherein a size of the initial user feature matrix is M×k; The processing module is configured to update the initial user feature matrix, the initial latent vector matrix, and the initial item feature matrix based on a matrix decomposition method, and determine a predicted score of each user for all items in the M items according to the updated user feature matrix, latent vector matrix, and item feature matrix in a case where an iteration of the matrix decomposition method meets a preset iteration condition, and determine the to-be-recommended items corresponding to the N users respectively according to the predicted score, and recommend the to-be-recommended items to the N users, wherein the initial user feature matrix and the initial item feature matrix are updated based on complete information in the initial latent vector matrix; The item recommendation apparatus further includes: A first determination module configured to determine a target value according to target information, wherein the target information includes a user quantity of the N users, an item quantity of the M items, and a total number of scores of the N users, and the target value is positively correlated with the values in the target information; A second determination module configured to determine a dimension quantity k of a feature in the user feature vector according to the target value, wherein the target value is positively correlated with the dimension quantity; A calculation formula of the dimension quantity k is: ; wherein, is a proportionality constant for controlling the speed of growth, is an offset for making is kept positive, is the minimum value of the number of dimensions, is the maximum value of the number of dimensions, and x represents the target value.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is configured to execute the item recommendation method in any one of claims 1 to 6 when running.
9. An electronic device, comprising: The electronic device includes one or more processors; A memory is configured to store one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement a program for running, wherein the program is configured to execute the item recommendation method in any one of claims 1 to 6 when running.
Citation Information
Patent Citations
Matrix decomposition recommendation method based on user preference
CN108960966A
Cold start recommendation algorithm based on implicit factor prediction
CN113987363A