# Improved Personalized Recommendation Algorithm Based on Context-Aware in Mobile Computing Environment

Authors: Fei Long
Journal: Wireless Communications and Mobile Computing
 (2020)

---

## Abstract

With the development and popularization of e-commerce and Internet, more and more attention has been paid to personalized recommendation for users. The traditional user interest model only considers the user’s behavior on the project, ignoring the user’s context at that time. Pointing to the shortage that context-related factors are not considered in previous works, combining the characteristics of a mobile computing environment, this paper studies the algorithm and model of mobile service recommendation. A recommendation algorithm based on specified context filtering in mobile computing environment is proposed. The context of the classification is aggregated, by grouping the scenarios of the same category together. Through experiments, we found that the improved personalized recommendation algorithms are superior to the common collaborative filtering algorithm.


---

## Body

## 1. Introduction

The data included information of major websites and mobile APPs. If the data had given a certain treatment, the information could have been more user-friendly and more efficient. Meanwhile, users would have been provided with a friendly experience, and the information provided could have had higher revenue [1]. So, the recommendation system came into being.The recommendation algorithm is the important part of the recommendation system [2]. The main recommendation algorithms are collaborative filtering recommendation algorithm, content-based recommendation algorithm, and hybrid recommendation algorithm [3–8]. In-depth research on the recommendation system allows users to get personalized recommendations, which greatly saved them time to search for information. At the same time, while the recommendation system is being improved, the user’s personalized demand for recommendation gets higher and higher; more accurate recommendation is the future development direction [9]. The improved recommendation algorithm on the existing algorithm is a lot, so many scholars turning to the context-aware recommendation [10–15]. The context information becomes an essential role to enhance the effect of the recommendation.The introduction of context information brings more ideas to improve the efficiency of the recommendation algorithm. The main context information includes user context information, such as users’ ages, occupation, region; physical context, such as location, weather, time. There is much context information that could be considered by recommendation algorithm [16]. The context information can bring more accurate recommendations to the users of the recommendation system. There are three commonly used context-aware recommendation methods, and they are contextual prefiltering, contextual postfiltering, and contextual modeling [17]. As a result, the context-aware recommendation algorithm has gradually become a popular research trend. In this paper, combining the characteristics of the mobile computing environment, a recommendation algorithm based on specified context filtering in mobile computing environment is proposed.The reminder of this paper is structured as follows: Section2 introduces the related work. In Section 3, it proposes the conceptual model of context-awareness based on the context-aware recommendation system theory. Section 4 proposed a context-based recommendation algorithm in the mobile computing environment. Section 5 presents the experimental process and results. The summary of the related work of our proposed model and algorithm and the conclusion of the paper are given in Section 6.


## 2. Related Work

After the introduction of the collaborative filtering algorithm, scholars have more research on the recommendation system. The most important recommendation algorithms are a collaborative filtering algorithm and content-based recommendation algorithm [18]. However, there are certain problems hard to be solved in the two basic algorithms, such as collaborative filtering algorithm has a cold start and high sparsely, and content-based recommendation algorithm is difficult to deal with multiple attributes. Therefore, the accuracy of a single recommendation algorithm recommendation is difficult to improve [19]. Many scholars have shifted their goals from traditional recommendation algorithms, focusing on the research of context-based recommendation systems [20].Foreign researches have been quite rich. The research direction and application fields include shopping, tourism, catering, and other aspects. But they focused on proposing improved algorithms, which are based on traditional algorithms. The contrast of advantages and disadvantages of various algorithms based on context perception is relatively rare. The fields and data types applicable to different context-aware algorithms are not studied. Among them, Kang et al. [21] proposed not only paying attention to the explicit context information but also implicit context information. And they used packet sniffing technique. Kwona and Kim [22] proposed a way to discover the user’s portrait by depicting the user’s outline tree. Tuan et al. [23] combined user preferences and contextual interaction information and proposed a location-based advertising recommendation algorithm. Sánchez-Pi et al. [24] proposed the construction of a knowledge-based context-aware system. Sánchez-Pi et al. [25] proposed a localized adaptive modification model using a vector space model and saved time to obtain user-related information.Lee et al. [26] proposed a novel TV system that combines gesture control, tag ranking, and context-awareness, providing personalized recommendations. Cai et al. [27] used collaborative filtering to generate a contextual concept ontology. Ji et al. [28] proposed an improved matrix approximate based on the clustering model. Wang et al. [29] proposed a hierarchical recommendation model based on a context tree structure, calculated situation transfer in the first layer, and recommended items in the second layer. Unger et al. [30] made a breakthrough in the acquisition of contexts, improving the accuracy of recommendations by extracting implicit context information from users’ data.


## 3. Conceptual Model of Context-Awareness

### 3.1. Classification of Context Information

The so-called context information is a general concept, which can be divided into user context information, physical context information, time context information, network context information, and so on. The user context information includes some personal information, such as users’ gender, age, region, occupation, and mood. The physical context information includes geographical location, temperature, and weather. The time context information includes season, morning or evening, and weekend or working day. The acquisition of this context information is conducive to better recommendation. If the system had those contexts, it could recommend suitable advertisements according to the geographical location, suitable music according to emotions, and decide whether videos are automatically loaded according to the network speed.As shown in Figure1, the types of context information currently defined are very diverse, but not all context information is readily available. The application of the context-aware algorithm is based on context acquisition. The shallow-level situation acquisition technology can already be achieved. The mobile device can obtain the user’s latitude and longitude position, weather conditions, time information, etc., and can obtain the user’s further information through the survey, such as age and gender. However, deep-level information processing is relatively rare at present, such as obtaining the user’s location type and time type. Deep context information is helpful for the recommendation algorithm. In the current research, that information is mainly obtained through users’ voluntary survey.Figure 1
The classification of context.


### 3.2. Model Construction

Related research on the context information recommendation is increasing, and the situation plays an important role in the personalized recommendation. Under the scope of user interests, there are some drifts in different context interests, and better recommendation can be obtained by studying the changes in the situation. At present, the context-aware model has a relatively consistent definition.Context information is a collection of information about users, generally denoted byC, which is C=c1,c2,c3,⋯cn, representing a set of contexts. And cj denotes a context element in the set, while n denotes a common n context element. The classification of context information has been as described in Section 3.1. Some of the context in Section 3.1 can be selected into the set C to form the contextual collection of this paper. The influence of some context information on the recommendation model can be explored.The context-aware recommendation model mainly collects the user’s context information, historical behavior tendency, personal preference, and other information. Through filtering and calculating, they can be applied to personalized recommendations to provide with more accurate recommendations.As showed in Figure2, the context-awareness recommendation model can be divided into three layers. The first layer is the data acquisition layer, which collects various types of data of users. The second layer is the data processing layer, which filters and processes the data. The third layer is the recommended service layer, which is operated by the algorithm to form a personalized recommendation. The association of services at each level provides a means of contextual awareness.Figure 2
Context-awareness recommendation model.In the traditional recommendation algorithm, the score matrix is associated with user and item, called user-item model, expressed asU×I⟶R. U represents the user set, U=u1,u2,u3,⋯un, and I indicates the item set, I=i1,i2,i3,⋯im. R denotes a score set; rij denotes a score of the user ui for the item ij. n denotes the number of users, and m denotes the number of items. The above formulas constitute a two-dimensional score matrix between the user and the item and can be operated using a collaborative filtering algorithm to obtain a recommended result.In the context-awareness recommendation model, the context factor is introduced, which is no longer a two-dimensional model, that is, it becomes a user-item-context model, expressed asU×I×C⟶R. U represents the user collection, U=u1,u2,u3,⋯un. I denotes a set of items, I=i1,i2,i3,⋯im. C denote a set of contexts, C=c1,c2,c3,⋯ck. n denotes the number of users, m denotes the number of items, and k indicates the number of situations. The meaning of R is still the user’s rating of the project.In the three-dimensional model, the score is represented as each of the small cubes that are segmented out. The cube in the three-dimensional coordinate system is the set of scoring data R.


## 3.1. Classification of Context Information

The so-called context information is a general concept, which can be divided into user context information, physical context information, time context information, network context information, and so on. The user context information includes some personal information, such as users’ gender, age, region, occupation, and mood. The physical context information includes geographical location, temperature, and weather. The time context information includes season, morning or evening, and weekend or working day. The acquisition of this context information is conducive to better recommendation. If the system had those contexts, it could recommend suitable advertisements according to the geographical location, suitable music according to emotions, and decide whether videos are automatically loaded according to the network speed.As shown in Figure1, the types of context information currently defined are very diverse, but not all context information is readily available. The application of the context-aware algorithm is based on context acquisition. The shallow-level situation acquisition technology can already be achieved. The mobile device can obtain the user’s latitude and longitude position, weather conditions, time information, etc., and can obtain the user’s further information through the survey, such as age and gender. However, deep-level information processing is relatively rare at present, such as obtaining the user’s location type and time type. Deep context information is helpful for the recommendation algorithm. In the current research, that information is mainly obtained through users’ voluntary survey.Figure 1
The classification of context.


## 3.2. Model Construction

Related research on the context information recommendation is increasing, and the situation plays an important role in the personalized recommendation. Under the scope of user interests, there are some drifts in different context interests, and better recommendation can be obtained by studying the changes in the situation. At present, the context-aware model has a relatively consistent definition.Context information is a collection of information about users, generally denoted byC, which is C=c1,c2,c3,⋯cn, representing a set of contexts. And cj denotes a context element in the set, while n denotes a common n context element. The classification of context information has been as described in Section 3.1. Some of the context in Section 3.1 can be selected into the set C to form the contextual collection of this paper. The influence of some context information on the recommendation model can be explored.The context-aware recommendation model mainly collects the user’s context information, historical behavior tendency, personal preference, and other information. Through filtering and calculating, they can be applied to personalized recommendations to provide with more accurate recommendations.As showed in Figure2, the context-awareness recommendation model can be divided into three layers. The first layer is the data acquisition layer, which collects various types of data of users. The second layer is the data processing layer, which filters and processes the data. The third layer is the recommended service layer, which is operated by the algorithm to form a personalized recommendation. The association of services at each level provides a means of contextual awareness.Figure 2
Context-awareness recommendation model.In the traditional recommendation algorithm, the score matrix is associated with user and item, called user-item model, expressed asU×I⟶R. U represents the user set, U=u1,u2,u3,⋯un, and I indicates the item set, I=i1,i2,i3,⋯im. R denotes a score set; rij denotes a score of the user ui for the item ij. n denotes the number of users, and m denotes the number of items. The above formulas constitute a two-dimensional score matrix between the user and the item and can be operated using a collaborative filtering algorithm to obtain a recommended result.In the context-awareness recommendation model, the context factor is introduced, which is no longer a two-dimensional model, that is, it becomes a user-item-context model, expressed asU×I×C⟶R. U represents the user collection, U=u1,u2,u3,⋯un. I denotes a set of items, I=i1,i2,i3,⋯im. C denote a set of contexts, C=c1,c2,c3,⋯ck. n denotes the number of users, m denotes the number of items, and k indicates the number of situations. The meaning of R is still the user’s rating of the project.In the three-dimensional model, the score is represented as each of the small cubes that are segmented out. The cube in the three-dimensional coordinate system is the set of scoring data R.


## 4. Context-Awareness Recommendation

### 4.1. Specific-Context Based Recommendation Algorithm

In the same situation, the user’s choice may have similarities. Based on this theory, the algorithm experiment can be further developed. When exploring the context factors, this paper selects three types of situations for classification. There is an inclusion relationship between single-situation factors and multisituation factors, such as context (at home), including (weekend, weekday, and holiday), and (alone, with friends, with family, and with lovers). It is actually compound context information. Through the aggregation of context information, it is explored whether there is consistency in user selection in the context of aggregation.This algorithm is a context-based prefiltering algorithm, which is a process of context selection. The algorithm aims at transforming the three-dimension model into a two-dimension model through context filtering. The score prediction function,Ru,i,cshould be represented as the following formula (1):
(1)Ru,i,c=Ru,ic1=x,c2=y,c3=z,where Ru,i,c represents the score matrix in the three-dimensional model, and the threshold of the context set indicates that the context information is c=<x,y,z>.Ru,i is the estimated score according to the collaborative filtering algorithm based on the user’s similarity in a given situation.After getting the score matrix, the similarity between users is calculated. The Pearson correlation coefficient calculation should be represented as the following formula (2):
(2)simu,vu,i=∑i∈Iuvrui−ru¯rvi−rv¯∑i∈Iuvrui−ru¯2∑i∈Iuvrvi−rv¯2,where rui represents the score of a user u for item i. ru¯ represents the average value of a user u score. rvi represents the score of a user v for item i. rv¯ represents the average value of a user v score. By calculating their similarities, the similarity matrix is formed as below:
(3)sim=s11s12⋯s21s22⋯⋯⋯⋯s1ms2m⋯sm1sm2⋯smm.Having got the similarities of user’s interests, the predicted score can be calculated by the following formula (4).
(4)pui=∑v∈Vrvi−rv¯×simu,v∑v∈Vsimu,v.The predicted score determines the degree of user interest. The higher the score is, the more the user is interested in. The process of Algorithm 1 can be summarized as follows:Algorithm 1: Specific-context based recommendation algorithm.
Input: score matrixOutput: context-based predicted score matrixForitemi∈I:Forcj∈C:IfCitemi=Ci&Ci∈cj:Moveitemi to Sfor item∈S:calculatesimu,vu,i=∑i∈Iuvrui−ru¯rvi−rv¯∑i∈Iuvrui−ru¯2∑i∈Iuvrvi−rv¯2pui=∑v∈Vrvi−rv¯×simu,v∑v∈Vsimu,v


### 4.2. User-Based Contextual Recommendation Algorithm

In the algorithm proposed above, the context information is a separate factor. The context information is not incorporated into the algorithm model, so the contextual modeling algorithm is proposed.The contextual modeling algorithm is divided into heuristic and model. There are many literature and papers in the research of contextual modeling algorithms based on models. It is not the focus of this paper. The algorithm proposed in this paper integrates the context information and processesU×I×C⟶R three-dimension model. We propose a user-based contextual recommendation model.The user-based context is scoring matrixU×C⟶R is constructed, and the method and steps are the same as before. According to the formula for calculating the Pearson correlation coefficient, calculate the user’s context similarity.
(5)simu,vc=∑c∈Cuvruc−ru¯rvc−rv¯∑c∈Cuvruc−ru¯2∑c∈Cuvc−rv¯2.In the algorithm, we use usera as an example to predict its score on the item i in the context c. The nearest neighbor of user a needs to be found, and the user similarity matrix can be obtained by substituting the required data into the formula. Among all the obtained user similarities, the top-N similar users are selected as the nearest neighbors, and the score of the item i under the situation c is predicted based on the score data of these users.In order to obtain the rating of the useru under the context c, we find the rating context set of the most neighboring user for the item i. The weighting operation is performed in combination with the user similarity and the context similarity obtained in the foregoing.
(6)p=k∑u∈Usima,u×Ru,i,cx×simcx,c,where k=1/∑u∈Csima,u×simcx,c. sima,u is user’s similarity, and simcx,c is similarity between target context and current context.The result of the scoring can be obtained. The algorithm is based on the user’s contextual modeling algorithm, and the context plays an essential role in the model. The algorithm is described as following:Algorithm 2: User-based contextual algorithm.
Input: score matrixOutput: predictionsfor each item:score = mean (scoreiUi=u&Cj=c)for each item (U,C):simu,vc=∑c∈Cuvruc−ru¯rvc−rv¯∑c∈Cuvruc−ru¯2∑c∈Cuvc−rv¯2for each user:simu,vu,i=∑i∈Iuvrui−ru¯rvi−rv¯∑i∈Iuvrui−ru¯2∑i∈Iuvrvi−rv¯2for top-N users:for c in C(top-N):p=k∑u∈Usima,u×Ru,i,cx×simcx,c,k=1/∑u∈Csima,u×simcx,c


### 4.3. Item-Based Contextual Recommendation Algorithm

The user-based heuristic contextual model is discussed above, and the algorithm to be discussed is similar with that. Item-based contextual recommendation model is also a recommendation algorithm based on context modeling.Firstly, in order to build the item-based context matrixI×C⟶R, the user’s information needs to be transformed first. We calculate the average score of the same item in the same situation.
(7)rc1,i1rc2,i1⋯rc1,i2rc2,i2⋯⋯⋯⋯rcj,i1rci,i2⋯rc1,inrc2,in⋯rcj,in.Then, we calculate context similarity based on items using Pearson formula.(8)simu,vc=∑c∈Cuvruc−ru¯rvc−rv¯∑c∈Cuvruc−ru¯2∑c∈Cuvc−rv¯2.In the algorithm, we use usera as an example to predict its score on the item i in the context c. The nearest neighbor of user a needs to be found, and the item similarity matrix can be obtained by substituting the required data into the formula. Among all the obtained item similarities, the top-N similar items are selected as the nearest neighbors, and the score of the item i under the situation c is predicted based on the score data of these items.In order to obtain the rating of the itemi under the context c, we find the rating context set of the most neighboring item for the context c. The weighting operation is performed in combination with the item similarity and the context similarity obtained in the foregoing.
(9)p=k∑j∈Isimi,j×Ra,i,cx×simcx,c,k=1/∑u∈Csimi,j×simcx,c. simi,j is item’s similarity, and simcx,c is similarity between target context and current context.Algorithm 3: Item-based contextual algorithm.
Input: score matrixOutput: predictionsfor each user:score = mean (scoreiIk=i&Cj=c)for each user (I,C):calculatesimu,vc=∑c∈Cuvruc−ru¯rvc−rv¯∑c∈Cuvruc−ru¯2∑c∈Cuvc−rv¯2for each item:calculatesimu,vu,i=∑i∈Iuvrui−ru¯rvi−rv¯∑i∈Iuvrui−ru¯2∑i∈Iuvrvi−rv¯2for top-N items:for c in C(top-N):p=k∑j∈Isimi,j×Ra,i,cx×simcx,c, k=1/∑j∈Isimi,j×simcx,c


## 4.1. Specific-Context Based Recommendation Algorithm

In the same situation, the user’s choice may have similarities. Based on this theory, the algorithm experiment can be further developed. When exploring the context factors, this paper selects three types of situations for classification. There is an inclusion relationship between single-situation factors and multisituation factors, such as context (at home), including (weekend, weekday, and holiday), and (alone, with friends, with family, and with lovers). It is actually compound context information. Through the aggregation of context information, it is explored whether there is consistency in user selection in the context of aggregation.This algorithm is a context-based prefiltering algorithm, which is a process of context selection. The algorithm aims at transforming the three-dimension model into a two-dimension model through context filtering. The score prediction function,Ru,i,cshould be represented as the following formula (1):
(1)Ru,i,c=Ru,ic1=x,c2=y,c3=z,where Ru,i,c represents the score matrix in the three-dimensional model, and the threshold of the context set indicates that the context information is c=<x,y,z>.Ru,i is the estimated score according to the collaborative filtering algorithm based on the user’s similarity in a given situation.After getting the score matrix, the similarity between users is calculated. The Pearson correlation coefficient calculation should be represented as the following formula (2):
(2)simu,vu,i=∑i∈Iuvrui−ru¯rvi−rv¯∑i∈Iuvrui−ru¯2∑i∈Iuvrvi−rv¯2,where rui represents the score of a user u for item i. ru¯ represents the average value of a user u score. rvi represents the score of a user v for item i. rv¯ represents the average value of a user v score. By calculating their similarities, the similarity matrix is formed as below:
(3)sim=s11s12⋯s21s22⋯⋯⋯⋯s1ms2m⋯sm1sm2⋯smm.Having got the similarities of user’s interests, the predicted score can be calculated by the following formula (4).
(4)pui=∑v∈Vrvi−rv¯×simu,v∑v∈Vsimu,v.The predicted score determines the degree of user interest. The higher the score is, the more the user is interested in. The process of Algorithm 1 can be summarized as follows:Algorithm 1: Specific-context based recommendation algorithm.
Input: score matrixOutput: context-based predicted score matrixForitemi∈I:Forcj∈C:IfCitemi=Ci&Ci∈cj:Moveitemi to Sfor item∈S:calculatesimu,vu,i=∑i∈Iuvrui−ru¯rvi−rv¯∑i∈Iuvrui−ru¯2∑i∈Iuvrvi−rv¯2pui=∑v∈Vrvi−rv¯×simu,v∑v∈Vsimu,v


## 4.2. User-Based Contextual Recommendation Algorithm

In the algorithm proposed above, the context information is a separate factor. The context information is not incorporated into the algorithm model, so the contextual modeling algorithm is proposed.The contextual modeling algorithm is divided into heuristic and model. There are many literature and papers in the research of contextual modeling algorithms based on models. It is not the focus of this paper. The algorithm proposed in this paper integrates the context information and processesU×I×C⟶R three-dimension model. We propose a user-based contextual recommendation model.The user-based context is scoring matrixU×C⟶R is constructed, and the method and steps are the same as before. According to the formula for calculating the Pearson correlation coefficient, calculate the user’s context similarity.
(5)simu,vc=∑c∈Cuvruc−ru¯rvc−rv¯∑c∈Cuvruc−ru¯2∑c∈Cuvc−rv¯2.In the algorithm, we use usera as an example to predict its score on the item i in the context c. The nearest neighbor of user a needs to be found, and the user similarity matrix can be obtained by substituting the required data into the formula. Among all the obtained user similarities, the top-N similar users are selected as the nearest neighbors, and the score of the item i under the situation c is predicted based on the score data of these users.In order to obtain the rating of the useru under the context c, we find the rating context set of the most neighboring user for the item i. The weighting operation is performed in combination with the user similarity and the context similarity obtained in the foregoing.
(6)p=k∑u∈Usima,u×Ru,i,cx×simcx,c,where k=1/∑u∈Csima,u×simcx,c. sima,u is user’s similarity, and simcx,c is similarity between target context and current context.The result of the scoring can be obtained. The algorithm is based on the user’s contextual modeling algorithm, and the context plays an essential role in the model. The algorithm is described as following:Algorithm 2: User-based contextual algorithm.
Input: score matrixOutput: predictionsfor each item:score = mean (scoreiUi=u&Cj=c)for each item (U,C):simu,vc=∑c∈Cuvruc−ru¯rvc−rv¯∑c∈Cuvruc−ru¯2∑c∈Cuvc−rv¯2for each user:simu,vu,i=∑i∈Iuvrui−ru¯rvi−rv¯∑i∈Iuvrui−ru¯2∑i∈Iuvrvi−rv¯2for top-N users:for c in C(top-N):p=k∑u∈Usima,u×Ru,i,cx×simcx,c,k=1/∑u∈Csima,u×simcx,c


## 4.3. Item-Based Contextual Recommendation Algorithm

The user-based heuristic contextual model is discussed above, and the algorithm to be discussed is similar with that. Item-based contextual recommendation model is also a recommendation algorithm based on context modeling.Firstly, in order to build the item-based context matrixI×C⟶R, the user’s information needs to be transformed first. We calculate the average score of the same item in the same situation.
(7)rc1,i1rc2,i1⋯rc1,i2rc2,i2⋯⋯⋯⋯rcj,i1rci,i2⋯rc1,inrc2,in⋯rcj,in.Then, we calculate context similarity based on items using Pearson formula.(8)simu,vc=∑c∈Cuvruc−ru¯rvc−rv¯∑c∈Cuvruc−ru¯2∑c∈Cuvc−rv¯2.In the algorithm, we use usera as an example to predict its score on the item i in the context c. The nearest neighbor of user a needs to be found, and the item similarity matrix can be obtained by substituting the required data into the formula. Among all the obtained item similarities, the top-N similar items are selected as the nearest neighbors, and the score of the item i under the situation c is predicted based on the score data of these items.In order to obtain the rating of the itemi under the context c, we find the rating context set of the most neighboring item for the context c. The weighting operation is performed in combination with the item similarity and the context similarity obtained in the foregoing.
(9)p=k∑j∈Isimi,j×Ra,i,cx×simcx,c,k=1/∑u∈Csimi,j×simcx,c. simi,j is item’s similarity, and simcx,c is similarity between target context and current context.Algorithm 3: Item-based contextual algorithm.
Input: score matrixOutput: predictionsfor each user:score = mean (scoreiIk=i&Cj=c)for each user (I,C):calculatesimu,vc=∑c∈Cuvruc−ru¯rvc−rv¯∑c∈Cuvruc−ru¯2∑c∈Cuvc−rv¯2for each item:calculatesimu,vu,i=∑i∈Iuvrui−ru¯rvi−rv¯∑i∈Iuvrui−ru¯2∑i∈Iuvrvi−rv¯2for top-N items:for c in C(top-N):p=k∑j∈Isimi,j×Ra,i,cx×simcx,c, k=1/∑j∈Isimi,j×simcx,c


## 5. Experiment Analysis

The hardware environment of this experiment is the Intel Core i5 processor, 8G memory. The software environment is the 64-bit Windows operating system, VMware Workstation Pro virtual machine, Cent OS7 operating system, Open JDK1.8, Python3.7, Anaconda for Python3.7, and PyCharm-community.The data of this experiment is mainly from the questionnaire survey of college students about the context information of watching movies. A total of 107 users’ data is collected. In order to guarantee the accuracy of the algorithm, some invalid questionnaires are eliminated. The data of 96 users were retained, including 2145 data.The quality of the recommendation system is mainly measured by some indicators. The accuracy of the prediction is extremely important in the recommendation system. It is mainly judged by Root Mean Squared Error (RMSE) and Mean Absolute Error (MAE).(10)RMSE=1N∑i=1Nreali−predicti2,MAE=1N∑i=1Nreali−predicti.The root mean square error and the mean absolute error are both the degree of deviation between the calculated predicted value and the true value. The value obtained by subtracting the predicted value from the true value is recalculated, and the larger the obtained result value, the greater the degree of deviation. On the contrary, the more accurate the prediction of the algorithm is. When judging the merits and demerits of the algorithm according to these two parameters, the value is expected to be small.The traditional prediction algorithm is set as the control object of this experiment, so that the latter experiment is compared with the experimental results obtained by the two-dimensional algorithm.In this paper, the user-based collaborative filtering algorithm is selected. According to the Pearson similarity coefficient, the nearest neighbor of the movie is calculated and we use them to predict. Several classical collaborative filtering algorithms and its improved algorithms are selected, which are KNN basic, KNN means, KNN Zscore, and KNN baseline, respectively, which represent the basic collaborative filtering algorithm, the collaborative filtering algorithm based on the scoring average, the collaborative filtering algorithm based on scoring standardization, and the collaborative filtering algorithm based on baseline scoring. At the same time, in order to avoid the contingency error, each of the following experiments set a five-fold cross-validation, and the obtained results were evaluated using the values of RMSE and MAE.In the collaborative filtering algorithm, the recommended precision depends on the number of nearest neighbors. In this paper, four values are selected as the representative, and the differentk values represent the maximum number of nearest neighbors.According to Tables1 and 2, the KNN baseline algorithm (the collaborative filtering algorithm based on the baseline score) is obviously inferior to the other algorithms, indicating that it does not fit for the problem. So, we omit it in the following experiments.Table 1
Traditional algorithms’ RMSE.
k=5k=10k=15k=20KNN basic1.4021.3121.2931.319KNN means1.2921.2461.3621.301KNN Zscore1.3111.3191.3631.405KNN baseline2.5452.4482.3912.422Table 2
Traditional algorithms’ MAE.
k=5k=10k=15k=20KNN basic1.0520.9810.9540.987KNN means0.9430.9240.9760.991KNN Zscore0.9700.9620.9791.003KNN baseline2.0651.9621.9511.874It can be observed in Figures3 and 4 that the pros and cons of the algorithm are not always the same. Under different k values, the prediction effect of the recommendation algorithm changes. Overall, the increase of the maximum number of neighbors is accompanied by the prediction accuracy. It rises first and then falls. If the value is selected approximately, the prediction works best. The basic collaborative filtering has larger RMSE and MAE values when the k value is smaller, but it shows an advantage when the k exceeds 10. The other two algorithms also show advantages when k is less than 15, and the collaborative filtering algorithm based on scoring standardization is always better than the collaborative filtering algorithm based on scoring average.Figure 3
Algorithms’ RMSE.Figure 4
Algorithms’ MAE.In order to implement the recommendation algorithm based on the specific context, we initially screened and organized the data set. As shown in Figure5, the context information has an inclusive relationship. The collection of context information is like a forest. Here, we choose three attributes of watching movies, and they are time, place, and company, forming three trees. There are parent nodes and their branches, each of which, respectively, represents the specific movie-watching behavior.Figure 5
The tree of context.We select 6 to 12 context information to aggregate and the results are as follows.According to the Table3, this resulted in an aggregation of six different contexts, namely, at home, at the cinema, one person, on weekends, on weekdays, and on holidays. The selected situation has to be in conformity with the logic of reality. Usually, in this context information, the frequency of people watching movies will increase. For each context environment, we use the collaborative filtering algorithm to predict and get the recommended results in this context. For the different nearest neighbors number, we will get different results in Tables 4 and 5.Table 3
Results after aggregation.
NumberContextItem number1Home13182Theater8263Alone9724Weekend8295Weekday8806Holiday435Table 4
RMSE.
K=5K=10K=15K=20Home1.1401.1771.3591.142Theater1.4041.4091.3921.375Weekday1.3911.3591.3611.283Alone1.1931.2081.2031.132Weekends1.2811.2451.2331.271Holiday1.2521.2201.2051.209Table 5
MAE.
K=5K=10K=15K=20Home0.8370.8630.8340.838Theater1.0621.0361.0451.025Weekday1.0111.0091.0040.940Alone0.8710.8760.8600.865Weekends0.9710.9340.9160.955Holiday0.9180.8900.8740.871The performance of several selected contextual effects is different, in order to more intuitively observe the advantages and disadvantages of the algorithm and compare with those traditional collaborative filtering algorithm.Through the above experimental results, it can be observed that the smaller the value of RMSE and MAE, the better the prediction effect. Conversely, the recommended algorithm is less effective. In Figure6, the solid line indicates the result obtained by the conventional algorithm, and the broken line indicates the result obtained by the improved precontextual filtering algorithm.Figure 6
Contrast of the specific contexts.In different situations, the performance of the algorithm is not the same. In the above six contexts, there are four contexts that are better than the traditional algorithm regardless of the value of the nearest neighbor. They are at home, one person, on weekends, and on holidays, and the best values for recent neighbors in different situations are not the same. The other two contexts, in the cinema and on the working day, do not apply to the precontextual filtering algorithm, and the prediction effect obtained is not as good as the traditional collaborative filtering algorithm. At the same time, it can be seen that the maximum value of the nearest neighbor have little influence on the algorithm.


## 6. Summary and Future Work

In this paper, context-based recommendation algorithms are proposed and implemented. In the comparison between the proposed algorithm and the traditional algorithm, the new algorithm is better than the traditional algorithm as a whole, but the new algorithm is not applicable in some contexts. Among the six contexts obtained after aggregation, only four contexts are superior to the common ones, and the other two contexts are not good enough to apply to the algorithm.



---

*Source: 8857576-2020-10-05.xml*