# Deep Collaborative Online Learning Resource Recommendation Based on Attention Mechanism

Authors: Cuiping Hao; Ting Yang
Journal: Scientific Programming
 (2022)

---

## Abstract

In view of the lack of hierarchical and systematic resource recommendation caused by rich online learning resources and many learning platforms, an attention-based ADCF online learning resource recommendation model is proposed by introducing the attention mechanism into a deep collaborative DCF model. Experimental results show that the proposed ADCF model enables an accurate recommendation of online learning resources, reaching 0.626 and 0.339 on the HR and NDCG metrics, respectively, compared to the DCF models before improved, up by 1.31% and 1.25%, and the proposed ADCF models by 1.79%, 2.17%, and 2.32%, respectively, compared to the IUNeu and NeuCF models.


---

## Body

## 1. Introduction

In recent years, the application of the Internet has promoted education from offline to online. Online education has become a trend in today’s education development and occupies a place in the huge education market. Data show that the number of online education users in China’s in 2020 grew from 90.992 million in 2015 to 182.492 million, an increase of 50.14%. With the infiltration of online education methods, online education and learning resources are increasingly rich, which not only brings the balanced development and multidirectional development of education but also brings great difficulties to the recommendation of learning resources. On the one hand, there are more online education platforms, and the curriculum types of each platform are complex and the curriculum quality is poor, making it difficult for learners to choose by themselves; on the other hand, online education and learning resources lack understanding of learners, which makes it difficult for the platform to recommend personalized courses to learners. Therefore, it is necessary to integrate and analyze the online learning resources and recommend them according to learners’ needs. To achieve this purpose, the relevant scholars conduct research. According to the different characteristics of students, Hu and others select a small piece of content course knowledge points in the learning resources, take the course knowledge as the recommendation point, and realize the recommendation of personalized online learning resources by designing personal personalized learning mechanism recommendation [1]. In order to solve the problem of sparse data and poor scalability in collaborative filtering algorithms, Honggang Wang and others optimized them using dynamic k close neighbors and slope one algorithms, and analyzed the sparsity of learning resource data in the network based on the neighbor selection results. Two-way self-equilibrium of stage evolution is adopted to improve the personalized recommendation of resource push, and the fuzzy adaptive binary particle group optimization algorithm based on evolutionary state judgment is adopted to solve the optimal sequence recommendation problem, thus to realize the personalized recommendation of learning resources and improve the matching degree and recommendation speed of online learning resources [2, 3]. Yuan studies link prediction methods in network education, builds a suitable model for network education, and proposes an improved path sorting algorithm based on the neural network sorting method through an improved analysis of traditional methods. Meanwhile, the random-walk model and the neural network-path sorting algorithm are used to realize the link prediction problem in the online learning knowledge base [4]. Xie et al. proposed a user interaction-based recommendation framework that explores real-time interest from immediate feedback, and experiments on real datasets show that the algorithm achieves more accurate prediction results and higher recommendation efficiency [5]. Liang et al. proposed a learning style model, AROLS model, to represent the characteristics of online learners, realize learning resource adaptation by mining behavioral data of learners, and improve the recommendation effect of online learning resources [6]. Antequera et al. present a novel approach to providing fast, automatic, and flexible resources for application owners with limited expertise in building and deploying appropriate cloud architectures; compared to existing schemes, the scheme improves resource recommendation accuracy in manufacturing scientific gateway applications by 21% [7, 8]. Through the above research, it can be found that the existing online learning resource recommendation is limited to the recommendation of courses on their own platforms and does not integrate and comprehensively recommend similar courses on other platforms, resulting in often the accurate recommendation of courses to learners. To solve this problem, this paper constructs an ADCF recommendation model based on the existing DCF model, by integrating the whole-platform online learning resources and introducing the attention mechanism to allocate the weight to the resources so as to realize the accurate recommendation of online learning resources.


## 2. Basic Approach

### 2.1. Brief Introduction of the DCF Model

The DCF model is a deep learning collaborative filter recommendation model developed based on the neural collaborative filter recommendation (NeuCF) model, which solves the problem of few input feature types of the NeuCF model and effectively improves the feature combination ability and nonlinear ability of the model. Its basic architecture is similar to that of NeuCF model architecture, mainly composed of multilayer perceptron (MLP) and generalized matrix decomposition (GMF), including input layer, coding layer, embedding layer, embedding layer, feature extraction layer, pooling layer, feature splicing layer, neural network layer, and output layer, as shown in Figure1 [9, 10].Figure 1
The DCF model structure.The model input layer is mainly responsible for inputting the relevant information and its auxiliary information into the model for training. The coding layer is responsible for coding input feature information. The embedding layer is responsible for converting the encoding into a corresponding feature representation, often including two types for the linear model GMF and for the nonlinear model MLP. The feature extraction layer is responsible for extracting feature relationships, where GMF is used to extract linear feature relationships, and MLP is used to extract nonlinear relationships [10]. The pooling layer is responsible for adjusting the feature size to facilitate feature splicing, including maximum pooling and mean pooling [11]. The feature splicing layer is responsible for integrating the feature information extracted from GMF and MLP, mainly by adding or splicing the extracted features. The neural network layer is responsible for training the model and model parameter tuning, and uses the cross-entropy loss function to adjust the network weight. The output layer maps the output value to a specific range through the activation function. The sigmoid function is selected as the activation function, and its mathematical expression is as follows [12]:(1)fx=11+e−x.In the formula, the value range off(x) is [0, 1].The DCF model can extract nonlinear and linear features of information and has strong personalized recommendation ability, but the model believes that all features have the same impact on the final recommendation results and do not have the importance of distinguishing between different features. In practice, different characteristic factors contribute differently to the model prediction results, so it is necessary to improve the model. In this paper, the recommendation effect of the model is improved by introducing an attention mechanism into the model to distinguish between the importance of different features.


### 2.2. DCF Model Refinement

The improvement of the DCF model in this paper is the introduction of the attention mechanism into the model to improve the model recommendation effect by adding the importance of distinguishing attention layers between the feature splicing layer and the neural network layer. The attention mechanism in the DCF model is mainly attached to the framework of the encoder and decoder, and the essence is a thought model, formulas (2) ∼ (4), by allowing the neural network in the DCF model to only focus on the partial information of the input and select specific inputs [13].(2)a=fXN,(3)Za=aΘXn,(4)st:a∈0,1.In the formula,Xn represents the n-dimensional eigenvector input attention layer, f(x) indicates the attention mechanism network, a represents the attention corresponding to the n-dimensional eigenvector through f(x), and Za represents the output layer output result. At that time, fx=SoftmaxXn, the value range of a was (0, 1); when a is constant 1, the attention network helps fit the complex function model when the model degenerated into a DCF model.The attention mechanism layer of the DCF model (hereinafter referred to as the ADCF model) obtains the weight of each feature dimension through equations (5) ∼ (7) [14]. Computing the attention of each feature dimension using softmax, then interacting with the corresponding features for a point-multiply input deep neural network, and finally the predictive values can be obtained through iterative training.(5)Soft maxZi=ezi∑i=1kezi,(6)An=Soft maxXn,(7)Aout=AΘnXn.In the formula,Zi represents the ith element input by the softmax function, soft max (Zi) represents the corresponding softmax value of this element, and Xn represents the output value of the feature splicing layer. ⊙indicates point multiplication; An represents the corresponding value calculated by softmax, and Aout represents the attention layer output value.The ADCF model, by introducing the attention layer into the DCF model, can distinguish the degree of contribution of different feature information to the predicted recommendation results and then improve the model recommendation effect. Therefore, this paper proposes a new online resource recommendation method based on the ADCF model.


## 2.1. Brief Introduction of the DCF Model

The DCF model is a deep learning collaborative filter recommendation model developed based on the neural collaborative filter recommendation (NeuCF) model, which solves the problem of few input feature types of the NeuCF model and effectively improves the feature combination ability and nonlinear ability of the model. Its basic architecture is similar to that of NeuCF model architecture, mainly composed of multilayer perceptron (MLP) and generalized matrix decomposition (GMF), including input layer, coding layer, embedding layer, embedding layer, feature extraction layer, pooling layer, feature splicing layer, neural network layer, and output layer, as shown in Figure1 [9, 10].Figure 1
The DCF model structure.The model input layer is mainly responsible for inputting the relevant information and its auxiliary information into the model for training. The coding layer is responsible for coding input feature information. The embedding layer is responsible for converting the encoding into a corresponding feature representation, often including two types for the linear model GMF and for the nonlinear model MLP. The feature extraction layer is responsible for extracting feature relationships, where GMF is used to extract linear feature relationships, and MLP is used to extract nonlinear relationships [10]. The pooling layer is responsible for adjusting the feature size to facilitate feature splicing, including maximum pooling and mean pooling [11]. The feature splicing layer is responsible for integrating the feature information extracted from GMF and MLP, mainly by adding or splicing the extracted features. The neural network layer is responsible for training the model and model parameter tuning, and uses the cross-entropy loss function to adjust the network weight. The output layer maps the output value to a specific range through the activation function. The sigmoid function is selected as the activation function, and its mathematical expression is as follows [12]:(1)fx=11+e−x.In the formula, the value range off(x) is [0, 1].The DCF model can extract nonlinear and linear features of information and has strong personalized recommendation ability, but the model believes that all features have the same impact on the final recommendation results and do not have the importance of distinguishing between different features. In practice, different characteristic factors contribute differently to the model prediction results, so it is necessary to improve the model. In this paper, the recommendation effect of the model is improved by introducing an attention mechanism into the model to distinguish between the importance of different features.


## 2.2. DCF Model Refinement

The improvement of the DCF model in this paper is the introduction of the attention mechanism into the model to improve the model recommendation effect by adding the importance of distinguishing attention layers between the feature splicing layer and the neural network layer. The attention mechanism in the DCF model is mainly attached to the framework of the encoder and decoder, and the essence is a thought model, formulas (2) ∼ (4), by allowing the neural network in the DCF model to only focus on the partial information of the input and select specific inputs [13].(2)a=fXN,(3)Za=aΘXn,(4)st:a∈0,1.In the formula,Xn represents the n-dimensional eigenvector input attention layer, f(x) indicates the attention mechanism network, a represents the attention corresponding to the n-dimensional eigenvector through f(x), and Za represents the output layer output result. At that time, fx=SoftmaxXn, the value range of a was (0, 1); when a is constant 1, the attention network helps fit the complex function model when the model degenerated into a DCF model.The attention mechanism layer of the DCF model (hereinafter referred to as the ADCF model) obtains the weight of each feature dimension through equations (5) ∼ (7) [14]. Computing the attention of each feature dimension using softmax, then interacting with the corresponding features for a point-multiply input deep neural network, and finally the predictive values can be obtained through iterative training.(5)Soft maxZi=ezi∑i=1kezi,(6)An=Soft maxXn,(7)Aout=AΘnXn.In the formula,Zi represents the ith element input by the softmax function, soft max (Zi) represents the corresponding softmax value of this element, and Xn represents the output value of the feature splicing layer. ⊙indicates point multiplication; An represents the corresponding value calculated by softmax, and Aout represents the attention layer output value.The ADCF model, by introducing the attention layer into the DCF model, can distinguish the degree of contribution of different feature information to the predicted recommendation results and then improve the model recommendation effect. Therefore, this paper proposes a new online resource recommendation method based on the ADCF model.


## 3. Recommended Methods for Online Learning Resources Based on ADCF

### 3.1. ADCF Mathematical Model

The mathematical model of the ADCF model is as follows:(8)PcGMF=c0GMF⊕c1GMF⊕c2GMF⊕c3GMF,PlGMF=l0MLP⊕l1MLP⊕l2MLP⊕l3MLP,qcMLP=c0MLP⊕c1MLP⊕c2MLP⊕c3MLP,φGMF=PlGMFΘqcGMF,φMLP=∂LWLT∂L−1...∂2W2rqcMLPplMLP+b2...+bL,Aout=Soft maxφMLPφEGMFΘφMLPφEGMF,y^k=σhTAout+b.In the formula,⊕ represents connections; liGMF and liMLP represent the learner eigenvectors of the GMF and MLP models, l0,l1,l2,l3, respectively, corresponding to {learner_id, sex, profession, job}; ciGMF and ciMLP represent the course resource eigenvectors of the models, c0,c1,c2,c3, respectively, corresponding to curriculum_id, name, complexity, label; the piGMF, piMLP, qcGMF, and qcMLP represent the learner and course resource feature vector with auxiliary information for the GMF and MLP models; φMLP and φEGMF, respectively, represent the underlying feature relationships learned through the MLP and GMF models. From the model, the whole model process uses the learner and course auxiliary information, which jointly determines the prediction recommendation performance of the model.


### 3.2. Online Learning Resource Recommendation Based on ADCF

From the above analysis, the online learning resource recommendation model based on ADCF is designed, as shown in Figure2. The model input layer includes the relevant information of the learner and the course, whose input form is the behavioral sequence of the learner-course X=X1,X2,X3,...XN. Among these, Xi represents the ith behavior Learneri,Coursei. Learneri contains information about learners’ ID, gender, occupation, and Coursei contains course ID, label, name, etc.Figure 2
Resource recommendation based on ADCF.The encoding layer transforms input information via one hot to embedding feature demo [15]. Taking learner sex as an example, male is coded as [1, 0] and female as [0, 1].The embedding layer first initializesa embedding matrix about sex, with a matrix size of 2∗d, where 2 indicates possible sex values and d indicates the embedding dimension. With the above operation, the intractable category feature is able to be converted into tractable vectors. For course and learner features, encoding includes course ID, name, complexity, tag, and learner ID, gender, major, occupation. Embedding corresponds to a length of 16, so the total embedding length is 16∗8=128 and the output matrix dimension is 1∗m∗n. Then, the auxiliary information (m−1)·n is added through the flattening operation to extend the length to m·n, where m represents the input length, n indicates the potential feature length, and the embedding layer input scale extends from (1,1, n) to (1, m, n).The feature extraction layer uses GMF and MLP to extract linear and nonlinear relationships between the learners and the course, the GMF model takes the implicit feature vector point multiplication of the user and the project as the output result, and the MLP model connects the flattening results beginning to end as the output results into the neural network. The activation function of the neural network adopts the ReLU function [16].The pooling layer adopts the maximum pooling adjusted feature size so that the output vector of the GMF model and the MLP model reaches the same size through the pooling layer.The feature splice layer was splicing to splicing the feature information extracted from the GMF and MLP models. The attention layer assigns the splice weights and inputs the assignment results into the neural network layer. The neural network layer loss function follows the cross-entropy loss function of the DCF model, adjusted for by backpropagation of the weights of each layer [17]. The output layer follows the sigmoid function as an activation function and maps the output values to a certain range for recommendation.


## 3.1. ADCF Mathematical Model

The mathematical model of the ADCF model is as follows:(8)PcGMF=c0GMF⊕c1GMF⊕c2GMF⊕c3GMF,PlGMF=l0MLP⊕l1MLP⊕l2MLP⊕l3MLP,qcMLP=c0MLP⊕c1MLP⊕c2MLP⊕c3MLP,φGMF=PlGMFΘqcGMF,φMLP=∂LWLT∂L−1...∂2W2rqcMLPplMLP+b2...+bL,Aout=Soft maxφMLPφEGMFΘφMLPφEGMF,y^k=σhTAout+b.In the formula,⊕ represents connections; liGMF and liMLP represent the learner eigenvectors of the GMF and MLP models, l0,l1,l2,l3, respectively, corresponding to {learner_id, sex, profession, job}; ciGMF and ciMLP represent the course resource eigenvectors of the models, c0,c1,c2,c3, respectively, corresponding to curriculum_id, name, complexity, label; the piGMF, piMLP, qcGMF, and qcMLP represent the learner and course resource feature vector with auxiliary information for the GMF and MLP models; φMLP and φEGMF, respectively, represent the underlying feature relationships learned through the MLP and GMF models. From the model, the whole model process uses the learner and course auxiliary information, which jointly determines the prediction recommendation performance of the model.


## 3.2. Online Learning Resource Recommendation Based on ADCF

From the above analysis, the online learning resource recommendation model based on ADCF is designed, as shown in Figure2. The model input layer includes the relevant information of the learner and the course, whose input form is the behavioral sequence of the learner-course X=X1,X2,X3,...XN. Among these, Xi represents the ith behavior Learneri,Coursei. Learneri contains information about learners’ ID, gender, occupation, and Coursei contains course ID, label, name, etc.Figure 2
Resource recommendation based on ADCF.The encoding layer transforms input information via one hot to embedding feature demo [15]. Taking learner sex as an example, male is coded as [1, 0] and female as [0, 1].The embedding layer first initializesa embedding matrix about sex, with a matrix size of 2∗d, where 2 indicates possible sex values and d indicates the embedding dimension. With the above operation, the intractable category feature is able to be converted into tractable vectors. For course and learner features, encoding includes course ID, name, complexity, tag, and learner ID, gender, major, occupation. Embedding corresponds to a length of 16, so the total embedding length is 16∗8=128 and the output matrix dimension is 1∗m∗n. Then, the auxiliary information (m−1)·n is added through the flattening operation to extend the length to m·n, where m represents the input length, n indicates the potential feature length, and the embedding layer input scale extends from (1,1, n) to (1, m, n).The feature extraction layer uses GMF and MLP to extract linear and nonlinear relationships between the learners and the course, the GMF model takes the implicit feature vector point multiplication of the user and the project as the output result, and the MLP model connects the flattening results beginning to end as the output results into the neural network. The activation function of the neural network adopts the ReLU function [16].The pooling layer adopts the maximum pooling adjusted feature size so that the output vector of the GMF model and the MLP model reaches the same size through the pooling layer.The feature splice layer was splicing to splicing the feature information extracted from the GMF and MLP models. The attention layer assigns the splice weights and inputs the assignment results into the neural network layer. The neural network layer loss function follows the cross-entropy loss function of the DCF model, adjusted for by backpropagation of the weights of each layer [17]. The output layer follows the sigmoid function as an activation function and maps the output values to a certain range for recommendation.


## 4. Simulation Experiment

### 4.1. Experimental Environment Construction

This experiment was carried out on the NVIDIA distributed framework and CUDA parallel computing platform with Selenium + Web Driver, installation of Chorme80.03987.132, compilation environment Python3.6, compiler PyCharm, and dependent module Requests2.21.0, Beautiful Soup, Selenuim, etc.


### 4.2. Data Preprocessing

Considering the large number of crawled datasets, computer-class-related data were selected to construct experimental datasets, and learners with interactions greater than 20 were selected as the main study subjects. Through statistical collation, 878 computer courses, 3,066 learners, and 203,987 learner history data were obtained. The distribution of course interaction number and number of learners is shown in Figure3.Figure 3
The number of learners distributed across the range of interaction numbers.


### 4.3. Dataset Construction

Online learning resource recommendation is actually a disclassification problem of predicting whether a learner will learn course [18]. Online learning resource recommendation is actually a disclassification problem of predicting whether a learner will learn course [18, 19]. If the missing samples in the dataset are taken by default to positive samples, it can easily lead to an unbalanced dataset. Therefore, to solve this problem, this paper selects some samples as negative samples by random uniform sampling from the missing values.Considering the certain sequence relationship between learner history learning records, the firstn−1 records were used as the training set and the last effective interaction n as the test set. The model was trained by using the training set, and its performance was detected using the validation set. The validation set consists of 100 courses and splicing test set data randomly drawn from the no-interaction course. For experimental convenience, the batch size trained by the model is set to the effective number of interactions n−1 per learner.


### 4.4. Evaluating Indicator

Hit Ratio, HR and Normalized Discounted Cumulative Gain, and NDCG were used as the indicators to evaluate model performance, calculated as formula (9) and formula (10) [20–22]:(9)HitRatio@K=Number Of Hits@KGT×100%,(10)NDCGk=DCGkIDCGk,(11)IDCGk=∑i=1k11og21+i,(12)DCGk=∑i=1k2reli−11og2i+1,(13)CGk=∑i=1kreli.In equation (9), HitRatio @K represents the hit rate, the number of tests predicted in the Top-k list per learner, and the denominator represents the number of test sets. In equation (10) ∼ equation (13), i represents the position in the recommended list; k represents the k value in Top-k; CGk represents the cumulative gain; and reli represents the correlation of the recommended result in position i. In this paper, reli = 1 indicates hits, and reli = 0 indicates misses. DCGk represents the cumulative damage gain, so when reli = 1, DCGk is calculated as formula (14) and when reli = 0, DCGk is calculated as formula (15). IDCGk represents the idealized loss gain, with all predicted hits, reli = 1, so the IDCGk calculation method can be rewritten as in formula (16).(14)DCGk=∑i−1k21−11og2i+1=∑i−1k1og21ogi+1,(15)DCGk=∑i−1k20−11og2i+1=0,(16)IDCGk=∑i−1k11og21+i.


### 4.5. Parameter Setting

In this experiment, the model learning rate was set at 0.001, the number of iterations was 20, and the predicted number wask = 10. The model adopts the cross-entropy loss function, which is calculated by the formula as follows [23, 24]:(17)LY,PY|X=−1ogPY|X=−1N∑i−1N∑j−1Myij1ogPij.In the formula,X represents the input variable, Y the output variable, L the loss function, N the input sample size, and M the number of possible categories. The yij is a binary indicator indicating whether the category j enters the real category of the instance xi. The pij represents the probability that the model predicts that the input instance xi belongs to the category j. In this paper, the recommendation results include recommendations and disapproval, which are indicated by 1 and not by 0. Thus, formula (17) can be overwritten as(18)Lloss=1N∑i−1Nyi1ogpi+1+yi1og1−pi.In the formula,yi represents the real category of the input instance xi, pi indicates the probability that the predicted input instance xi belongs to category 1, and L (loss) represents the logarithmic loss average for each sample. The cross-entropy function is used to measure the similarity of yi and pi.


### 4.6. Experimental Result

#### 4.6.1. Analysis of Parameters on Model Performance

This experiment was used to explore the influence of different parameters on the model performance. Figures4 and 5 are the changes in the HR and NDCG indicators at the different number of iterations, respectively. According to the figure, with the same number of iterations, the DCF and ADCF models performed better on the HR and NDCG indicators compared to the IUNeu and NeuCF models, and the DCF and ADCF models also showed better and more stable performance with the number of iterations increasing. The proposed ADCF model adds the attention mechanism to extract the features and perform the best.Figure 4
The effect of different iterations on model HR.Figure 5
Effect of the different iterations on model NDCG.For different recommended coursesk, the recommended performance of different models is Figures 6 and 7. As shown in the figure, increased with k values, the HR and NDCG metrices of the ADCF, DCF, and NeuCF models were gradually increased, showing that the model recommendation effect is getting better. At the same k values, the ADCF model outperformed the DCF model than the NeuCF and the IUNeu model and the ADCF model, showing that the ADCF model recommended the best effect. Thus, it shows that the proposed ADCF model recommends the best performance.Figure 6
Index comparison of HR Model at differentk values.Figure 7
Comparison of the model NDCG indicators at differentk values.HR and NDCG indicators for different models under different negative sampled num-neg values are compared in Figures8 and 9, respectively. From the figure, the value range of negative sampling n is [1, 10], and the recommended effect of different models is optimal when n = 4. Overall, the proposed ADCG model has smaller fluctuations in the HR and NDCG metrics as compared to the DCF and NeuCF models. This shows that the overall ADCF model generally has better recommended performance.Figure 8
The effect of the different num-neg on model HR.Figure 9
Effects of the different num-neg on model NDCG.


#### 4.6.2. Model Performance Analysis

To validate the performance of the proposed model, the test results of different models such as IUNeu, NeuCF, and DCF were tested with the proposed models on the experimental dataset, as shown in Table1. According to the table, the proposed model performs best on the HR and NDCG indicators, reaching 0.626 and 0.339, compared to the IUNeu model, respectively; HR and NDCG indicators increased 1.79% and 1.86%, respectively; compared with the NeuCF, it was increased by 2.17% and 2.32% on the HR and NDCG indicators, respectively; compared to the DCF models, it was increased by 1.31% and 1.25%, respectively.Table 1
Comparison of the results of the different algorithms on the experimental datasets.
Serial numberAlgorithmHR@10NDCG@10Loading data time (s)Time1ADCF0.6260.33914.312.9 s (training) + 2.3 s (test)2DCF0.6130.32612.512.4 s (training) + 1.8 s (test)3lUNeu0.6080.32012.311.4 s (training) + 2.1 s (test)4NeuCF0.5980.31711.111.2 s (training) + 1.4 s (test)5ConvNCF0.5460.29216.916.9 s (training) + 2.6 s (test)In terms of time indicators, the proposed ADCF model has improved both the training time and the validation time of the dataset compared to the comparison model; compared to the DCF and NeuCF models, the average total training time increased by 1 s and 2.6 s, the average total validation time per iteration was increased by 0.5 s and 0.2 s, respectively. The reason for the analysis is that the proposed model introduces an attention mechanism in the characteristic splicing layer, so its temporal performance decreases, but the overall effect is small.


## 4.1. Experimental Environment Construction

This experiment was carried out on the NVIDIA distributed framework and CUDA parallel computing platform with Selenium + Web Driver, installation of Chorme80.03987.132, compilation environment Python3.6, compiler PyCharm, and dependent module Requests2.21.0, Beautiful Soup, Selenuim, etc.


## 4.2. Data Preprocessing

Considering the large number of crawled datasets, computer-class-related data were selected to construct experimental datasets, and learners with interactions greater than 20 were selected as the main study subjects. Through statistical collation, 878 computer courses, 3,066 learners, and 203,987 learner history data were obtained. The distribution of course interaction number and number of learners is shown in Figure3.Figure 3
The number of learners distributed across the range of interaction numbers.


## 4.3. Dataset Construction

Online learning resource recommendation is actually a disclassification problem of predicting whether a learner will learn course [18]. Online learning resource recommendation is actually a disclassification problem of predicting whether a learner will learn course [18, 19]. If the missing samples in the dataset are taken by default to positive samples, it can easily lead to an unbalanced dataset. Therefore, to solve this problem, this paper selects some samples as negative samples by random uniform sampling from the missing values.Considering the certain sequence relationship between learner history learning records, the firstn−1 records were used as the training set and the last effective interaction n as the test set. The model was trained by using the training set, and its performance was detected using the validation set. The validation set consists of 100 courses and splicing test set data randomly drawn from the no-interaction course. For experimental convenience, the batch size trained by the model is set to the effective number of interactions n−1 per learner.


## 4.4. Evaluating Indicator

Hit Ratio, HR and Normalized Discounted Cumulative Gain, and NDCG were used as the indicators to evaluate model performance, calculated as formula (9) and formula (10) [20–22]:(9)HitRatio@K=Number Of Hits@KGT×100%,(10)NDCGk=DCGkIDCGk,(11)IDCGk=∑i=1k11og21+i,(12)DCGk=∑i=1k2reli−11og2i+1,(13)CGk=∑i=1kreli.In equation (9), HitRatio @K represents the hit rate, the number of tests predicted in the Top-k list per learner, and the denominator represents the number of test sets. In equation (10) ∼ equation (13), i represents the position in the recommended list; k represents the k value in Top-k; CGk represents the cumulative gain; and reli represents the correlation of the recommended result in position i. In this paper, reli = 1 indicates hits, and reli = 0 indicates misses. DCGk represents the cumulative damage gain, so when reli = 1, DCGk is calculated as formula (14) and when reli = 0, DCGk is calculated as formula (15). IDCGk represents the idealized loss gain, with all predicted hits, reli = 1, so the IDCGk calculation method can be rewritten as in formula (16).(14)DCGk=∑i−1k21−11og2i+1=∑i−1k1og21ogi+1,(15)DCGk=∑i−1k20−11og2i+1=0,(16)IDCGk=∑i−1k11og21+i.


## 4.5. Parameter Setting

In this experiment, the model learning rate was set at 0.001, the number of iterations was 20, and the predicted number wask = 10. The model adopts the cross-entropy loss function, which is calculated by the formula as follows [23, 24]:(17)LY,PY|X=−1ogPY|X=−1N∑i−1N∑j−1Myij1ogPij.In the formula,X represents the input variable, Y the output variable, L the loss function, N the input sample size, and M the number of possible categories. The yij is a binary indicator indicating whether the category j enters the real category of the instance xi. The pij represents the probability that the model predicts that the input instance xi belongs to the category j. In this paper, the recommendation results include recommendations and disapproval, which are indicated by 1 and not by 0. Thus, formula (17) can be overwritten as(18)Lloss=1N∑i−1Nyi1ogpi+1+yi1og1−pi.In the formula,yi represents the real category of the input instance xi, pi indicates the probability that the predicted input instance xi belongs to category 1, and L (loss) represents the logarithmic loss average for each sample. The cross-entropy function is used to measure the similarity of yi and pi.


## 4.6. Experimental Result

### 4.6.1. Analysis of Parameters on Model Performance

This experiment was used to explore the influence of different parameters on the model performance. Figures4 and 5 are the changes in the HR and NDCG indicators at the different number of iterations, respectively. According to the figure, with the same number of iterations, the DCF and ADCF models performed better on the HR and NDCG indicators compared to the IUNeu and NeuCF models, and the DCF and ADCF models also showed better and more stable performance with the number of iterations increasing. The proposed ADCF model adds the attention mechanism to extract the features and perform the best.Figure 4
The effect of different iterations on model HR.Figure 5
Effect of the different iterations on model NDCG.For different recommended coursesk, the recommended performance of different models is Figures 6 and 7. As shown in the figure, increased with k values, the HR and NDCG metrices of the ADCF, DCF, and NeuCF models were gradually increased, showing that the model recommendation effect is getting better. At the same k values, the ADCF model outperformed the DCF model than the NeuCF and the IUNeu model and the ADCF model, showing that the ADCF model recommended the best effect. Thus, it shows that the proposed ADCF model recommends the best performance.Figure 6
Index comparison of HR Model at differentk values.Figure 7
Comparison of the model NDCG indicators at differentk values.HR and NDCG indicators for different models under different negative sampled num-neg values are compared in Figures8 and 9, respectively. From the figure, the value range of negative sampling n is [1, 10], and the recommended effect of different models is optimal when n = 4. Overall, the proposed ADCG model has smaller fluctuations in the HR and NDCG metrics as compared to the DCF and NeuCF models. This shows that the overall ADCF model generally has better recommended performance.Figure 8
The effect of the different num-neg on model HR.Figure 9
Effects of the different num-neg on model NDCG.


### 4.6.2. Model Performance Analysis

To validate the performance of the proposed model, the test results of different models such as IUNeu, NeuCF, and DCF were tested with the proposed models on the experimental dataset, as shown in Table1. According to the table, the proposed model performs best on the HR and NDCG indicators, reaching 0.626 and 0.339, compared to the IUNeu model, respectively; HR and NDCG indicators increased 1.79% and 1.86%, respectively; compared with the NeuCF, it was increased by 2.17% and 2.32% on the HR and NDCG indicators, respectively; compared to the DCF models, it was increased by 1.31% and 1.25%, respectively.Table 1
Comparison of the results of the different algorithms on the experimental datasets.
Serial numberAlgorithmHR@10NDCG@10Loading data time (s)Time1ADCF0.6260.33914.312.9 s (training) + 2.3 s (test)2DCF0.6130.32612.512.4 s (training) + 1.8 s (test)3lUNeu0.6080.32012.311.4 s (training) + 2.1 s (test)4NeuCF0.5980.31711.111.2 s (training) + 1.4 s (test)5ConvNCF0.5460.29216.916.9 s (training) + 2.6 s (test)In terms of time indicators, the proposed ADCF model has improved both the training time and the validation time of the dataset compared to the comparison model; compared to the DCF and NeuCF models, the average total training time increased by 1 s and 2.6 s, the average total validation time per iteration was increased by 0.5 s and 0.2 s, respectively. The reason for the analysis is that the proposed model introduces an attention mechanism in the characteristic splicing layer, so its temporal performance decreases, but the overall effect is small.


## 4.6.1. Analysis of Parameters on Model Performance

This experiment was used to explore the influence of different parameters on the model performance. Figures4 and 5 are the changes in the HR and NDCG indicators at the different number of iterations, respectively. According to the figure, with the same number of iterations, the DCF and ADCF models performed better on the HR and NDCG indicators compared to the IUNeu and NeuCF models, and the DCF and ADCF models also showed better and more stable performance with the number of iterations increasing. The proposed ADCF model adds the attention mechanism to extract the features and perform the best.Figure 4
The effect of different iterations on model HR.Figure 5
Effect of the different iterations on model NDCG.For different recommended coursesk, the recommended performance of different models is Figures 6 and 7. As shown in the figure, increased with k values, the HR and NDCG metrices of the ADCF, DCF, and NeuCF models were gradually increased, showing that the model recommendation effect is getting better. At the same k values, the ADCF model outperformed the DCF model than the NeuCF and the IUNeu model and the ADCF model, showing that the ADCF model recommended the best effect. Thus, it shows that the proposed ADCF model recommends the best performance.Figure 6
Index comparison of HR Model at differentk values.Figure 7
Comparison of the model NDCG indicators at differentk values.HR and NDCG indicators for different models under different negative sampled num-neg values are compared in Figures8 and 9, respectively. From the figure, the value range of negative sampling n is [1, 10], and the recommended effect of different models is optimal when n = 4. Overall, the proposed ADCG model has smaller fluctuations in the HR and NDCG metrics as compared to the DCF and NeuCF models. This shows that the overall ADCF model generally has better recommended performance.Figure 8
The effect of the different num-neg on model HR.Figure 9
Effects of the different num-neg on model NDCG.


## 4.6.2. Model Performance Analysis

To validate the performance of the proposed model, the test results of different models such as IUNeu, NeuCF, and DCF were tested with the proposed models on the experimental dataset, as shown in Table1. According to the table, the proposed model performs best on the HR and NDCG indicators, reaching 0.626 and 0.339, compared to the IUNeu model, respectively; HR and NDCG indicators increased 1.79% and 1.86%, respectively; compared with the NeuCF, it was increased by 2.17% and 2.32% on the HR and NDCG indicators, respectively; compared to the DCF models, it was increased by 1.31% and 1.25%, respectively.Table 1
Comparison of the results of the different algorithms on the experimental datasets.
Serial numberAlgorithmHR@10NDCG@10Loading data time (s)Time1ADCF0.6260.33914.312.9 s (training) + 2.3 s (test)2DCF0.6130.32612.512.4 s (training) + 1.8 s (test)3lUNeu0.6080.32012.311.4 s (training) + 2.1 s (test)4NeuCF0.5980.31711.111.2 s (training) + 1.4 s (test)5ConvNCF0.5460.29216.916.9 s (training) + 2.6 s (test)In terms of time indicators, the proposed ADCF model has improved both the training time and the validation time of the dataset compared to the comparison model; compared to the DCF and NeuCF models, the average total training time increased by 1 s and 2.6 s, the average total validation time per iteration was increased by 0.5 s and 0.2 s, respectively. The reason for the analysis is that the proposed model introduces an attention mechanism in the characteristic splicing layer, so its temporal performance decreases, but the overall effect is small.


## 5. Conclusion

In this paper, an attention-based deep collaborative online learning resource recommendation method is proposed; it can realize the accurate recommendation of online learning resources. Compared with the proposed former DCF model, the proposed ADCF model was improved by 1.31% and 1.25% on the HR and NDCG indicators, respectively; compared with the IUNeu and NeuCF models, the proposed ADCF model was improved by 1.79% and 1.86%, 2.17%, and 2.32% on the HR and NDCG metrics, respectively, which has some practical application value. This paper presents a preliminary study of online learning resource recommendation, but the study is still in its infancy, and there are some problems to be improved. For example, when there is one feature fusion method, a splicing method is adopted, while there are many feature fusion methods, different fusion methods are suitable for different models. Therefore, multiple ways should be explored to choose the best fusion methods. Next step, it will be optimized from the above deficiencies to further improve the recommendation effect of online learning resources.



---

*Source: 3199134-2022-03-24.xml*