A personalized recommendation method for online educational resources
By applying the alternating least squares algorithm to perform matrix decomposition on the Spark platform, the model inaccuracy caused by data sparseness in the recommendation of educational and teaching resources is solved, and efficient and accurate personalized recommendation is achieved.
Patent Information
- Application Number
- CN202110088311.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-20
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2041-01-20
AI Technical Summary
In the application of existing collaborative filtering recommendation algorithms in educational and teaching resources, the model is inaccurate due to data sparsity, and it is impossible to accurately recommend appropriate educational and teaching resources.
Alternating least squares (ALS) algorithm is used to perform parallel calculations on the Spark big data analysis platform, and the recommended accuracy and calculation efficiency are improved through matrix decomposition and iterative solution of loss function.
It improves the accuracy and computing efficiency of educational and teaching resource recommendations, and can provide efficient personalized recommendations in the environment of super-large sparse feature matrix, which significantly improves the accuracy of recommendations.
Smart Images

Figure CN112749342B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of computer Internet and relates to a personalized recommendation method for network education and teaching resources. Background Art
[0002] With the continuous advancement of human information technology, information infrastructure, information technology, software systems and platforms have developed into a revolutionary force that promotes the development of education and teaching to a higher level and promotes social progress. With the emergence of various educational and teaching platforms, online educational and teaching resources are also growing at a rapid rate. However, the sharp increase in the amount of educational and teaching resources has brought many troubles and challenges to teaching organizers and learners. They have to spend a lot of time and energy to screen out educational and teaching resources that meet their needs. Therefore, personalized recommendation systems that are widely used in the commercial field have also begun to be gradually applied to the field of education and teaching. They can use users' historical behavior data to perform personalized calculations, discover the interests of different users, and guide users to gradually discover the information and educational and teaching resources they need, which greatly improves the work and learning efficiency of users.
[0003] Recommendation algorithm is a method that can filter information and can effectively recommend personalized information based on the user's information needs, personal interests, etc., and has been successfully applied in many fields such as online video, social platforms, online music, e-commerce, etc. With the continuous improvement of educational and teaching resources in the construction of smart education and teaching, using rich educational and teaching resources, such as e-books, teaching videos, literature, etc., to make personalized recommendations will help improve students' learning efficiency.
[0004] At present, the more popular recommendation algorithm is collaborative filtering (CF). Collaborative filtering, literally, includes two operations: collaboration and filtering. The so-called collaboration is to use the behavior of the group to make recommendations. In biology, there is a saying of collaborative evolution. Through the role of collaboration, the group gradually evolves to a better state. For the recommendation system, through the continuous collaboration of users, the recommendations given to users will eventually become more and more accurate. And filtering is to find (filter) the solutions that users like from the feasible decision (recommendation) solutions. Specifically, the idea of collaborative filtering is to find a certain similarity (similarity between users or similarity between objects) through the behavior of the group, and make decisions and recommendations for users based on this similarity. Generally speaking, collaborative filtering recommendations are divided into three types. The first is user-based collaborative filtering, the second is item-based collaborative filtering, and the third is model-based collaborative filtering. User-based collaborative filtering mainly considers the similarity between users. As long as we find out the educational resources that similar users like and predict the target user's rating of the corresponding educational resources, we can find several educational resources with the highest ratings and recommend them to users. Item-based collaborative filtering is similar to user-based collaborative filtering, except that we now turn to finding the similarity between educational resources. Only when we find the target user's rating of certain educational resources, we can predict similar educational resources with high similarity and recommend several similar educational resources with the highest ratings to users. For example, if you buy a book on machine learning online, the website will immediately recommend a bunch of books on machine learning and big data to you. The idea of item-based collaborative filtering is clearly used here.
[0005] However, the accuracy of many recommendation algorithms is relatively low. Directly using collaborative filtering methods will result in outdated recommended educational and teaching resources due to a lack of understanding and knowledge of the course content, and the recommended results will have a low degree of correlation with the prepared course tasks. Therefore, it is necessary to construct a personalized recommendation method that can recommend relevant educational and teaching resources as accurately as possible. Summary of the invention
[0006] The present invention provides a personalized recommendation method for online educational and teaching resources. In real teaching, it is impossible for every user to have a behavioral relationship with all teaching resources. In fact, user-resource pairs with interactive relationships only account for a very small part. In other words, the user-resource relationship list is very sparse. If the educational and teaching resource rating matrix is very sparse, it will directly affect the accuracy of the model. The purpose of the present invention is to provide a teaching resource recommendation method that can be applied to ultra-large sparse feature matrices and has good computational efficiency for large-scale data set environments. In order to solve the problem that the model is inaccurate due to the data sparsity of the existing collaborative filtering scheme, which leads to the inability to accurately recommend suitable educational and teaching resources to different users.
[0007] The present invention uses the Alternating Least Squares (ALS) algorithm on the Spark big data analysis platform, and then uses a parallel method to increase the workload completed per unit time and the accuracy of recommendations, thereby solving the problem of being unable to accurately recommend educational resources.
[0008] A method for personalized recommendation of online educational teaching resources, comprising:
[0009] Step 1: First, obtain the user rating matrix through the original user rating data, and calculate the similarity between users and users, and between educational and teaching resources and educational and teaching resources.
[0010] Step 2: Design a loss function and add the similarity data obtained from the above calculation to the corresponding function for use in the next step.
[0011] Step 3: Execute the iterative solution of the minimization function in the function of step 2, and finally obtain the U matrix and V matrix. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 Matrix decomposition model diagram
[0013] Figure 2 Determine UV map for iteration
[0014] Figure 3 Flowchart of the proposed algorithm for alternating least squares
[0015] Figure 4 MSE algorithm comparison chart
[0016] Figure 5 RMSE algorithm comparison chart DETAILED DESCRIPTION
[0017] The alternating least squares collaborative filtering recommendation algorithm of the present invention is implemented on the Spark platform. Its basic principle is: if R is a user's rating matrix for educational resources, it is normalized to (R = (R m×n ))∈{0,1} m×n , where m represents the number of users and n represents the number of rating matrices. This algorithm needs to find a low-rank matrix X to approximate the matrix R and minimize the following objective function:
[0018] L(x)=∑ ij (R ij -X ij ) 2 (1)
[0019] In formula (1), R ij represents the score with horizontal coordinate i and vertical coordinate j in matrix R, X ij represents the value of the horizontal coordinate i and the vertical coordinate j in the low-rank matrix X, (R ij -X ij ) 2 represents the square error term between the R matrix and the X matrix. Then think about how to efficiently solve the optimization problem argmin x L(x).
[0020] like Figure 1 As shown, about the matrix decomposition model X = UV T , where d represents the number of features of the R matrix, r represents the rank of the matrix R, and R ij represents the rating of user i on educational resource j, U represents the user's preference matrix for the implicit features of educational resources, and U i represents the implicit feature vector of user i’s preference, V represents the matrix of implicit features contained in educational resources, V j represents the implicit feature vector contained in educational resource j, V T represents the transpose of the matrix V. In general, d is less than one thousandth of r, and r≈min(m,n) is equivalent to dimensionality reduction. In this case, equation (1) can be rewritten as
[0021] L(U,V)=∑ ij (R ij -U i V j T ) 2 (2)
[0022] The loss function generally needs to add a regularization term to avoid overfitting and other problems. By adding a second-order regularization term to formula (2), overfitting can be prevented. Then formula (2) can be rewritten as
[0023]
[0024] In formula (3), λ represents the coefficient of the second-order regularization term. This parameter is usually configured using a validation set or a cross-validation set. We try a variety of data to find the best parameter. We need to consider the trade-off between training sets and set the parameter to a smaller value to avoid overfitting. Initially, λ is set to 0.1, and the learning rate is 0.01. Then, the learning rate is fixed, and λ is increased with a step size of 0.01 around the initial value. It is iterated ten times. Each iteration uses the λ obtained last time as the benchmark value and increases with a step size of 0.01. When λ reaches 0.2, λ is set to 0.1 again, and iterates ten times again. Each iteration uses the λ obtained last time as the benchmark value and decreases with a step size of 0.01. When λ is 0, the λ with the smallest error among these 20 times is selected as λ1, and then the learning rate is reduced to 0.001. The λ obtained in the above steps is further fine-tuned, using the λ1 obtained in the previous link as the benchmark value and increasing or decreasing with a step size of 0.001. After 20 iterations, the λ1 with the smallest error among these 20 times is selected as the final λ that meets the requirements (the physical meaning of λ in the formula below is the same as that of formula (3)). At this point, collaborative filtering has been successfully transformed into an optimization problem. Since the variable U i and V j Coupled together, it is not easy to solve, so we introduce the alternating least squares method to solve it. Assuming that the V matrix is known, we can apply RidgeRegression to infer each row of the U matrix, and vice versa. Therefore, fix the V matrix and apply the loss function L(U,V) to U i Find the partial derivative and set the derivative equal to 0, and we get the following solution for U i Formula
[0025]
[0026] In formula (4), R i represents the rating vector that user i has rated, Indicates that user u i The feature matrix composed of the rated feature vectors, m represents the number of users, n represents the number of rating matrices, Represents the number of educational and teaching resources rated by user i.
[0027] Similarly, if we fix the U matrix, we can get the following solution for V j Formula
[0028]
[0029] In formula (5), R jIt represents the rating vector of users who have rated educational resource j, m represents the number of users, n represents the number of rating matrices, Represented as educational and teaching resources v j The feature matrix composed of the feature vectors of the rated users, Represented as educational and teaching resources v j The number of users who have already rated. In equations (4) and (5), I represents a d×d identity matrix.
[0030] Based on the least cross squares method of collaborative filtering algorithm, the algorithm is calculated by calling equations (4) and (5) until convergence results are obtained. The iterative process is as follows: Figure 2 shown.
[0031] The process of the alternating least squares collaborative filtering recommendation algorithm is as follows Figure 3 shown.
[0032] Step 1: First, the user rating matrix is obtained through the original data of user ratings, and the similarity between users and educational resources is calculated. The present invention uses the vector cosine method, also known as VSS (spatial similarity method), where N (m) N represents the set of educational and teaching resources owned by user m, that is, the promotion of educational and teaching resources by user m. (n) represents the educational resources owned by user n, then the similarity formula between users m and n is:
[0033]
[0034] The same principle shows that the similarity formula between educational and teaching resources i and educational and teaching resources j is:
[0035]
[0036] Step 2: Design a loss function and add the similarity data obtained by the above calculation to the function of formula (8).
[0037]
[0038] In the above formula, (i, j) represents all user-educational resource pairs, r ij represents the rating of user i on educational resource j, represents the transpose of the user matrix, v j represents the implicit feature vector contained in educational resource j, I i represents the user set, u ki represents the preference of user i for the implicit feature k of educational resources, u p The implicit feature vector representing the preference of user p, ukp represents the preference of user p for the implicit feature k of educational resources, PC(m,n) represents the similarity between users, K(u i ) represents user u i The N nearest neighbors of j represents a collection of educational and teaching resources, v kj represents the implicit feature vector k, v contained in the educational resource j q represents the implicit feature vector contained in the educational resource q, v kq represents the implicit feature vector k contained in the educational resource q, K represents a random attribute, K(v j ) represents educational and teaching resources v j The N nearest neighbors of PC(i,j) represent the similarity between educational and teaching resources. Represents user u i The number of rated educational resources, Represented as educational and teaching resources v j The number of users who have already rated the product.
[0039] Step 3, iteratively solve the minimization function in the function of step 2, and finally obtain the U and V matrices.
[0040] Exactly solve U and V, solve V based on fixed U, solve U based on fixed V, and use alternating least squares method to iteratively solve. The specific steps are as follows:
[0041]
[0042] In the above formula (9), I i Represents a collection of users, The transpose of the latent feature vector representing the preference of user i, v j represents the implicit feature vector contained in educational resource j, r ij represents the rating of user i on educational resource j, represents the implicit feature vector k contained in the educational resource j, represents the preference of user i for the implicit feature k of educational resources, u p The implicit feature vector representing the preference of user p, represents the preference of user p for the implicit feature k of educational resources, PC(m,n) represents the similarity between user m and user n, K(u i ) represents user u i The N nearest neighbors, k represents a random attribute, E represents the identity matrix, I j represents a collection of educational and teaching resources, R T represents the transpose of the user's rating matrix for educational resources, Represents the transpose of the matrix formed by the educational and teaching resource vectors, Represents the matrix formed by the user set vector. After iterative solution, u can be obtained. i .
[0043] The same about v j , among which,
[0044]
[0045] In the above formula (10), I i Represents a collection of users, Represents the matrix formed by the user set vector, v j represents the implicit feature vector contained in educational resource j, Represented as educational and teaching resources v j The number of users who have already rated represents the matrix formed by the educational and teaching resource vectors, PC(i,j) represents the similarity between educational and teaching resource i and educational and teaching resource j, v q represents the implicit feature vector contained in the educational resource q, K(v j ) represents educational and teaching resources v j The n nearest neighbors, k represents a random attribute, E represents the identity matrix, I j represents a collection of educational and teaching resources, R T Represents the transpose of the user's rating matrix for educational resources.
[0046] Experiments and Results
[0047] To evaluate the accuracy of the proposed algorithm, we use the following evaluation indicators: mean square error (MSE), root mean square error (RMSE), and global average accuracy (MAP). MSE means the range of variation in the data evaluation. If the range is small, the correctness of the proposed model is very good. RMSE acts as the standard deviation. MAP is a ranking based on the evaluation index. A higher value indicates that the recommended teaching resources are more accurate, and the ranking of teaching resources can still satisfy users. Their exact definitions are:
[0048]
[0049]
[0050]
[0051] represents the estimated degree of preference of user u for educational resource i, r ui It indicates the actual rating of the user for the teaching resource, and N indicates the number of preference ratings in the data set.ui Indicates the recommended educational resource i is ranked as the favorite by user u, pt ui Indicates the ranking of the recommended educational and teaching resources in the recommendation list.
[0052] The data is the result of 200 users who tested the teaching resource recommendation method. Because the number of users is not large, the data is relatively small, and there are also random errors, but the data obtained by the present invention can still objectively show the effect of the algorithm. Compared with the algorithm presented in the present invention are the recommendation algorithm based on content and the recommendation algorithm based on association rules.
[0053] The MSE algorithm results are as follows: Figure 4 As shown, from Figure 4 The results show that the recommendation algorithm used in the present invention is more accurate than the two compared algorithms. Figure 5 As shown. Figure 5 It can be seen that the algorithm used in the present invention greatly exceeds the algorithm compared with it. The MSE algorithm shows the accuracy of the algorithm proposed by the present invention, and the RMSE algorithm can show the ranking of the recommendation results. These two algorithms complement each other to meet the needs of the system. Therefore, the algorithm proposed by the present invention can be applied in the teaching resource recommendation system.
[0054] In summary, the present invention is based on the application of the alternating least squares collaborative filtering recommendation algorithm in the teaching resource recommendation system. First, the principle of the alternating least squares recommendation algorithm and its problems are analyzed, and then a recommendation method is proposed based on the traditional collaborative filtering recommendation algorithm, which uses the similarity between users and between teaching resources to calculate the similarity between users and between teaching resources, and at the same time applies the alternating least squares collaborative filtering recommendation algorithm to the Spark platform to increase the workload completed per unit time and the accuracy of recommendations by using a parallel method.
Claims
1. A personalized recommendation method for online educational teaching resources, characterized by: R is a user's rating matrix for educational resources, which is standardized as (R = (R m×n ))∈{0,1} m×n , where m represents the number of users and n represents the number of education and teaching rating matrices. We look for a low-rank matrix X to approximate the matrix R and minimize the following objective function: L(x)=∑ ij (R ij -X ij ) 2 (1) In formula (1), R ij represents the rating of user i on educational resource j, (R ij -X ij ) 2 Represents the square error term between the R matrix and the X matrix; About the matrix decomposition model X=UV T , d represents the number of features of the R matrix, r represents the rank of the matrix R, U represents the user's preference matrix for the implicit features of educational resources, and U i represents the implicit feature vector of user i’s preference, V represents the matrix of implicit features contained in educational resources, V j represents the implicit feature vector contained in educational resource j, V T It means the transpose of matrix V, d is less than one thousandth of r, r≈min(m,n), which is equivalent to dimensionality reduction; At this time, (1) can be rewritten as The loss function needs to add a regularization term to avoid overfitting. By adding a second-order regularization term to formula (2), overfitting can be prevented. Then formula (2) can be rewritten as In formula (3), λ represents the coefficient of the second-order regularization term. The alternating least squares method is introduced to solve it. Assuming that the V matrix is known, each row of the U matrix can be inferred by Ridge Regression, and vice versa. Therefore, the V matrix is fixed and the loss function L(U, V) is applied to U i Find the partial derivative and set the derivative equal to 0, and we get the following solution for U i Formula In formula (4), Ri represents the rating vector of user i, V ui represents the feature matrix composed of the feature vectors rated by user i, m represents the number of users, n represents the number of rating matrices, and n ui represents the number of educational resources rated by user i; Similarly, we can fix the U matrix and obtain the following solution for V j Formula In formula (5), R j It represents the rating vector of users who have rated educational resource j, m represents the number of users, n represents the number of rating matrices, It is represented as a feature matrix composed of feature vectors of users who have rated educational resource j. It is represented by the number of users who have already rated educational resource j. In formulas (4) and (5), I represents a d×d unit matrix; Based on the alternating least cross squares method of collaborative filtering algorithm, the algorithm is calculated by calling equations (4) and (5) until convergence results are obtained. The process of the alternating least squares collaborative filtering recommendation algorithm is as follows; Step 1: First, obtain the user rating matrix through the original data of user ratings, and calculate the similarity between users and users, and between educational and teaching resources; Apply the vector cosine method, where N (m) N represents the set of educational and teaching resources owned by user m, that is, the promotion of educational and teaching resources by user m. (v) represents the educational resources possessed by user v, then the similarity formula between users m and v is: The same principle is used to know that the similarity formula between educational and teaching resources h and educational and teaching resources j is: Step 2, add the similarity data obtained by the above calculation to the loss function of formula (8); In the above formula, (i, j) represents all user-educational resource pairs, r ij represents the rating of user i on educational resource j, represents the transpose of the user matrix, v j represents the implicit feature vector contained in educational resource j, I i represents the user set, u ki represents user i’s preference u for the implicit feature k of educational resources p The implicit feature vector representing the preference of user p, u kp represents the preference of user p for the implicit feature k of educational resources, PC(m, v) represents the similarity between users, K(u i ) represents user u i The N nearest neighbors of j represents a collection of educational and teaching resources, v kj represents the implicit feature vector k, v contained in the educational resource j q represents the implicit feature vector contained in the educational resource q, v kq represents the implicit feature vector k contained in the educational resource q, K represents a random attribute, K(v j ) represents educational and teaching resources v j The N nearest neighbors of , PC(h, j) represents the similarity between educational and teaching resources. Represents user u i The number of rated educational resources, Represented as educational and teaching resources v j The number of users who have already rated; Step 3, iteratively solve the minimization function in the function of step 2, and finally obtain the U and V matrices.
2. The method according to claim 1, characterized in that: Initially, λ is set to 0.1, and λ is increased with a step size of 0.01 around the initial value for ten iterations. When λ reaches 0.2, λ is set to 0.1 again, and iterates again for ten times, decreasing it with a step size of 0.
01. When λ is 0, the λ with the smallest error among these 20 times is selected as λ1, and then the obtained λ1 is used as the benchmark value, and it is increased or decreased with a step size of 0.
001. After 20 iterations, the λ1 with the smallest error among these twenty times is selected as the final λ that meets the requirements.
3. The method according to claim 1, characterized in that: Exactly solve U and V, solve V based on fixed U, solve U based on fixed V, and use alternating least squares method to iteratively solve. The specific steps are as follows: In the above formula (9), I i Represents a collection of users, The transpose of the latent feature vector representing the preference of user i, v j represents the implicit feature vector contained in educational resource j, r ij represents the rating of user i on educational resource j, v kj represents the implicit feature vector k, u contained in the educational resource j ki represents the preference of user i for the implicit feature k of educational resources, u p The implicit feature vector representing the preference of user p, u kp represents the preference of user p for the implicit feature k of educational resources, PC(m, v) represents the similarity between user m and user v, K(u i ) represents user u i The N nearest neighbors, k represents a random attribute, E represents the identity matrix, I j represents a collection of educational and teaching resources, R T represents the transpose of the user's rating matrix for educational resources, Represents the transpose of the matrix formed by the educational and teaching resource vectors, Represents the matrix formed by the user set vector, and u is obtained through iterative solution i , the same about v j , among which there are In the above formula (10), I i Represents a collection of users, Represents the matrix formed by the user set vector, v j represents the implicit feature vector contained in educational resource j, Represented as educational and teaching resources v j The number of users who have already rated represents the matrix formed by the educational and teaching resource vectors, PC(h, j) represents the similarity between educational and teaching resources h and educational and teaching resources j, and v q represents the implicit feature vector contained in the educational resource q, K(v j ) represents educational and teaching resources v j The n nearest neighbors, k represents a random attribute, E represents the identity matrix, I j represents a collection of educational and teaching resources, R T Represents the transpose of the user's rating matrix for educational resources.
