IoT Service Recommendation Scheme Based on Matter Diffusion

With the development of Internet of Things(IoT), more and more smart devices and services appeared in people’s life. These services make life more convenient, while it is difficult for people, especially the elderly, to find them in time, because they are widely distributed in great numbers with small sizes. In order to solve this problem, the service recommendation scheme, which is becoming increasingly important, needs to be used in IoT. However, the traditional web service recommendation schemes are not suitable for the IoT, because they rely more on the historical information rather than the energy state or the user’s habit attributes, which are important for IoT. We research the service recommendation scheme, finding that the service recommendation process in IoT is a process of matter flows, which follows the conservation of matter. Therefore, we propose the service recommendation scheme based on tripartite graph with matter diffusion and use the habit feature as a dynamic tag. Based on the balance of matter, we use the positive and negative matter diffusion results on the tripartite as the recommendation results. The results of our evaluation show that the performance of the service recommendation scheme is improved in the precision and recall.


I. INTRODUCTION
Nowadays, a large number of intelligent devices are integrated with sensors, thus enabling them to detect real-time user behavior features and environment information. In our previous research, we used the smart switch, environment sensor and smart bracelet to record user's daily activities and extract the habits of user' using electrical equipment [1]. We discovered that the habits of users' using electrical appliance could be classified into the fixed-length habit and the timing habit for the first time. In addition, there were different relationships between habits, such as selection, sequence, cross, parallel, inclusion, beginning, and finish. In addition, we translated the habits into the service rules by SWRL, and realized the automatic control of the smart home equipment based on the service rules of habits [2]. The good habits could be spread as a culture in the smart home, so the services based on the habits could be recommended to others as well. For example, in the smart ward the patient with good habits The associate editor coordinating the review of this manuscript and approving it for publication was Miguel Jesus Torres Ruiz. likes going to bed early and getting up early would achieve better rehabilitation results. This habit is associated with turning light on and off, therefore, the services of turning light on and off on time could be recommended to others. All in all, we researched the service recommendation scheme for such services to help people find the services in time.
The service in IoT is different from the traditional web service in user characteristics, constraint of energy, trust correlation, social relationship, etc. The IoT services come from the habits of users [2], and they will have user characteristics such as department, age, name, etc. The services in IoT usually rely on smart devices with limited power, but they may stop providing service content when the energy is exhausted, therefore they are called energyconstrained. In the IoT, the user prefers to use the trusted services. The services trusted by most users would have high trust value, therefore they are called trust correlation. The services would have social relations such as leadermember relationship, ownership relationship, etc. These relationships come from their owners, thus they have social relationship.

P. Wang: IoT Service Recommendation Scheme Based on Matter Diffusion
Therefore, the service recommendation scheme should take account of these new features of service in IoT. However, the traditional web service recommendation schemes [3]- [6] like content-based filtering approach, collaborative filtering method and hybrid system approach are not suitable for the IoT. The traditional service recommendation schemes are mainly aimed at the Internet environment, and recommend the corresponding items to the users based on their previous evaluations, access records or preferences. However, in the IoT environment, the users rarely evaluate the service after using the corresponding IoT device services, therefore, the services cannot be recommended through the evaluation records of the previous users.

A. RESEARCH CONTRIBUTIONS
In this paper, we consider the service recommendation process in IoT as a process of matter diffusion. The energy state is regarded as the matter. The services with more matter would be easier to be recommended to users. The main contributions to the research for this work are summarized as follows.
• This paper proposes a IoT service recommendation scheme based on tripartite graph with matter diffusion. We treat the energy as the matter and believe that the IoT service recommendation process follows the conservation of matter for the first time.
• We chose the users' habit behavioral features about how they used the IoT device service as the dynamic tag, and we further built the complete tripartite graph network with matter diffusion based on the dynamic tags, the users and the IoT services. In the tripartite graph network, we could get the service's matter value more efficiently by the calculation of positive and backward matter diffusion value.
• The performance of the proposed technique was evaluated and compared with the existing model with respect to various performance metrics.

B. ORGANIZATION
The rest of the paper is structured as follows: Section II discusses the related work; Section III presents the service recommendation framework; Section IV presents the evaluation of the proposed model based on different performance metrics; Section V presents the conclusions of this research.

II. RELATED WORK A. SERVICE RECOMMENDATION SCHEME IN WEB SERVICE
The service recommendation system, which is a tool automatically connecting users and items, recommends the service to the interested user, and is widely used in e-commerce, video websites, social networking, etc. There are three main types of recommendation algorithms in web service, namely content-based recommendation algorithm [7]- [9], collaborative filtering algorithm(CF) [10]- [14], and graph-based recommendation algorithm [15]- [17]. CF techniques use a database of user preferences for items to predict additional topics or products a new user might like [18]. [19] used the user rating data to calculate the similarity of users or items and made the predictions or recommendations according to the similarity values. The memory-based CF methods are notably deployed into commercial systems such as http://www.amazon.com/, because they are easy to implement effectively [20], [21]. Customization of CF systems for each user decreases the search effort for users. It also promises a greater customer loyalty, higher sales, more advertising revenues, and the benefit of targeted promotions [21]. However, the CF needs to update the dataset of user's hobbies in real time, which is difficult to be achieved in the IoT, because it is difficult to obtain the user's interest in time.
The content-based recommendation is based on the text of the item and the historical access record [9], and it recommends the items that are similar to the items previously used by the user. The major difference between CF and content-based recommendation systems is that CF only uses the user-item ratings data to make predictions and recommendations, while content-based recommendation systems rely on the features of users and items for predictions [22]. The content-based recommendation algorithm needs to calculate the item similarity, so it is not suitable for IoT because the time complexity is too high.
The graph based on recommendation algorithm has been widely used in recommendation system. The PageRank algorithm of Google, which is based on graph [23], achieves a better effect on sorting web pages. The tripartite graph is built in [24] which is based on user, resource and tag. It uses the unified tagging information to reveal user's behaviors and preferences, extracts the latent semantic relations among items to make the recommendations. The tag could include different types of message such as position, environment, hobby, etc. These information could comprehensively describe the context information which is important for the recommendation results. The graph based on recommendation is also used in the [25]- [27], and gets better recommendation effects. The IoT service recommendation needs more attributes than traditional web service recommendation, such as trust, social relationship, energy, geography position, etc, which are seldom used in web service recommendation, however, they are important in IoT service recommendation.

B. SERVICE RECOMMENDATION SCHEME IN IoT
At present, the researches on IoT service recommendation are still in its early stage. The IoT service has some new characteristics such as user characteristics, constraint of energy, and trust correlation. The IoT service recommendation scheme should take these characteristics into consideration. The IoT service recommendation framework was proposed in [28], [29], using the similarity calculation results of users and smart devices. The service recommendation system based on the formal model was proposed in [30]. As the first attempt, this paper puts forward a kind of hyper graph model, which is used to model the time and space correlation of the IoT, in which each edge connects the user,  the objects and the service. However, the paper does not consider things' own properties, such as the energy state, the time and spatial relevance of things. The attribute relationship and energy-aware mechanism were first used in [31] for the service recommendation, in which each node is a provider of information/services as well as a requester or presenter of the information service. Requesting a particular service, the node should broadcast the request information on the network and then select the appropriate node. Each node maintains a transactional history and brief profiles. The node with high trust relationship and energy state will be recommended to the user. In [32], the authors use cognitive reasoning into the social IoT for the recommendation of everyday tasks. Tag is used to describe the different kinds of information in the Internet service recommendation system, such as user's topic preferences as well as the content of items [33]. In [37]- [39], the authors use the lightweight situation aware for the service composition. In the IoT service recommendation, tag could have many definitions such as human feature, environment feature and situation, but it has seldom been applied in IoT service recommendation.

III. SERVICE RECOMMENDATION FRAMEWORK
In our previous researches, we extracted the user's habits of using electrical equipment [1] in smart home, and translated them into the IoT services [2] which realized the automatic control of the smart home. For example, the TV set service could turn on TV according to the user's habits. In order to recommend these services to other persons in the smart home, we propose the service recommendation framework as shown in Fig.1. The framework mainly includes three parts, namely habit abstract, service rule generation, and service recommendation scheme. The user's daily behaviors are recorded by different kinds of sensors. The habit abstract module extracts the user's habits and habit set by the scheme in [1], and translates them into the service rules in service rule generation module by the scheme in [2]. The behavioral feature services which are based on the habit and habit set would be recommended to users in service recommendation scheme module by the service recommendation scheme based on matter diffusion on tripartite graph.

A. BEHAVIORAL FEATURE SERVICE
The service which is consistent with user's habit is called behavioral feature service, which is very common in the smart home. For example, the user is used to turning the light on at eight o' clock every day, and we could collect this habit and translate it into a kind of behavioral feature service [1], [2]. The formal definition of a behavioral feature service status at time t can be represented as follows.

Definition 1 (Behavioral Feature Service): The behavioral feature service is based on the user's habit. Given a behavioral feature service S k , its status at time t is S k
DevSet is the device set in the smart space, H k ⊂ HabitSet, and HabitSet is the habits which make up the services. T k (t) is the trust status of the service at time t.
The habit feature is obtained from the on/off or time series of the activity adjustment, which is shown in Fig.2. An activity is a pair of on/off operation or an operation regulation. In Fig.2, the capital letters without being underlined stand for the on operation, the lowercase letter stands for the off operation, and the underlined capital letters stand for the  operation regulation. The subscript represents the monitoring period and time.

B. TRIPARTITE GRAPH WITH DYNAMIC TAG
The behavioral feature services use different kinds of habits as the service rules. The habits contain the information about the activities such as type of people, location, time, operation, etc. These information is useful to IoT service recommendation. For example, the person's early rising habit usually happens in the morning in the bedroom with the light on. When a new person come into the smart home, we could recommend the behavioral feature service to him based on the location, age, time, etc. These information is seldom used in the tradition web service recommendation, but is important for IoT service recommendation. The tag could carry more information, and it could be used to describe different kinds of information in the Internet service recommendation system, such as user's topic preferences as well as the content of items [33]. In order to recommend the popular behavioral feature service to the user, we could label the service with the habit and recommend the service with tag based on service recommendation scheme.
We use the habit as a kind of dynamic tag, and construct a tripartite graph of user-dynamic tag-service. The dynamic tag of habit could well describe the time and environment characteristics which are important for Internet of things. Furthermore, the user's habit usually changes with time and environment, and the dynamic tag could describe it well. The formal definition of dynamic tag could be represented as follows.
Definition 2 (Dynamic Tag): The dynamic tag is based on the habit and it could be expressed as a triple which is < L s >:= (H s , O s , D s )|t s , e s , in which H k ⊂ HabitSet, which is the habits which make up the tag L s , O s is the operation sequence of the habit H s , D s ⊂ DevSet, which is the device set in the smart space, t s is the time characteristic of tag L s , and e s is the environment characteristic of tag L s .
We could see from the definition 2 that when the time and environment meet the condition of t s and e s , the recommendation system will show the dynamic tag L s . For example, when the humidity is higher than 60% between 7 o'clock and 8 o'clock in the morning, the recommendation system will show the dynamic tag of querying the humidity.
Based on the definition of dynamic tag, we further define the tripartite graph with dynamic tag as shown in Fig.3(a).
The tripartite consists of three bipartite graphs, including user-service, service-dynamic tag and dynamic tag-user. The user-service bipartite stands for the user' using the service directly, the service-dynamic tag bipartite stands for the service labeled by the dynamic tag, and the dynamic tag-user stands for the dynamic tag used by the user. The tripartite graph has two directions including service->dynamic tag-> user bipartite graph as shown in Fig.3(b) and service-> user->dynamic tag as shown in Fig.3(c). There are some relationships among users, services and dynamic tag, such as the usage and the annotation. To describe these relationships, we propose the edge weight ω, ϕ and θ shown in Fig.3.
The edge weight is related to the historical usage record. For example, ω is the edge weight between service and user, standing for the state that the service is used by the user.
where u i is the history records between the two objects T i and S i or U i in the tripartite, h is the total records between the two objects T and S or U . In order to evaluate the weight value, we further use the delta rule [34] which is based on gradient descent to get the edge weight. The edge weight calculation algorithm is shown in Algorithm 1, which chooses the random weight vector w as the initial value, and gets the training samples by the o( x) = w • x. We get w i by Formula (2), where D is the training sample set, t d is the target output of the training sample d, o d is the output of the linear element to the training samples, x id is the input component x i of the linear element d, and η is the learning rate. initialize ω i by the random small number 2: initialize ω by 0 3: initialize the error rate k=100 4: while k > z do 5: do the following operation in the training sample < x, t >: The IoT devices which provided the data for the services are usually powered by the batteries. Therefore the energy is very important for the IoT service. We regard the energy as a kind of matter which is calculated by the energy surplus (ES) and the energy consumption (EC). The ES of the device c i could be described as Formula (3).
CE(c i ) stands for the current energy state of c i , and M (c i ) stands for the minimum energy of c i . The EC of the device c i could be described as Formula (4).
SEC(c i ) stands for the energy consumption rate of device c i , and T (c i ) stands for the execution time of device c i .
Based on the definition of ES(c i ) and EC(c i ), we further define the energy assessment of c i as Formula (5), We can see from the Definition 1 of behavioral feature service that one service always consists of several devices. If one service consists of n device, the energy assessment could be expressed as Formula (6): We can see from the Formula (6) that the service energy state depends on the device energy state which has minimum energy assessment.

D. SERVICE RECOMMENDATION SCHEME BASED ON MATTER DIFFUSION
We can see from the Fig.3 that the tripartite graph with dynamic tag has two directions, namely service → User → Dynamic Tag bipartite graph as shown in Fig.3(c) and Service → Dynamic Tag → User as shown in Fig.3(b). We name the direction form service to user in the bipartite as forward direction, and the direction from user to dynamic tag as backward direction. The process of service recommendation is accompanied by the flow of matter, such as the energy. Therefore, the recommendation process satisfies the law of mass conservation. Based on the edge weight Formula (1) and the tripartite in Fig.3, we could construct the matrix of user-service A PS , the matrix of user-dynamic tag A PK , and the matrix of dynamic-service A KS . In the tripartite, if there is an association between two entities, the weight should be showed in the matrix. For example, in the matrix A PS as shown in Fig.4, if the user P chooses the service S, the matrix element a ps = ω p,s , otherwise a ps = 0. The backward diffusion is the process: Service → User → Dynamic Tag. The backward diffusion process should first find the user who used the service, then the dynamic tags the user used, and finally the service labeled by the dynamic tag. The forward diffusion is the process: Service → Dynamic Tag → User. The forward diffusion process should first search for the service labeled by the dynamic tag, then the owner of the dynamic tag, and finally the service which the user used.

1) MATTER IN THE BACKWARD DIFFUSION
We assume the service set is S = {S 1 , S 2 , . . . , S x }, the user set is U = {U 1 , U 1 , . . . , U y }, and the dynamic tag set is T = {T 1 , T 1 , . . . , T z }, so the matter in the backward diffusion process could be expressed as follows: 1. The initial matter of service S i in the backward matter diffusion is f S i ; after the matter is diffused from the service to the user, the matter of the user U k is f U k ; the service set which is directly connected with the user U k is S = {s 1 , s 2 , . . . , s M }, and S ∈ S; the out-degree of service S i in the tripartite graph is N S i , of which S i ∈ S . The matter value of U k is: where Q s i U k is the weight between service S i and user U k in the matrix of service-user A PS . f S i is the matter value of S i in the backward diffusion. 2. After the matter diffusion of user-dynamic tag, the matter value of dynamic tag T L is f T L , the user set P. Wang: IoT Service Recommendation Scheme Based on Matter Diffusion directly connected with dynamic tag T L is U = {U 1 , U 2 , . . . , U L }, of which U ∈ U , and the out-degree of user U j is N U j , of which U j ∈ U . The matter value of dynamic tag T L is: where Q T L Uj is the weight value between user U j and dynamic tag T L in the matrix of A PK . f U j is the matter value of user U j . 3. After the matter diffusion of dynamic tag-service, the matter value of the service S i is f S i , and the dynamic tag set directly connected with service S i is T = {T 1 , T 2 , . . . , T P }, of which T ∈ T , and the out-degree of dynamic is N T r , of which T r ∈ T . The matter value of service S i is: where Q T r S i is the weight value between dynamic tag T r and service S i in the matrix of A KS . f T r is the matter value of the dynamic tag T r .

2) MATTER IN THE FORWARD DIFFUSION
We assume the service set is S = {S 1 , S 2 , . . . , S x }, the user set is U = {U 1 , U 1 , . . . , U y }, and the dynamic tag set is T = {T 1 , T 1 , . . . , T z }, so the matter in the forward diffusion process could be expressed as follows: 1. The initial matter of service S i in the forward matter diffusion is z S i , but after the matter diffusion of service-dynamic tag, the matter of dynamic tag T k is Z T k ; the service set which is directly connected with the dynamic tag T k is S = {S 1 , S 2 , . . . , S W }, of which S ∈ S; the out-degree of service S i in the tripartite graph is N S i , of which S i ∈ S . The matter value of T k is: where Q s i T k is the weight between dynamic tag T k and service S i in the matrix of dynamic tag-service A KS . 2. After the matter diffusion of dynamic tag-user, the matter value of user U L is Z U L , the dynamic set directly connected with user U L is T = {T 1 , T 2 , . . . , T O }, of which T ∈ T ; the out-degree of dynamic tag T y is N T y , of which T y ∈ T . The matter value of user U L is: where Q T y U L is the weight between user U L and dynamic tag T y in the matrix of dynamic tag-user A PK . 3. After the matter diffusion of user-service, the matter value of service S i is Z S i ; the user set directly connected with service S i is U = {U 1 , U 2 , . . . , U V }, of which U ∈ U ; the out-degree of user U r is N U r , of which U r ∈ U .
The matter value of service S i is: where Q U r S i is the weight between user U r and service S i in the matrix of service-user A PS . After the matter diffusion, the service S i 's matter value W s i could be obtained by the forward/backward diffusion parameter λ as shown in Formula (13), where λ ∈ [0, 1]. The service recommendation result is based on the matter value, and the service which has more matter could be given priority in recommendation.
In the end, we further propose the service recommendation algorithm based on the matter diffusion tripartite graph as shown in Algorithm (2).
In the algorithm, S i is described as is the initial matter value of service S i in the backward matter diffusion, Z S i is the initial matter value of service S i in the forward matter diffusion, N S i is the out-degree of S i in the forward matter diffusion, T is the tag set directly connected with S i in the backward matter diffusion, and T is the tag set directly connected with S i in the forward matter diffusion. The user U k is described the out-degree of user U k in the backward diffusion, N U k is the out-degree of user U k in the forward diffusion, S is the service set directly connected with user U k in the backward matter diffusion, and S is the service set directly connected with user U k in the forward matter diffusion.
To further explain the matter diffusion process in the tripartite graph, we give an example shown in Fig.5. We assume the initial matter values of the services S 1 , S 2 , S 3 are all 1, the edge weights of the tripartite are all 1, and the forward/backward matter diffusion parameter λ is 0.5. After the forward matter diffusion, the matter values of S 1 , S 2 , S 3 are 7/8, 3/2 and 5/8, respectively. After the backward matter diffusion, the matter values of S 1 , S 2 , S 3 are 28/24, 31/24 and 13/24, respectively. We use Formula (13) to get the comprehensive values of S 1 , S 2 , S 3 , which are 49/48, 67/48 and 28/48, respectively. If the recommendation list length is 1, we could choose S 2 as the candidate service.

IV. PERFORMANCE STUDY
In this section, first of all, we present the setup of our simulation. Then, we analyze the performance of service recommendation algorithm based on matter diffusion tripartite graph in different recommendation scenes, and use the precision/recall to measure the effectiveness of the service recommendation scheme. Finally, we find that the proposed algorithm could get good precision/recall when we recommend the service to the user who is familiar with the smart environment.

A. SIMULATION ENVIRONMENT
We build a smart home and the collect the operation records of the user using different electrical appliances. The deployment of electrical equipment and smart switch is shown in Fig.6. The smart home has eleven electrical appliances like light, air conditioner, printer, etc. Because these devices are unintelligent devices, we use the smart switches for on/off/adjustment operation. The switch's control core is microcontroller AT89C51, and the Wi-Fi model is ESP8266 which could be connected to the TXD port and RXD port of SCM for the serial communication. The electrical appliances could be controlled by the Android APP, and the app could communicate with the Wi-Fi model ESP8266.
In two months, we collected one volunteer's 1342 records of on/off/adjustment operations. Moreover, we generated 6530 records of other five users, which were similar to the volunteer's. We further extracted the users' habits and service rules by the methods in [1], [2]. In the same smart home, we chose another volunteer who was similar to the first volunteer, and the similarity is higher than the similar threshold ∝ [1]. In two months, we collected 2765 records of the second volunteer. We used the precision and recall to measure the effectiveness of the recommendations, and the definitions of precision and recall are shown in Formula (14), (15).
where R(u) is the recommendation list in the training set, and T (u) is the operation list in the test set. The precision is the possibility that the user is interested in the recommendation  service. The recall is the possibility that the user is interested in the service recommended.
In the experiment, we firstly determined the forward and backward diffusion parameter λ and the number of dynamic tags k. Then we used 7872 historical records as a training set, and chose the 2765 records of the second volunteer as the test set. We can see from histogram of precision, λ and k in Fig.7 that the recommendation precision is affected by λ and k. With the increasing of k, the recommendation precision is decreasing. When λ is 0.3 and k is 10, the recommendation precision reaches the maximum 35%. When λ is 0.1 and k is 20, the recommendation precision reaches the minimum 12%. Therefore, in the following experiments, we set λ to be 0.3 and k to be 10.
We divided the test set into two parts by month. In the same test set, we compared the service recommendation arithmetic based on matter diffusion tripartite graph with attribute similarity algorithm [35], namely MPSUO and ServRank [36].
The similarities of the attributes between the two users are calculated in the form of the cosine similarity, as shown in Formula (16) λ represents the consistency parameter of the must-same attribute set. The similar attribute set of the user S is M (s), and the similar attribute set of the user u j is M u j .
MPSUO is a popular service recommendation algorithm based on service, user and object, which could be described as Formula (17), where Y s,u is the popular service between service and user, Y s,o is the popular service between service and object, and β is the weight. In the experiment, we set β to be 0.5. ServRank arithmetic is originated from FolkRank which is a service recommendation arithmetic based on tripartite graph. ServRank could be described as Formula (18), where w is the adjacent matrix in the tripartite graph, A is the random value of the normalized column of w, and p is the preference vector. We set d to be 0.7 in the experiment. Fig.8 shows the result of the test set of the first month. When the recall is between 0.15 and 0.28, the attribute similarity algorithm has the highest precision. By analyzing the test set, we find that when the volunteer was just beginning to use the smart home, they tended to use the services similar   to their own attributes, because he was not familiar with the smart environment. Therefore, the attribute similarity algorithm could achieve good recommendation effect in the early stage. As the volunteer was gradually familiar with the environment, he would select other services which were not similar to his own attributes. Therefore, the yellow curve has a big fluctuation when the recall is between 0.15 and 0.28. We can see from Fig.8 that the gray curve of service recommendation arithmetic based on matter diffusion tripartite graph is higher than MPSUO and SerVRank. Although the service recommendation arithmetic based on matter diffusion tripartite graph does not have better effect than the attribute similarity algorithm in the early stage, its recommended stability is better. The precision/recall of service recommendation arithmetic based on matter diffusion tripartite graph and SerVRank are better than MPSUO, and they are all based on the tripartite graph. It also shows that the tripartite graph can comprehensively describe the relationship between users and services, realizing more accurate recommendations. In order to further verify the conclusion, we did the same comparative experiment in the test set of the second month. The experimental result is shown in Fig.9. In the second month, with the recall increasing, the attribute similarity algorithm has the lowest precision compared with the other three recommendation algorithms. The recommendation arithmetic based on matter diffusion tripartite graph and SerVRank has better recommendation results. Therefore, we find that the recommendation algorithm of attribute similarity is more suitable for the new users who just start using smart space. Once the user is familiar with the smart service in the smart home, the recommendation arithmetic based on matter diffusion tripartite graph would have better effect.

V. CONCLUSION
This paper studied the IoT service recommendation strategy, and obtained the recommendation list through the comprehensive calculation of the energy state, the user similarity, the bearing capacity, and the service resource value of the mass diffusion results. The corresponding theory was validated in the real experimental environment. In the following work, the author will continue to study other recommendation methods of the IoT.