A real-time movie recommendation method based on ALS and collaborative filtering

By improving the calculation of movie similarity and user interest considerations, combining ALS and collaborative filtering algorithms, and dynamically adjusting the movie recommendation list, the problems of accuracy and interest changes in real-time recommendations are solved, and the accuracy of movie recommendations and user experience are improved.

CN117150080BActive Publication Date: 2025-09-05ANHUI NORMAL UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202311066986.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-23
Publication Date
2025-09-05
Estimated Expiration
2043-08-23

AI Technical Summary

Technical Problem

Existing movie recommendation algorithms are difficult to simultaneously meet the requirements of accuracy and user interest changes in real-time recommendations. In particular, collaborative filtering algorithms have the problem of mining few hidden user features and sparse data, resulting in poor recommendation results.

Method used

A hybrid recommendation method based on ALS and collaborative filtering is adopted. By improving the movie similarity calculation, combining user historical behavior and the characteristics of the movie itself, the list of alternative movies is dynamically adjusted, and changes in user interests are taken into account. The Ebbinghaus forgetting curve is used to set the time threshold to improve the recommendation accuracy.

Benefits of technology

It improves the accuracy and user experience of real-time movie recommendations, solves the recommendation errors caused by changes in user interests, ensures that the recommendation results are in line with the user's recent interests, and improves the recall rate and precision rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117150080B_ABST
    Figure CN117150080B_ABST
Patent Text Reader

Abstract

The present invention discloses a real-time movie recommendation method based on ALS and collaborative filtering, comprising: S1, obtaining a movie feature matrix and a user feature matrix through ALS algorithm training; S2, constructing a movie similarity matrix; S3, after the user has watched a movie, using the movie familiarity matrix to dynamically adjust the list of candidate movies, and then using a preference algorithm that takes into account the changes in user interests to calculate the user's preference for the movies in the candidate movie list, to obtain a candidate movie list containing the preference; S4, based on the user's preference for the movie, merging and updating the last recommended movie list and the candidate movie list containing the preference, ultimately generating a new movie recommendation list and directly pushing it to the target user. By improving the calculation of item similarity, the present invention can improve the recommendation accuracy of the ItemCF algorithm in a real-time movie recommendation system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence recommendation, and in particular to a real-time movie recommendation method based on ALS and collaborative filtering. Background Art

[0002] In today's era of rapid technological advancement, the internet industry is flourishing. As people gain a deeper understanding of the internet and use it more frequently, data generation across various industries is exponentially increasing, ushering in the era of big data. As of June 2021, the number of online video users (including short videos) in my country reached 944 million, an increase of 17.07 million from December 2020, accounting for 93.4% of the total internet population. The rapid development of the internet has led to a continuous increase in the number of films, resulting in a vast amount of film data, making it difficult for users to quickly find films that suit their interests.

[0003] Faced with the challenge of information overload and the limitations of traditional solutions, recommendation systems have emerged. The rise of deep learning in recent years has taken the research of recommendation algorithms a step further, making the models more complex but the recommendations more accurate. Although algorithms have become more efficient, each recommendation algorithm has its own specific application scope and each has its own advantages and disadvantages. This inevitably means that in certain specific environments, the recommendations of a single model cannot meet user needs. For example, the collaborative filtering algorithm is a classic recommendation algorithm that mines and analyzes data based on the user's historical behavior records to discover the user's interests and hobbies and make recommendations. However, the collaborative filtering recommendation algorithm has the problem of mining few hidden features of users and data sparsity. Therefore, in order to improve personalized recommendations, more and more movie platforms are adopting hybrid recommendation strategies to cope with the challenges brought by different scenarios. For example, patent document CN116049377A discloses a method that combines convolutional neural networks and recurrent neural networks. The method uses a combination of convolutional neural networks and recurrent neural networks to obtain a highly representative project feature vector, which is then combined with probability matrix decomposition to find the optimal similar user-item rating matrix, improve the accuracy of recommendations, and reduce the loss rate.

[0004] Movie recommendation systems are generally divided into offline and real-time recommendation systems. The design of the real-time recommendation component must meet two requirements: first, an effective recommendation strategy. Recommendation results are pushed to users for display, and movie recommendations serve the user, so the recommendation effect must be efficient. Second, the real-time nature of the recommendations. Real-time recommendations require timely feedback on users' movie viewing and evaluation behavior. If complex offline models are used for calculation, the user wait time for responses will be significantly longer, giving the user the illusion of no change, and thus impairing the real-time recommendation experience. In the movie recommendation scenario, the number of movies is far smaller than the number of users, and the movie data is relatively stable. Furthermore, the actual recommendation model should not be overly complex and should deliver recommendations quickly. Therefore, item-based collaborative filtering algorithms are generally used in real-time recommendations. Item-based collaborative filtering algorithms are a common and intuitive algorithm in recommendation systems, and they meet the high efficiency requirements of real-time recommendations. For example, Peng Yu (2022) proposed the use of item-based collaborative filtering algorithm (ItemCF) in short video recommendation (Research and Implementation of Short Video Recommendation System Based on Improved LFM Algorithm). In order to meet the real-time recommendation requirements, the item-based collaborative filtering algorithm was combined with the LFM algorithm to realize the recommendation of short videos.

[0005] In real life, people's interests in external things change with their living environment, interpersonal relationships, job nature, and age. If a user's interests change over time, this can increase the error in recommendation results. Therefore, it's important to consider user interests; otherwise, recommendation algorithms won't be able to accurately adapt to changes in user interests. Therefore, accuracy must be considered while also fully accounting for changes in user interests. Currently, no recommendation algorithm can simultaneously account for both accuracy and interest changes. Summary of the Invention

[0006] The purpose of the present invention is to overcome the shortcomings of the existing technology and provide a real-time movie recommendation method based on ALS and collaborative filtering. By improving the calculation of movie similarity, the recommendation accuracy of the ItemCF algorithm in the real-time movie recommendation system can be improved, and the user experience is improved by taking into account the changes in user interests.

[0007] To achieve the above objectives, the present invention adopts a technical solution: a real-time movie recommendation method based on ALS and collaborative filtering, comprising:

[0008] S1. Obtain the original user rating data, construct the user-movie rating matrix, and obtain the movie feature matrix and user feature matrix through ALS algorithm training;

[0009] S2. The movie similarity is calculated by fusing the user-movie rating matrix and the movie feature matrix. Finally, the similarity between all two movies is obtained to construct a movie similarity matrix.

[0010] S3. After the user has watched a movie, the movie similarity matrix is ​​used to dynamically adjust the candidate movie list. Then, a preference algorithm that takes into account the user's interest changes is used to calculate the user's preference for the movies in the candidate movie list, and a candidate movie list including the preference is obtained.

[0011] S4. Based on the user's preference for movies, the last recommended movie list and the list of alternative movies including the preference are merged and updated, and finally a new movie recommendation list is generated and pushed directly to the target user.

[0012] Step S1 includes: using the ALS algorithm to mine the implicit features of users and movies, using matrix decomposition to solve the sparsity of the rating matrix, decomposing the rating matrix into the form of multiplication of two low-order matrices, and generating a user feature matrix and a movie feature matrix.

[0013] Step S1 includes:

[0014] S1.1: Based on the user's original rating data, construct a user-movie rating matrix A. The shape of matrix A is a co-occurrence matrix of the number of users multiplied by the number of movies.

[0015] S1.2: Randomly initialize the user feature matrix P and the movie feature matrix Q; where the P matrix shape is the number of users * k; the Q matrix shape is the number of movies * k;

[0016] Then the global objective function is:

[0017] A=P·Q T

[0018] The formula for predicting the rating of a single user u and a single movie i is:

[0019]

[0020] S1.3: Compare the true rating of user u to movie i in the training data with the corresponding p u and q i The value obtained by dot multiplication establishes the squared difference loss function; the definition of this loss function is to make the square of the difference between the product of the movie vector and the user vector and the original rating as small as possible, so that the product of the user matrix and the movie matrix is ​​as close as possible to the original rating matrix;

[0021] Among them, r u,i represents the true rating of user u for movie i, represents the algorithm’s prediction of user u’s rating for movie i, A represents the user-movie rating matrix, and p u represents the implicit feature factor vector of user u, q i is the implicit feature factor vector of movie i; λ represents the regularization coefficient used to prevent overfitting of the model;

[0022] S1.4: Use gradient descent to optimize the loss function. The parameters trained in the optimization process are the user feature matrix P and the movie feature matrix Q, that is, the latent vectors of all users and all movies. Use gradient descent to iteratively update the latent vectors of users and all movies, and calculate their partial derivatives. The formula is as follows:

[0023]

[0024] where p u represents the implicit feature factor vector of user u, q i is the implicit feature factor vector of movie i, λ represents the regularization coefficient used to prevent overfitting of the model, r u,i represents the true rating of user u on movie i;

[0025] S1.5: When the error value of the loss function drops to the set value or reaches the number of iterations, the trained user feature matrix P and movie feature matrix Q are output.

[0026] Step S2 includes:

[0027] S2.1: Calculate the similarity between movies in the user-movie rating matrix using cosine similarity;

[0028]

[0029] where r ui and r uj Represents the ratings of user u on movies i and j, U ij represents the set of users who like both movies i and j;

[0030] S2.2: The movie feature matrix Q obtained by training the ALS algorithm: the number of rows in the matrix is ​​the number of movies, and the number of columns is the dimension k of the movie's implicit features. The cosine similarity is used to calculate the movie similarity in the movie feature matrix;

[0031] S2.3: The movie similarity obtained based on the user's historical viewing behavior and the movie's own characteristics is weighted and integrated to obtain the final item similarity, which can be expressed as:

[0032] new_sim(i,j)=αsim1(i,j)+(1-α)sim2(i,j);

[0033] Where i and j represent the movies used to calculate similarity, α represents the weight of calculating movie similarity based on the user's historical viewing behavior using the original user-movie rating matrix, and 1-α represents the movie feature matrix trained using the ALS algorithm, which is used to calculate the weight of movie familiarity based on the movie's own features.

[0034] Step 2.4: Calculate the similarity matrix between all movies in the offline stage, and quickly get a list of similar movies when watching a movie in real-time recommendation.

[0035] Step S3 includes:

[0036] S3.1: After a user watches a movie, the movie similarity matrix calculated in S2 is used to dynamically adjust the list of candidate movies based on the user's rating. When the rating is low, a few similar movies to the current movie are selected. The remaining similar movies are obtained from the most recently rated movies with the highest rating. These are dynamically combined to form the list of candidate recommended movies. The formula for the candidate movie recommendation list PreList is:

[0037]

[0038] Where N is the number of candidate movies, the user's rating is 1-5 points, r represents the user's rating of the movie they just watched, and M is the number of similar movies to the highest-rated movie in the recent ratings;

[0039] S3.2: Get the user's most recent S movie ratings;

[0040] S3.3: Calculate the user's preference for the candidate movies using a real-time recommendation algorithm. Compare the N movies in the candidate list with the movies rated by the user most recently S times to calculate the user's preference. To ensure the timeliness of the recommendation, the user's interest changes are incorporated into the calculation of the user's preference.

[0041] S3.4: According to the likeability calculation rule that takes into account the change of user interests, the likeability of the movies in the candidate movie list is calculated to obtain the candidate movie list including the likeability.

[0042] Step S4 includes:

[0043] S4.1: Get the last movie recommendation list OldList, which has N movies in size;

[0044] S4.2: Get the candidate movie list PreList from S3, which has a size of N movies;

[0045] S4.3: Merge the previous movie recommendation list OldList and the candidate movie list PreList, sort them by popularity, select the top N movies as the movie recommendation list NewList, and push the movies in the movie recommendation list NewList to the user.

[0046] In step S3.3, movies are recommended based on the user's recent rating records. The movie ratings given by users are stored in the database. Then, based on the current movie, similar movies are selected as the list of movies to be recommended. The similarity with the recently rated movies is calculated, and then multiplied by the movie rating and summed up. The result is the recommended predicted rating, which represents the user's preference:

[0047]

[0048] Like is the predicted score for each similar candidate movie, indicating the user's preference for the movie. S is the list of recently rated movies, p is a movie in the rated list, q is a movie in the candidate movie list, and Sp represents the user's rating of each movie in the recently rated movie list. n is the total number of recently rated movies; incount represents the number of recently rated movies with high similarity scores, and decount represents the number of recently rated movies with low similarity scores.

[0049] When calculating the likeability, the change of user interest over time is taken into account, and the forgetting function is introduced to correct Sp. Definition: In the forgetting function, the time from the recognition to the forgetting of half of the information is defined as the information half-life T0, and the decay factor is defined Then for the current time t n The forgetting curve can be expressed as:

[0050]

[0051] t n is the current time of the system, and t0 is the user's rating time;

[0052] Set the threshold TL of the scoring time from the current time, and the revised score Sp is:

[0053]

[0054] The advantages of the present invention are: by improving the calculation of item similarity, the recommendation accuracy of the ItemCF algorithm in the real-time movie recommendation system can be improved, and the user experience is improved by taking into account changes in user interests. The use of ALS and ItemCF for mixing solves the sparsity problem of the user-movie rating matrix, improves the movie similarity calculation formula, and uses the movie rating matrix calculated by ALS and the original user-movie to calculate the similarity between movies, changing the traditional method of using only user-movie ratings to calculate similarity. Ultimately, the accuracy of real-time movie recommendations is greatly improved while ensuring the recall rate. When calculating the user's preference for a movie, the user's interest changes are taken into account, the time factor is incorporated, and in order to better explore the user's recent interest in watching movies, a time threshold is set to make better real-time recommendations. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] The following is a brief description of the contents and symbols in the drawings of the present invention:

[0056] Figure 1 1 is a flowchart of a real-time movie recommendation method based on ALS and collaborative filtering according to the present invention;

[0057] Figure 2 It is the ALS algorithm training optimization flow chart in the present invention;

[0058] Figure 3 This is a flow chart of the present invention for calculating a user's preference for a movie. DETAILED DESCRIPTION

[0059] The specific implementation of the present invention will be further explained in detail below by describing the best embodiment with reference to the accompanying drawings.

[0060] Real-time movie recommendations require both algorithm accuracy and real-time performance. In movie recommendation scenarios, since each user only rates a small number of movies, the user's movie rating matrix is ​​very sparse. To address this data sparsity, this paper employs the ALS model. The core of the ALS algorithm is matrix factorization. This type of algorithm typically achieves high prediction accuracy. Its main idea is to reduce the dimensionality of the large and sparse rating matrix and then achieve prediction by filling the user-item matrix. However, the predicted rating matrix obtained by ALS must continuously approximate the user's actual ratings of the items, requiring multiple iterations to obtain more accurate results. Therefore, the ALS algorithm takes a long time to obtain a good prediction result, making it incapable of real-time recommendations. Currently, item-based collaborative filtering algorithms are commonly used in real-time recommendations. To address the ALS algorithm's inability to make real-time recommendations while maintaining its accuracy, this paper combines the ItemCF algorithm with the ALS algorithm and improves its accuracy. Furthermore, in real-time movie recommendations, more attention is paid to recent changes in user interests. However, this method is used in offline recommendation scenarios and does not consider the timeliness of real-time recommendations. In view of this, in the hybrid model of the ItemCF algorithm and the ALS algorithm, the present invention takes into account both the movie feature matrix model decomposed by the ALS algorithm and the original user-movie rating matrix when calculating movie similarity, and weights and fuses the item similarities obtained based on the user's historical behavior and the characteristics of the movie itself. In real-time recommendations, the changes in user interests are taken into account, and the Ebbinghaus forgetting curve is selected as the interest forgetting function. The timeliness of real-time recommendations is considered, and a time threshold is set at the same time. This ensures the real-time nature of real-time movie recommendations while also ensuring the accuracy of the recommendations, thereby improving the effect of movie recommendations.

[0061] This paper adopts the ALS model. The core of the ALS algorithm is matrix decomposition. This type of algorithm usually has high prediction accuracy. Its main idea is to reduce the dimensionality of the large and sparse rating matrix and then achieve the purpose of prediction by filling the user-item matrix. However, the predicted rating matrix obtained by ALS needs to continuously approximate the actual rating of the user to the item, which requires multiple iterations to obtain more accurate results. Therefore, the ALS algorithm takes a long time to obtain a good prediction result and cannot achieve real-time recommendation. Currently, item-based collaborative filtering algorithms are often used in real-time recommendations. In order to solve the problem that the ALS algorithm cannot make real-time recommendations and retain the accuracy of the ALS algorithm, the present invention combines the ItemCF algorithm and the ALS algorithm and improves it in terms of accuracy. Then, in real-time movie recommendations, more attention is paid to the user's recent changes in interest. However, the above method is used in offline recommendation scenarios and does not consider the timeliness of real-time recommendations. In view of this, in the hybrid model of the ItemCF algorithm and the ALS algorithm, the present invention takes into account both the movie feature matrix model decomposed by the ALS algorithm and the original user-movie rating matrix when calculating movie similarity, and weights and fuses the item similarities obtained based on the user's historical behavior and the characteristics of the movie itself. In real-time recommendations, the changes in user interests are taken into account, and the Ebbinghaus forgetting curve is selected as the interest forgetting function. The timeliness of real-time recommendations is considered, and a time threshold is set at the same time. This ensures the real-time nature of real-time movie recommendations while also ensuring the accuracy of the recommendations, thereby improving the effect of movie recommendations.

[0062] This embodiment discloses a real-time movie recommendation method based on ALS and collaborative filtering. By improving the calculation of item similarity, the recommendation accuracy of the ItemCF algorithm in a real-time movie recommendation system can be improved. It also takes into account changes in user interests and improves the user experience.

[0063] like Figure 1 As shown, a real-time movie recommendation method based on ALS and collaborative filtering includes the following steps:

[0064] Step S1: Obtain the original user rating data, construct a user-movie rating matrix, and obtain the movie feature matrix and user feature matrix through ALS algorithm training.

[0065] Step S2: The movie similarity is calculated by fusing the user-movie rating matrix and the movie feature matrix. Finally, the similarity between all two movies is obtained to construct a movie similarity matrix.

[0066] Step S3: After the user has watched a movie, the movie similarity matrix is ​​used to dynamically adjust the candidate movie list based on the user's feedback. Then, a preference algorithm that takes into account the user's changing interests is used to calculate the user's preference for the movies in the candidate movie list, resulting in a candidate movie list with a preference score.

[0067] Step S4: Based on the user's preference for movies, the last recommended movie list and the alternative movie list are merged and updated, and finally a new movie recommendation list is generated and pushed directly to the target user.

[0068] In step S1, the ALS algorithm is used to mine the implicit features of users and movies. The main idea is matrix decomposition, which changes the sparsity of the user rating matrix and decomposes it into the form of multiplication of two low-order matrices to generate user feature matrix and movie feature matrix. Specifically:

[0069] Step 1.1: Based on the user's original rating data, construct the user-movie rating matrix A. The shape of the matrix A is a co-occurrence matrix of the number of users multiplied by the number of movies.

[0070] Step 1.2: Randomly initialize the user feature matrix P (shape is the number of users * k) and the movie feature matrix Q (shape is the number of movies * k).

[0071] Then the global objective function is:

[0072] A=P·Q T

[0073] The formula for predicting the rating of a single user u and a single movie i is:

[0074]

[0075] Step 1.3: Compare the real rating of user u to movie i in the training data with the corresponding p u and q i The value obtained by the dot product is used to establish the squared difference loss function. This loss function is defined to minimize the square of the difference between the product of the movie vector and the user vector and the original rating, hoping that the product of the user matrix and the movie matrix is ​​as close as possible to the original rating matrix.

[0076]

[0077] Among them, r u,i represents the true rating of user u for movie i, represents the algorithm’s prediction of user u’s rating for movie i, A represents the user-movie rating matrix, and p u represents the implicit feature factor vector of user u, q iis the latent feature factor vector of movie i. λ represents the regularization coefficient used to prevent overfitting of the model.

[0078] Step 1.4: Use gradient descent to optimize the loss function. The parameters to be trained in this process are the user feature matrix P and the movie feature matrix Q, which are the latent vectors of all users and all movies. Use gradient descent to iteratively update the latent vectors of all users and all movies. Next, calculate their partial derivatives, as shown in the following formula:

[0079] where p u represents the implicit feature factor vector of user u, q i is the implicit feature factor vector of movie i, λ represents the regularization coefficient used to prevent overfitting of the model, r u,i represents the true rating of user u for movie i.

[0080] Step 1.5: Finally, when the error value of the loss function drops to the set value or reaches the number of iterations, the trained user feature matrix P and movie feature matrix Q are output.

[0081] Next, we tuned the optimal parameters of the ALS model. The ALS algorithm uses three key parameters for training latent semantic models: k, epochs, and λ. k represents the latent feature dimension, epochs represents the number of training iterations, and λ represents the regularization coefficient, which is primarily used to prevent overfitting during training. The evaluation metrics used in this experiment were RMSE and MAE (root mean square error) and mean absolute error (MAE). Minimum RMSE and MAE yielded the best results on the test set, indicating that the optimized model parameters were optimal. The latent feature dimension k was selected as 16, 32, 64, 128, and 256, respectively, and the regularization coefficient λ was selected as 0.001, 0.01, 0.1, and 1. To conserve computing resources and time, the training cycle was set to 5.

[0082]

[0083] RMSE training results table

[0084] As can be seen from the above table, the RMSE when λ is 0.1 is significantly smaller than the RMSE when λ is 0.001, 0.01, and 1, and when λ is 0.1 and k is 128, the RMSE is significantly smaller than the RMSE when other feature dimensions are used.

[0085] Similarly, when the implicit feature dimension k, regularization coefficient λ, and number of iterations epochs remain unchanged, the mean absolute error (MAE) results after multiple experiments are shown in the following table.

[0086]

[0087] MAE training results table

[0088] It can be seen from the MAE training result table that the MAE when λ is 0.1 is significantly smaller than the MAE when λ is 0.001, 0.01 and 1, and when λ is 0.1 and k is 128, the MAE is significantly smaller than the MAE when other feature dimensions are used.

[0089] According to the parameter adjustment of the ALS model, when the root mean square error (RMSE) and mean absolute error (MAE) are minimized, the optimal parameter combination of the model is (128, 0.1). At this time, the latent semantic model trained by the ALS algorithm works best.

[0090] Step 2 is as follows:

[0091] Step 2.1: Use cosine similarity to calculate the similarity between movies in user-ratings.

[0092]

[0093] where r ui and r uj Represents the ratings of user u on movies i and j, U ij represents the set of users who like both movies i and j.

[0094] Step 2.2: Calculate the movie feature matrix Q using the ALS algorithm. The number of rows in the matrix corresponds to the number of movies, and the number of columns corresponds to the dimension k of the movie's implicit features. For example, the movie genres are action, comedy, and other implicit features, and the matrix values ​​represent the weights of these features. Cosine similarity is also used to calculate movie similarity in the movie feature matrix.

[0095] Step 2.3: Weighted fusion of the movie similarity obtained based on the user's historical viewing behavior and the movie's own characteristics is used to obtain the final item similarity, which can be expressed as:

[0096] new_sim(i,j)=αsim1(i,j)+(1-α)sim2(i,j)

[0097] Where i and j represent the movies used to calculate similarity, α represents the weight of calculating movie similarity based on the user's historical viewing behavior using the original user-movie rating matrix, and 1-α represents the movie feature matrix trained using the ALS algorithm, which is used to calculate the weight of movie familiarity based on the movie's own features.

[0098] Step 2.4: Calculate the similarity matrix between all movies in the offline stage, and quickly get a list of similar movies when watching a movie in real-time recommendation.

[0099] Next, we tune the α parameter in the matrix similarity formula and select a step size of 0.2 in the interval (0, 1). We compare the recommendation precision and recall rates in the ItemCF algorithm as evaluation indicators after improving the similarity formula with different α values.

[0100] From the list of user-favorite movies predicted by the recommendation algorithm, the list of products that the user actually likes is filtered out as the correctly predicted list, and the proportion of the correctly predicted movie list in all predicted movie lists is calculated.

[0101]

[0102] Where R(u) represents the recommendation list for user u calculated by the recommendation algorithm, and T(u) represents the list of movies that the user actually likes.

[0103] In the list of movies that the user likes predicted by the recommendation algorithm, the list of movies that the user actually likes is filtered out as the correct predicted list. The proportion of the correct predicted movie list to the list of movies that the user actually likes is calculated as the recall rate.

[0104]

[0105] Where R(u) represents the recommendation list for user u calculated by the recommendation algorithm, and T(u) represents the list of movies that the user actually likes.

[0106]

[0107] Precision and Recall training results table

[0108] By observing the training results, we can see that using only the movie feature matrix obtained after ALS training in the similarity calculation yields a high precision of 0.8085, but a very low recall of 0.1375. Precision indicates how many of the recommended movies are actually liked by the user. Recall indicates how many of the recommended movies are actually liked by the user, given their existing list of favorite movies. Precision and recall influence each other. Ideally, both should be high, but generally, high precision results in low recall, and vice versa. In real-time movie recommendations, it is necessary to improve precision while maintaining recall. As shown in the table above, when α is 0.2, precision meets the requirements for real-time recommendations while also maintaining a good recall. Therefore, using a balance factor of (0.2, 0.8) improves precision by 6.8% while maintaining recall.

[0109] The Step 3 is specifically as follows:

[0110] Step 3.1: After the user has watched a movie, use the movie similarity matrix calculated in Step 2 to dynamically adjust the list of candidate movies based on the user's rating. For example, if the user gives a very low rating after watching a movie, we should select fewer similar movies, but we cannot choose none, because the user may just not like the movie, not the type of movie. When the rating is low, select a few similar movies to the current movie, and the rest are similar movies to the movie with the highest rating in the recent ratings. After dynamic combination, they are used as the list of candidate recommended movies. The formula for the candidate movie recommendation list PreList is:

[0111]

[0112] Where N is the number of alternative movies, the user's rating is 1-5 points, r represents the user's rating of the movie they just watched, M is the number of similar movies to the highest-rated movie in the recent ratings, and Ceil(x) is the rounding function.

[0113] Step 3.2: Get the user's most recent S movie ratings.

[0114] Step 3.3: Calculate the user's preference for the candidate movies using a real-time recommendation algorithm. Compare the N movies in the candidate list with the movies rated by the user most recently S times to calculate the user's preference. To ensure the timeliness of the recommendation, the user's interest changes are incorporated into the calculation of the user's preference.

[0115] The core idea of ​​the real-time recommendation algorithm is to recommend movies based on users' recent ratings. Users rate movies after watching them, and these ratings are stored in a database. A list of candidate movies is then dynamically assembled based on the ratings. Similarities are calculated with the most recently rated movies, and the sum of these scores is multiplied by the movie ratings. The resulting predicted recommendation score represents the user's preference. Multiplication by the movie rating is done because users assign different ratings based on their preference after watching a movie. A high score indicates that the user enjoys that type of movie and should be recommended more frequently; a low score indicates that the user may not be interested in that type of movie and should be recommended less frequently. By calculating the similarity between the candidate movies and the most recently rated movies and then multiplying the product by the movie ratings, we can generate candidate movies similar to the user's recently favored, high-scoring movies, capturing their recent viewing preferences.

[0116]

[0117] Where Like is the predicted score for each similar candidate movie, indicating the user's preference for the movie. S is the list of recently rated movies, p is a movie in the rated list, q is a movie in the candidate movie list, and Sp represents the user's rating for each movie in the recently rated movie list. n is the total number of recently rated movies.

[0118] The second half is regularization, which prevents overfitting or underfitting of the captured interest. Incount represents the number of recently rated movies with similar high scores, while decount represents the number of recently rated movies with similar low scores. The high and low scores are determined by whether the movie score exceeds a set threshold. In this system, the threshold for movie ratings is set to 3, and the similarity threshold is set to 0.6. Taking the logarithm of high- and low-scoring movies does not significantly affect the overall result of the formula, but it also adds the factor of the number of similar movies, making the formula more comprehensive and reasonable.

[0119] To optimize real-time recommendations, we consider the impact of changing user interests on the calculated preference when calculating a user's movie preference. User interests may change over time, and making recommendations without considering this time factor will result in reduced accuracy. We chose the Ebbinghaus forgetting curve as the interest forgetting function. German psychologist Ebbinghaus proposed that human forgetting follows a pattern, and that the forgetting process is not uniform, but rather slows down. The knowledge retained in the brain during the period of fastest forgetting is considered short-term memory, while the remaining less than 30% at the end of the forgetting process is considered stable long-term memory.

[0120] In the forgetting function, the time from information cognition to forgetting is defined as the information half-life T0, and the decay factor is defined as Then for the current time t n The forgetting curve can be expressed as:

[0121]

[0122] t n is the current time of the system, and t0 is the user's rating time.

[0123] Because real-time recommendations only need to obtain the most recent interests and consider the user's short-term memory, a threshold TL is set for the rating time from the current time. When the time exceeds the threshold, the reference value for real-time recommendations is not very large. In this way, the inverse tangent function is used to penalize the rating weight again, which can better ensure that the user's recent movie tastes are met.

[0124]

[0125] Step 3.4: Based on the likeability calculation rule that takes into account the changes in user interests, the likeability of the movies in the candidate movie list is calculated to obtain a candidate movie list with likeability.

[0126] The Step 4 is specifically as follows:

[0127] Step 4.1: Get the last movie recommendation list OldList, which is N movies in size

[0128] Step 4.2: Get the candidate movie list PreList from S3, which is N movies in size

[0129] Step 4.3: Merge the previous movie recommendation list OldList and the alternative movie list PreList, sort them by popularity, select the top N movies as the movie recommendation list NewList, and push it directly to the user.

[0130] The recommendation algorithm in this solution uses a hybrid of ALS and ItemCF, leveraging the strengths of each algorithm. This not only overcomes the matrix sparsity issue in movie recommendation systems, but also calculates movie similarities between the movie feature matrix calculated by the ALS algorithm and the original user-movie rating matrix, then fuses them with a certain weight. Ultimately, while maintaining recall, the precision rate is improved by 6.8%. The real-time recommendation algorithm considers user interests when calculating the candidate movie list, overcoming the issue of lagging recommendation information due to changes in user viewing interests. This ensures that real-time recommendation results meet users' recent movie tastes, resulting in more accurate recommendations that meet user needs and enhance the recommendation system's effectiveness.

[0131] Obviously, the specific implementation of the present invention is not limited to the above-mentioned methods. As long as various non-substantial improvements are made using the method concept and technical solution of the present invention, they are all within the scope of protection of the present invention.

Claims

1. A real-time movie recommendation method based on ALS and collaborative filtering, characterized by: include: S1. Obtain the original user rating data, construct the user-movie rating matrix, and obtain the movie feature matrix and user feature matrix through ALS algorithm training; S2. The movie similarity is calculated by fusing the user-movie rating matrix and the movie feature matrix. Finally, the similarity between all two movies is obtained to construct a movie similarity matrix. S3. After the user has watched a movie, the movie similarity matrix is ​​used to dynamically adjust the candidate movie list. Then, a preference algorithm that takes into account the user's interest changes is used to calculate the user's preference for the movies in the candidate movie list, and a candidate movie list including the preference is obtained. S4. Based on the user's preference for movies, the last recommended movie list and the list of alternative movies including the preference are merged and updated, and finally a new movie recommendation list is generated and pushed directly to the target user; Step S1 uses the ALS algorithm to mine the implicit features of users and movies, and uses matrix decomposition to solve the sparsity of the rating matrix. The rating matrix is ​​decomposed into the form of two low-order matrices multiplied together to generate a user feature matrix and a movie feature matrix; Step S1 includes: S1.1: Based on the user's original rating data, construct a user-movie rating matrix A. The shape of the matrix A is a co-occurrence matrix of the number of users multiplied by the number of movies. S1.2: Randomly initialize the user feature matrix P and the movie feature matrix Q; where the P matrix shape is the number of users * k; the Q matrix shape is the number of movies * k; Then the user-movie rating matrix is: A=P·Q T The formula for predicting the rating of a single user u and a single movie i is: S1.3: Compare the true rating of user u to movie i in the training data with the corresponding p u and q i The value obtained by dot multiplication establishes the squared difference loss function; the definition of this loss function is to make the square of the difference between the product of the movie vector and the user vector and the original rating as small as possible, so that the product of the user matrix and the movie matrix is ​​as close as possible to the original rating matrix; Among them, r u,i represents the true rating of user u for movie i, represents the algorithm’s prediction of user u’s rating for movie i, A represents the user-movie rating matrix, and p u represents the implicit feature factor vector of user u, q i is the implicit feature factor vector of movie i; λ represents the regularization coefficient used to prevent overfitting of the model; S1.4: Use gradient descent to optimize the loss function. The parameters trained in the optimization process are the user feature matrix P and the movie feature matrix Q, that is, the latent vectors of all users and all movies. Use gradient descent to iteratively update the latent vectors of users and all movies, and calculate their partial derivatives. The formula is as follows: S1.5: When the error value of the loss function drops to the set value or reaches the number of iterations, the trained user feature matrix P and movie feature matrix Q are output.

2. The real-time movie recommendation method based on ALS and collaborative filtering according to claim 1, characterized in that: Step S2 includes: S2.1: Calculate the similarity between movies in the user-movie rating matrix using cosine similarity; where r ui and r uj Represents the ratings of user u on movies i and j, U ij represents the set of users who like both movies i and j; S2.2: The movie feature matrix Q obtained by training the ALS algorithm: the number of rows in the matrix is ​​the number of movies, and the number of columns is the dimension k of the movie's implicit features. The movie similarity is calculated using cosine similarity in the movie feature matrix; S2.3: The movie similarity obtained based on the user's historical viewing behavior and the movie's own characteristics is weighted and integrated to obtain the final item similarity expressed as: new_sim(i,j)=αsim1(i,j)+(1-α)sim2(i,j); Where i and j represent the movies used to calculate similarity, α represents the weight of calculating movie similarity based on the user's historical viewing behavior using the original user-movie rating matrix, and 1-α represents the movie feature matrix trained using the ALS algorithm, which is used to calculate the weight of movie similarity based on the movie's own features. Step 2.4: Calculate the similarity matrix between all movies in the offline stage, and quickly get a list of similar movies when watching a movie in real-time recommendation.

3. The real-time movie recommendation method based on ALS and collaborative filtering according to claim 1, characterized in that: Step S3 includes: S3.1: After a user watches a movie, the movie similarity matrix calculated in S2 is used to dynamically adjust the list of candidate movies based on the user's rating. When the rating is low, a few similar movies to the current movie are selected. The remaining similar movies are obtained from the most recently rated movies with the highest rating. These are dynamically combined to form the list of candidate recommended movies. The formula for the candidate movie list PreList is: Where N is the number of candidate movies, the user's rating is 1-5 points, r represents the user's rating of the movie they just watched, and M is the number of similar movies to the highest-rated movie in the recent ratings; S3.2: Get the user's most recent S movie ratings; S3.3: Calculate the user's preference for the candidate movies using a real-time recommendation algorithm. Compare the N movies in the candidate list with the movies rated by the user most recently S times to calculate the user's preference. To ensure the timeliness of the recommendation, the user's interest changes are incorporated into the calculation of the user's preference. S3.4: According to the likeability calculation rule that takes into account the change of user interests, the likeability of the movies in the candidate movie list is calculated to obtain the candidate movie list including the likeability.

4. The real-time movie recommendation method based on ALS and collaborative filtering according to claim 1, characterized in that: Step S4 includes: S4.1: Get the last movie recommendation list OldList, which has N movies in size; S4.2: Get the candidate movie list PreList from S3, which has a size of N movies; S4.3: Merge the previous movie recommendation list OldList and the candidate movie list PreList, sort them by popularity, select the top N movies as the movie recommendation list NewList, and push the movies in the movie recommendation list NewList to the user.

5. The real-time movie recommendation method based on ALS and collaborative filtering according to claim 3, characterized in that: In step S3.3, movies are recommended based on the user's recent rating records. The movie ratings given by users are stored in the database. Then, based on the current movie, similar movies are selected as the list of movies to be recommended. The similarity with the recently rated movies is calculated, and then multiplied by the movie rating and summed up. The result is the recommended predicted rating, which represents the user's preference: Like is the predicted score of each similar candidate movie, indicating the user's preference for the movie. S is the list of recently rated movies, p is a movie in the rated list, and q is a movie in the candidate movie list. S p Indicates the user's rating of each movie in the recently rated movie list; n is the number of all recently rated movies; incount represents the number of recently rated movies with high similarity, and decount represents the number of recently rated movies with low similarity.

6. The real-time movie recommendation method based on ALS and collaborative filtering according to claim 5, characterized in that: When calculating the likeability, the user’s interest changes over time and the forgetting function is introduced to p Modify and define: In the forgetting function, the time from cognition to forgetting half of the information is defined as the information half-life T0, and define the decay factor Then for the current time t n The forgetting curve shows: t n is the current time of the system, and t0 is the user's rating time; Set the threshold TL of the scoring time from the current time, and the corrected score S p for:

Citation Information

Patent Citations

  • Context sensing recommendation system and method based on matrix decomposition and CRNN

    CN116049377A

  • Film individuation recommendation method based on user real-time interest vectors

    CN104063481A

  • Movie recommendation method based on improved collaborative filtering algorithm

    CN110569374A