# Service Recommendation with High Accuracy and Diversity

Authors: Shengqi Wu; Huaizhen Kou; Chao Lv; Wanli Huang; Lianyong Qi; Hao Wang
Journal: Wireless Communications and Mobile Computing
 (2020)

---

## Abstract

In recent years, the number of web services grows explosively. With a large amount of information resources, it is difficult for users to quickly find the services they need. Thus, the design of an effective web service recommendation method has become the key factor to satisfy the requirements of users. However, traditional recommendation methods often tend to pay more attention to the accuracy of the results but ignore the diversity, which may lead to redundancy and overfitting, thus reducing the satisfaction of users. Considering these drawbacks, a novel method called DivMTID is proposed to improve the effectiveness by achieving accurate and diversified recommendations. First, we utilize users’ historical scores of web services to explore the users’ preferences. And we use the TF-IDF algorithm to calculate the weight vector of each web service. Second, we utilize cosine similarity to calculate the similarity between candidate web services and historical web services and we also forecast the ranking scores of candidate web services. At last, a diversification method is used to generate the top-K recommended list for users. And through a case study, we show that DivMTID is an effective, accurate, and diversified web service recommendation method.


---

## Body

## 1. Introduction

In recent years, web services have developed rapidly and are playing an increasingly important role in E-commerce and virtual reality applications. With the increasing of Internet web services’ numbers, people have more access to Internet information anytime and anywhere. However, people need to deal with a large amount of information resources, which makes it difficult for people to quickly find valuable services which they are interested in. In other words, the selection process is complicated in the age of big data [1–4]. Therefore, precise recommendation of web services is the key issue in service computing. As we all know, the recommender system has been widely used in many applications, such as https://Amazon.com, https://TiVo.com, and https://Netflix.com [5]. And web service recommendation is a process of actively identifying suitable web services and recommending them to users. The most common method is traditional collaborative filtering [6].As we all know, collaborative filtering usually explores users’ preferences basing on users’ historical usage records and then recommends the most appropriate service items to users automatically [7]. However, this method mainly focuses on improving the accuracy of recommendation, which may lead to the redundancy of services in a limited list of top-K recommendations. Worse, the recommendation results may reduce users’ satisfaction and are not conducive to exploring users’ potential preferences for other services. For example, it is assumed that there is a certain service category with similar or related functions that match the interests of users and has better quality of services than other categories of services. Ordinary service recommendation methods may only recommend this category of services to users in the final recommended list, but from users’ points of view, recommendation services with similar functions are redundant, and this phenomenon is called overfitting. Accordingly, the recommender system should also pay attention to the diversity of service recommendations while ensuring a high accuracy of recommendation results. In this manner, other categories of services that users may be interested in can be included in the top-K recommended list [3, 8].Fortunately, diversification methods can not only avoid redundancy but also expand the range of users’ choices, which is beneficial to avoid the uncertainty in the prediction of users’ preferences [9]. However, there is a trade-off between accuracy and diversity [10] because high accuracy may often be obtained by safely recommending users the most popular and appropriate items, which can clearly lead to the reduction of diversity. And on the contrary, higher diversity can be achieved by trying to uncover and recommend highly idiosyncratic or personalized items with less data for each user, which will be more difficult to predict. And it may lead to the decrease of recommendation accuracy. Therefore, it is crucial for recommender systems to provide an optimal list of recommendations that takes into account both accuracy and diversity and to keep a balance between them [11–14]. This is also the main research direction of this paper. The main contributions of this paper are listed below:
(i)
A new web service recommendation method which pays attention to both accuracy and diversity is proposed(ii)
Providing users with the list of top-K service recommendations, our method improves the disadvantages of traditional service recommendation methods and effectively solves the problem of overfitting(iii)
Our method weighs well the double indicators of accuracy and diversity in order to achieve the best recommendation effect and improve users’ satisfactionThe remainder of this paper is organized as follows. Section2 describes a scenario of web service recommendation, and based on that, the main motivation and research content of this paper are further described. Section 3 presents the framework and specific steps of the proposed web service recommendation method (named DivMTID). Section 4 introduces a case study, where a specific case is solved by DivMTID. Section 5 summarizes this paper, draws conclusions, and expounds future work.


## 2. Research Scenario and Motivation

In this section, the research scenario and motivation of this paper are described. All the work we have done is based on the research scenario and motivation.


### 2.1. Research Scenario

Here, we use Figure1 to describe the research scenario in this paper. Suppose that a website has many different types of modules (entertainment, military, sports, life, finance, cars, games, films, shopping, etc.), and there are many different web services under each module. Assume that there are M web services used by a user under all modules, and they are recorded as WSu1, WSu2,…, WSuM. For each module, they are recorded as WSu1, WSu2,…, WSux (x is a variable). Meanwhile, there are N candidate web services recorded as WS1, WS2,…, WSN in the set of candidate services. And each web service is described by the Web Service Description Language (which is called the WSDL document). In order to describe it exhaustively, the symbols mentioned in this paper and their meanings are shown in Table 1.Figure 1
Research scenario.Table 1
Symbols and their meanings.
Symbol
Meaning
W
S
u
i
Web service i used in a user’s history
W
S
j
Candidate web service j
WSD
L
i
The WSDL documentation of web service i
M
The number of web services used in a user’s history
N
The number of candidate web services
r
i
A user’s rating of web service i used in history
M
j
Degree of a user’s preference for module j
a, b
Threshold setting
t
j
Thej-th word in the corpus
ω
The weight vector of web service
CosSi
m
i
,
j
The similarity level of web service i and web service j
Scor
e
j
The predicted ranking score of candidate web service j


### 2.2. Motivation

In this subsection, we utilize the example in Figure2 to demonstrate the motivation of our proposal. It is assumed that the recommender system intends to recommend a list of web services to a user. In this condition, to recommend appropriate web services to the user, the similarity between historical web services and candidate web services should be calculated first. And then the system generates the top-K recommended list to the user. However, in the process of similarity calculation and recommendation calculation, we will face the following challenges:Figure 2
A motivating example.When calculating the similarity between historical web services and candidate web services, it is necessary to establish the relationship between historical records and the candidate service set. However, an effective method to predict the relative score of candidate service objects and filter the candidate web services is needed.As the diversity of the recommended list is frequently neglected, the web services in the list may be similar to each other, which may lead to overfitting and failure to explore users’ potential preferences and finally reduce the users’ satisfaction.Considering the above issues, a novel web service recommendation method named DivMTID is proposed, which will achieve the accuracy and diversity of recommendation results, and it will be presented in detail in the following sections.


## 2.1. Research Scenario

Here, we use Figure1 to describe the research scenario in this paper. Suppose that a website has many different types of modules (entertainment, military, sports, life, finance, cars, games, films, shopping, etc.), and there are many different web services under each module. Assume that there are M web services used by a user under all modules, and they are recorded as WSu1, WSu2,…, WSuM. For each module, they are recorded as WSu1, WSu2,…, WSux (x is a variable). Meanwhile, there are N candidate web services recorded as WS1, WS2,…, WSN in the set of candidate services. And each web service is described by the Web Service Description Language (which is called the WSDL document). In order to describe it exhaustively, the symbols mentioned in this paper and their meanings are shown in Table 1.Figure 1
Research scenario.Table 1
Symbols and their meanings.
Symbol
Meaning
W
S
u
i
Web service i used in a user’s history
W
S
j
Candidate web service j
WSD
L
i
The WSDL documentation of web service i
M
The number of web services used in a user’s history
N
The number of candidate web services
r
i
A user’s rating of web service i used in history
M
j
Degree of a user’s preference for module j
a, b
Threshold setting
t
j
Thej-th word in the corpus
ω
The weight vector of web service
CosSi
m
i
,
j
The similarity level of web service i and web service j
Scor
e
j
The predicted ranking score of candidate web service j


## 2.2. Motivation

In this subsection, we utilize the example in Figure2 to demonstrate the motivation of our proposal. It is assumed that the recommender system intends to recommend a list of web services to a user. In this condition, to recommend appropriate web services to the user, the similarity between historical web services and candidate web services should be calculated first. And then the system generates the top-K recommended list to the user. However, in the process of similarity calculation and recommendation calculation, we will face the following challenges:Figure 2
A motivating example.When calculating the similarity between historical web services and candidate web services, it is necessary to establish the relationship between historical records and the candidate service set. However, an effective method to predict the relative score of candidate service objects and filter the candidate web services is needed.As the diversity of the recommended list is frequently neglected, the web services in the list may be similar to each other, which may lead to overfitting and failure to explore users’ potential preferences and finally reduce the users’ satisfaction.Considering the above issues, a novel web service recommendation method named DivMTID is proposed, which will achieve the accuracy and diversity of recommendation results, and it will be presented in detail in the following sections.


## 3. A Diversified Service Recommendation Method Based on TF-IDF

Under the research scenario of Section2, this paper proposes a new web service recommendation method named DivMTID, which is based on the TF-IDF algorithm. It utilizes cosine similarity and combines WSDL documents to calculate the ranking score of each candidate service and then uses the diversity algorithm to select the best web services from candidate services to set the top-K service recommended list. Meanwhile, it takes into account the accuracy and diversity of recommendation results. Table 2 lists the basic framework of DivMTID, which includes four steps.Table 2
The basic framework of DivMTID.
Step 1: explore users’ preferences approximately
By establishing the relationship between a user’s history score records and the information of the metadata module, the preference degree of each module is calculated, and the user’s preferences is approximately explored.
Step 2: calculate TF-IDF weight vectors of web services
Using the TF-IDF algorithm, the importance of words in the corpus to web services is calculated and finally represented by the TF-IDF weight vector in order to make a distinction among web services.
Step 3: predict the ranking scores of candidate services
The similarity between candidate web services and historically used web services is calculated by using cosine similarity, and the ranking score values of candidate web services are predicted.
Step 4: create a diversified web service recommended list
According to different index numbers,K different web services are selected to form multiple recommended lists. Then, it needs to calculate the list-diversity value of each list, and the list with the highest value becomes the web service recommended list that is finally recommended to the user.


### 3.1. Step 1: Explore Users’ Preferences Approximately

In step 1, we first make an approximate positioning of users’ preferences according to users’ historical score records. In order to give more effectively personalized service recommendations, we need to figure out what users like and why they like it. In other words, using more effective preference representation methods may make recommendation algorithms exhibit higher performance. In most service recommendation methods, a user’s score on web service can only represent the user’s opinion on a service, but the user’s preferences cannot be fully determined by a score record. However, a user’s historical score records can be used to make an approximate positioning of the user’s preferences. We can use the rating scores of web services to establish correlations with metadata and break the common limitation of expressing preferences with only one score.For example, under the scenario described in Section2, if a user rated 5 for all the web services under the module of military and rated 2 for all the web services under the module of finance, then the recommender system should infer that the user prefers the military module and should recommend more candidate web services about the military than finance.We can establish the correlation between history scores and the information of the metadata module in equation (1), which utilizes score records for web services to calculate a user’s preference degree for each module.
(1)Mj=∑i=rminrmaxri×nrservice‐ratednrservice‐used.In equation (1), Mj represents the degree of a user’s preference for module j. ri represents a user’s historical rating scores for the used web services. nrservice‐rated represents the number of web services which rated ri under the metadata module j, and nrservice‐used represents the number of all the used web services by the user under the metadata module j.We can calculate the user’s preference degree for the modules in equation (1) and make an approximate positioning of the user’s preference. A threshold “a” is set here, and the module with a calculated result greater than “a” is defined as the user’s preference module. For example, in the scenario of Section 2, we set a threshold 3. After calculation, if the modules with a result greater than 3 are military, finance, cars, and shopping, then the top-K recommended list should mainly consist of web services under these modules, which means that the modules below the threshold are automatically filtered out. At last, we put all the web services belonging to the preference modules together to form a set P. The above is the content of step 1, its pseudocode can be described by Algorithm 1.


### 3.2. Step 2: Calculate TF-IDF Weight Vectors of Web Services

The task of step1 in DivMTID is to determine users’ preferences, filtering out the web services under all modules with low history rating scores. It saves a lot of time for the subsequent recommendation algorithm to run. However, step 1 cannot exactly determine what kind of services users like, what characteristics the web services with high scores have, and how to select the best web services from so many candidate services. Step 2 is designed to solve these problems. It is assumed that step 1 filtered outL web services together.As is mentioned, each web service in set P has a corresponding WSDL document, the same as candidate services. Then, all meaningful words in the WSDL documents of all services can form a corpus. After that, a well-known TF-IDF algorithm [8, 15] is used to assess the importance of words in the corpus for each web service. The importance is proportional to the number of times that words appear in the document and inversely proportional to the frequency of words appearing in the corpus. The explanation is as follows.tf represents the word frequency, indicating the frequency of a word appearing in a WSDL document. It can be described in
(2)tftj,WSDLi=freqtj,WSDLiWSDLi.tj represents the j-th word in the corpus and WSDLi represents the WSDL document of the i-th web service. Freqtj,WSDLi represents the number of times that tj appears in the WSDLi document, and ∣WSDLi∣ represents the number of words that appear in the WSDLi document. So we can also get the equation WSDLi=∑jfreqtj,WSDLi.idf represents the inverse document frequency. It is expressed by the ratio of the total number of all WSDL documents and the number of documents containing the word. We can calculate the logarithm of the quotient in
(3)idftj,WSDLi=log2WSDLWSDLi:tj∈WSDLi.∣
WSDL
∣ represents the total number of WSDL documents. And ∣WSDLi:tj∈WSDLi∣represents the total number of documents containing word tj.we use TF-IDF to assess the importance of words in a corpus for a web service. If a word appears with high frequency in a WSDL document of a web service and appears with low frequency in other WSDL documents of services, then we suppose that the word has a high importance and representativeness for this web service, which can be used to classify and distinguish different services.Since WSDL documents are generally short, this paper chooses to give higher weight to theidf value to normalize the inherent bias with
(4)ω=tftj,WSDLi∗idf2tj,WSDLi.The common way to implement TF-IDF is to give the same weight to word frequency and the inverse document frequency. However, this paper gives higher weight toidf in order not only to standardize the inherent deviation of the tf measurement in short documents but also to better exclude the common words that frequently appear in web services in the corpus [16]. In this way, it can improve the classification and differentiation ability among web services and so improve the accuracy of a user’s preferences. ω represents the calculation result. It is the TF-IDF weight of word tj to web services, which means the importance of word tj for web services. Utilizing all the words in the corpus, we calculate the TF-IDF weight of a web service by equation (4) to form the weight vector of a certain web service. We candidate the TF-IDF weight vectors of all web services in the set P, denoted as ωi, i=u1,u2,⋯,uM−L. Similarly, for all candidate web services, their TF-IDF weight vectors are also calculated and denoted as ωj, j=1,2,⋯,N. The above is the content of step 2; its pseudocode can be described by Algorithm 2.Algorithm 1: Explore users’ preferences approximately.
Input:
WSu1, WSu2,…, WSuM: web services used by a user.
r1, r2,…, rM: the rating scores.
a: the threshold.
Output:
P: a set.
1.forj=1 to gdo//assume there are g modules
2.nrservice‐used = count(WSui)
3.forr=rmin to rmaxdo
4.nrservice‐rated = count(WSui)
5.nrservice‐rated∗r
6.end for
7.  CalculateMj according to equation (1)
8.ifMj≥a
9.then add WSui∣WSui∈j to P
10.end if
11.end for
12.return PAlgorithm 2: Calculate TF-IDF weight vectors of web services.
Input:
WSu1, WSu2,…, WSu(M-L): web services in set P.
WS1, WS2,…, WSN: candidate web services.
Output:
ωi: weight vectors of services in set P.
ωj: weight vectors of candidate services.
1. Count (∣WSDL∣)
2.fori=u1 to uM−Ldo
3.forj=1 to ndo//assume there are n words in the corpus
4.iftj∈WSDLi
5.then freq(tj, WSDLi)
6.   Count∣WSDLi∣
7.   Count∣WSDLi:tj∈WSDLi∣
8.   Calculateωi according to equation (4)
9.end if
10.end for
11.end for
12.ωi=ω1,ω2,⋯,ωn
13.Calculate candidate services’ TF-IDF weight vectorsωj
14.returnωi, ωj


### 3.3. Step 3: Predict the Ranking Scores of Candidate Services

In order to evaluate the similarity between two web services, we use the TF-IDF weight vector of web services to calculate their cosine similarity [17] and define the similarity level between two web services as CosSimi,j. The reason that we choose cosine similarity to measure the distance between different services is twofold: (1) cosine similarity is not limited to dimension volume; (2) cosine similarity has higher accuracy and is intuitive enough to describe the similarity calculation. The value of CosSimi,j is calculated in
(5)CosSimi,j=cosωi,ωj=ωi⋅ωjωi×ωj.In equation (5), ∣ωi∣ and ∣ωj∣ is the Euclidean length of the weight vector ωi and ωj. Besides, ωi·ωj is their dot product. Cosine similarity can be used to effectively evaluate the similarity degree between two vectors, so we can also evaluate the similarity between two web services. After that, we calculate CosSimi,j of candidate web services by combining each candidate web service and every web service in set P to get their value of cosine similarity in order.We can get the similarity between the candidate web services and a user’s history web services according to the value ofCosSimi,j, so that we can calculate the ranking score of each candidate web service (defined as Scorej) in
(6)Scorej=λ∑i=1M‐Lri×CosSimi,j.In equation (6), λ is the parameter and ri is users’ rating on history web services. The aim of multiplying users’ rating and the value ofCosSimi,jis to giveCosSimi,ja different weight. After that, we carry on the accumulation, and we can obtain the ranking score of each candidate service. At last, we sort the score and set a threshold “b.” All the candidate web services with a ranking score greater than “b” form a set Y. And the web services in the top-K recommended list are selected from this set. The above is the content of step 3; its pseudocode can be described by Algorithm 3.


### 3.4. Step 4: Create a Diversified Web Service Recommended List

The purpose of setting threshold “b” is to ensure the accuracy of the top-K recommended list, which is usually recommended to the user by selecting the first K services from high value to low value according to Scorej. Although it ensures the high accuracy of the recommendation results, it leads to the decrease of the diversity. Besides, it may cause the problem of overfitting, which is not conducive to exploring the potential preferences of users [18–21]. Therefore, we need a method which can balance accuracy and diversity. Step 4 provides a solution to how to make the recommendations more diverse while ensuring a high accuracy at the same time.First, we set up an index of all candidate web services in the set Y and selectK services according to different index numbers to form multiple recommended lists. Then, we define the diversity of web services in recommended lists as the list-diversity and each recommended list’s list-diversity is calculated in equation (7). Finally, we select the recommended list with the highest list-diversity value as the top-K recommended list to recommend to users.
(7)List‐diversity=1−2NN−1∑i,j∈Y,i≠jCosSimi,j.The list-diversity means the average dissimilarity between each pair of web services in a recommended list. In equation (7), Y represents the set Y and N=∣Y∣. CosSimi,j represents the similarity of every two candidate web services in a list. The above is the content of step 4, its pseudocode can be described by Algorithm 4 (set the length of recommended list is K).Algorithm 3: Predict the ranking scores of candidate services.
Input:
ωi,ωj: weight vectors of services.
ri: the rating scores.
b: the threshold.
Output:
Y: a set.
1.forj=1 to Ndo
2.fori=1 to M−Ldo
3.  CalculateCosSimi,j according to equation (5)
4.ri∗CosSimi,j
5.end for
6. CalculateScorej according to equation (6)
7.ifScorej>b
8.then add WSj to Y
9.end if
10.end for
11.returnYAlgorithm 4: Create a diversified web service recommended list.
Input:
Y: set Y.
K: the length of recommended list
CosSimi,j: the similarity between service i and service j.
Output:
a diversified web service recommended list
1.f=∣Y∣//f denotes the number of web services in the set Y
2. Sort(Y)
3. Create indexes forf web services
4.forj=1 to CK fdo//K<f
5. Form a list withK web services according to different
index numbers
6. Calculate list-diversity according to equation (7)
7.end for
8.return the list with the highest list-diversity value


## 3.1. Step 1: Explore Users’ Preferences Approximately

In step 1, we first make an approximate positioning of users’ preferences according to users’ historical score records. In order to give more effectively personalized service recommendations, we need to figure out what users like and why they like it. In other words, using more effective preference representation methods may make recommendation algorithms exhibit higher performance. In most service recommendation methods, a user’s score on web service can only represent the user’s opinion on a service, but the user’s preferences cannot be fully determined by a score record. However, a user’s historical score records can be used to make an approximate positioning of the user’s preferences. We can use the rating scores of web services to establish correlations with metadata and break the common limitation of expressing preferences with only one score.For example, under the scenario described in Section2, if a user rated 5 for all the web services under the module of military and rated 2 for all the web services under the module of finance, then the recommender system should infer that the user prefers the military module and should recommend more candidate web services about the military than finance.We can establish the correlation between history scores and the information of the metadata module in equation (1), which utilizes score records for web services to calculate a user’s preference degree for each module.
(1)Mj=∑i=rminrmaxri×nrservice‐ratednrservice‐used.In equation (1), Mj represents the degree of a user’s preference for module j. ri represents a user’s historical rating scores for the used web services. nrservice‐rated represents the number of web services which rated ri under the metadata module j, and nrservice‐used represents the number of all the used web services by the user under the metadata module j.We can calculate the user’s preference degree for the modules in equation (1) and make an approximate positioning of the user’s preference. A threshold “a” is set here, and the module with a calculated result greater than “a” is defined as the user’s preference module. For example, in the scenario of Section 2, we set a threshold 3. After calculation, if the modules with a result greater than 3 are military, finance, cars, and shopping, then the top-K recommended list should mainly consist of web services under these modules, which means that the modules below the threshold are automatically filtered out. At last, we put all the web services belonging to the preference modules together to form a set P. The above is the content of step 1, its pseudocode can be described by Algorithm 1.


## 3.2. Step 2: Calculate TF-IDF Weight Vectors of Web Services

The task of step1 in DivMTID is to determine users’ preferences, filtering out the web services under all modules with low history rating scores. It saves a lot of time for the subsequent recommendation algorithm to run. However, step 1 cannot exactly determine what kind of services users like, what characteristics the web services with high scores have, and how to select the best web services from so many candidate services. Step 2 is designed to solve these problems. It is assumed that step 1 filtered outL web services together.As is mentioned, each web service in set P has a corresponding WSDL document, the same as candidate services. Then, all meaningful words in the WSDL documents of all services can form a corpus. After that, a well-known TF-IDF algorithm [8, 15] is used to assess the importance of words in the corpus for each web service. The importance is proportional to the number of times that words appear in the document and inversely proportional to the frequency of words appearing in the corpus. The explanation is as follows.tf represents the word frequency, indicating the frequency of a word appearing in a WSDL document. It can be described in
(2)tftj,WSDLi=freqtj,WSDLiWSDLi.tj represents the j-th word in the corpus and WSDLi represents the WSDL document of the i-th web service. Freqtj,WSDLi represents the number of times that tj appears in the WSDLi document, and ∣WSDLi∣ represents the number of words that appear in the WSDLi document. So we can also get the equation WSDLi=∑jfreqtj,WSDLi.idf represents the inverse document frequency. It is expressed by the ratio of the total number of all WSDL documents and the number of documents containing the word. We can calculate the logarithm of the quotient in
(3)idftj,WSDLi=log2WSDLWSDLi:tj∈WSDLi.∣
WSDL
∣ represents the total number of WSDL documents. And ∣WSDLi:tj∈WSDLi∣represents the total number of documents containing word tj.we use TF-IDF to assess the importance of words in a corpus for a web service. If a word appears with high frequency in a WSDL document of a web service and appears with low frequency in other WSDL documents of services, then we suppose that the word has a high importance and representativeness for this web service, which can be used to classify and distinguish different services.Since WSDL documents are generally short, this paper chooses to give higher weight to theidf value to normalize the inherent bias with
(4)ω=tftj,WSDLi∗idf2tj,WSDLi.The common way to implement TF-IDF is to give the same weight to word frequency and the inverse document frequency. However, this paper gives higher weight toidf in order not only to standardize the inherent deviation of the tf measurement in short documents but also to better exclude the common words that frequently appear in web services in the corpus [16]. In this way, it can improve the classification and differentiation ability among web services and so improve the accuracy of a user’s preferences. ω represents the calculation result. It is the TF-IDF weight of word tj to web services, which means the importance of word tj for web services. Utilizing all the words in the corpus, we calculate the TF-IDF weight of a web service by equation (4) to form the weight vector of a certain web service. We candidate the TF-IDF weight vectors of all web services in the set P, denoted as ωi, i=u1,u2,⋯,uM−L. Similarly, for all candidate web services, their TF-IDF weight vectors are also calculated and denoted as ωj, j=1,2,⋯,N. The above is the content of step 2; its pseudocode can be described by Algorithm 2.Algorithm 1: Explore users’ preferences approximately.
Input:
WSu1, WSu2,…, WSuM: web services used by a user.
r1, r2,…, rM: the rating scores.
a: the threshold.
Output:
P: a set.
1.forj=1 to gdo//assume there are g modules
2.nrservice‐used = count(WSui)
3.forr=rmin to rmaxdo
4.nrservice‐rated = count(WSui)
5.nrservice‐rated∗r
6.end for
7.  CalculateMj according to equation (1)
8.ifMj≥a
9.then add WSui∣WSui∈j to P
10.end if
11.end for
12.return PAlgorithm 2: Calculate TF-IDF weight vectors of web services.
Input:
WSu1, WSu2,…, WSu(M-L): web services in set P.
WS1, WS2,…, WSN: candidate web services.
Output:
ωi: weight vectors of services in set P.
ωj: weight vectors of candidate services.
1. Count (∣WSDL∣)
2.fori=u1 to uM−Ldo
3.forj=1 to ndo//assume there are n words in the corpus
4.iftj∈WSDLi
5.then freq(tj, WSDLi)
6.   Count∣WSDLi∣
7.   Count∣WSDLi:tj∈WSDLi∣
8.   Calculateωi according to equation (4)
9.end if
10.end for
11.end for
12.ωi=ω1,ω2,⋯,ωn
13.Calculate candidate services’ TF-IDF weight vectorsωj
14.returnωi, ωj


## 3.3. Step 3: Predict the Ranking Scores of Candidate Services

In order to evaluate the similarity between two web services, we use the TF-IDF weight vector of web services to calculate their cosine similarity [17] and define the similarity level between two web services as CosSimi,j. The reason that we choose cosine similarity to measure the distance between different services is twofold: (1) cosine similarity is not limited to dimension volume; (2) cosine similarity has higher accuracy and is intuitive enough to describe the similarity calculation. The value of CosSimi,j is calculated in
(5)CosSimi,j=cosωi,ωj=ωi⋅ωjωi×ωj.In equation (5), ∣ωi∣ and ∣ωj∣ is the Euclidean length of the weight vector ωi and ωj. Besides, ωi·ωj is their dot product. Cosine similarity can be used to effectively evaluate the similarity degree between two vectors, so we can also evaluate the similarity between two web services. After that, we calculate CosSimi,j of candidate web services by combining each candidate web service and every web service in set P to get their value of cosine similarity in order.We can get the similarity between the candidate web services and a user’s history web services according to the value ofCosSimi,j, so that we can calculate the ranking score of each candidate web service (defined as Scorej) in
(6)Scorej=λ∑i=1M‐Lri×CosSimi,j.In equation (6), λ is the parameter and ri is users’ rating on history web services. The aim of multiplying users’ rating and the value ofCosSimi,jis to giveCosSimi,ja different weight. After that, we carry on the accumulation, and we can obtain the ranking score of each candidate service. At last, we sort the score and set a threshold “b.” All the candidate web services with a ranking score greater than “b” form a set Y. And the web services in the top-K recommended list are selected from this set. The above is the content of step 3; its pseudocode can be described by Algorithm 3.


## 3.4. Step 4: Create a Diversified Web Service Recommended List

The purpose of setting threshold “b” is to ensure the accuracy of the top-K recommended list, which is usually recommended to the user by selecting the first K services from high value to low value according to Scorej. Although it ensures the high accuracy of the recommendation results, it leads to the decrease of the diversity. Besides, it may cause the problem of overfitting, which is not conducive to exploring the potential preferences of users [18–21]. Therefore, we need a method which can balance accuracy and diversity. Step 4 provides a solution to how to make the recommendations more diverse while ensuring a high accuracy at the same time.First, we set up an index of all candidate web services in the set Y and selectK services according to different index numbers to form multiple recommended lists. Then, we define the diversity of web services in recommended lists as the list-diversity and each recommended list’s list-diversity is calculated in equation (7). Finally, we select the recommended list with the highest list-diversity value as the top-K recommended list to recommend to users.
(7)List‐diversity=1−2NN−1∑i,j∈Y,i≠jCosSimi,j.The list-diversity means the average dissimilarity between each pair of web services in a recommended list. In equation (7), Y represents the set Y and N=∣Y∣. CosSimi,j represents the similarity of every two candidate web services in a list. The above is the content of step 4, its pseudocode can be described by Algorithm 4 (set the length of recommended list is K).Algorithm 3: Predict the ranking scores of candidate services.
Input:
ωi,ωj: weight vectors of services.
ri: the rating scores.
b: the threshold.
Output:
Y: a set.
1.forj=1 to Ndo
2.fori=1 to M−Ldo
3.  CalculateCosSimi,j according to equation (5)
4.ri∗CosSimi,j
5.end for
6. CalculateScorej according to equation (6)
7.ifScorej>b
8.then add WSj to Y
9.end if
10.end for
11.returnYAlgorithm 4: Create a diversified web service recommended list.
Input:
Y: set Y.
K: the length of recommended list
CosSimi,j: the similarity between service i and service j.
Output:
a diversified web service recommended list
1.f=∣Y∣//f denotes the number of web services in the set Y
2. Sort(Y)
3. Create indexes forf web services
4.forj=1 to CK fdo//K<f
5. Form a list withK web services according to different
index numbers
6. Calculate list-diversity according to equation (7)
7.end for
8.return the list with the highest list-diversity value


## 4. Case Study

In order to introduce the specific steps of DivMTID, and also to further illustrate the effectiveness of DivMTID, a case study is provided in this section.Suppose that there are nine existing modules including entertainment, military, sports, life, finance, cars, games, films, and shopping. We assume that there are five different web services under each module and there are ten candidate web services. A user rated the web services he has used (rating values between 1 and 5, no rating value is recorded as null which equals to 0). Table3 is the user’s history rating records. Now, our work is providing the user with a top-K web service recommended list. We set the threshold “a” to 3.Table 3
The user’s history rating records.
Entertainment
Military
Sports
Webu1
Null
2
4
Webu2
2
3
5
Webu3
Null
1
3
Webu4
3
2
5
Webu5
4
1
3
Life
Finance
Cars
Webu1
4
1
Null
Webu2
4
1
4
Webu3
5
Null
3
Webu4
3
5
2
Webu5
3
Null
1
Games
Films
Shopping
Webu1
2
5
1
Webu2
1
3
2
Webu3
1
3
2
Webu4
1
3
3
Webu5
2
5
Null


### 4.1. Step 1: Explore Users’ Preferences Approximately

We use equation (1) to calculate the user’s preference degree for each module and make an approximate positioning of the user’s preference. After the calculation, we get the preference degree values Mj, and the results are shown in Table 4.Table 4
The user’s module preference degree.
Entertainment
Military
Sports
M
j
1.8
1.8
4.0
Life
Finance
Cars
M
j
3.8
1.4
2.0
Games
Films
Shopping
M
j
1.4
3.8
1.6Because we have set the threshold “a” to 3, the modules containing sports, life, and films whose Mj greater than 3 are the user’s approximate preference modules. The web services under these three modules form a set P.


### 4.2. Step 2: Calculate TF-IDF Weight Vectors of Web Services

After approximately exploring the user’s preferences, we calculate the weight vectors of web services utilizing the WSDL documents of all services in the set P and the WSDL documents of all candidate services. Table5 shows the WSDL documents of all web services in the set P, and Table 6 shows the WSDL documents of all candidate services.Table 5
The WSDL documents of web services in set P.
Sports
Life
Films
Webu1
Shooting
Marriage
Ang Lee
Video
Marriage
Ang Lee
Long
Article
Ang Lee
Slow
Long
Article
Webu2
Shooting
Marriage
Hollywood
Video
Picture
Article
Short
Long
Fast
Webu3
Gymnastics
Cooking
Ang Lee
Video
Video
Picture
Short
Long
Fast
Slow
Webu4
Shooting
Cooking
Action movie
Shooting
Cooking
Picture
Article
Cooking
Long
Picture
Webu5
Gymnastics
Cooking
Hollywood
Video
Cooking
Video
Long
Cooking
Short
Slow
Article
FastTable 6
The WSDL documents of candidate web services.
Candidate services
Web1
Ang Lee, article, long
Web2
Cooking, cooking, picture
Web3
Shooting, video, short, fast
Web4
Marriage, video, long, slow
Web5
Diving, diving, picture
Web6
Gymnastics, article, long
Web7
Hollywood, picture
Web8
Hollywood, video, short, fast
Web9
Action movie, article
Web10
Shooting, shooting, article, longA corpus containing all meaningful words from the WSDL documents of all services in the set P and the WSDL documents of all candidate services is made (shooting, gymnastics, diving, marriage, cooking, Ang Lee, Hollywood, action movie, video, article, picture, long, short, fast, and slow). Then, we calculate the weight vector of each web service according to equation (4).The sports module:(8)ωu1→=1.35,0,0,0,0,0,0,0,0.54,0,0,0.44,0,0,1.75,ωu2→=1.35,0,0,0,0,0,0,0,0.54,0,0,0,1.35,1.35,0,ωu3→=0,4.68,0,0,0,0,0,0,0,0,1.69,0,0,0,0,ωu4→=2.69,0,0,0,0,0,0,0,0,0.54,0,0.44,0,0,0,ωu5→=0,2.34,0,0,0,0,0,0,0.54,0,0,0.44,0,0,1.75.The life module:(9)ωu1→=0,0,0,4.68,0,0,0,0,0,0.54,0,0.44,0,0,0,ωu2→=0,0,0,4.68,0,0,0,0,0,0,1.69,0,0,0,0,ωu3→=0,0,0,0,1.75,0,0,0,0.54,0,0,0,1.35,1.35,0,ωu4→=0,0,0,0,5.24,0,0,0,0,0,0.84,0,0,0,0,ωu5→=0,0,0,0,5.24,0,0,0,0,0.54,0,0,0,0,0,The films module:ω
u
1
→
=
0
,
0
,
0
,
0
,
0
,
7.01
,
0
,
0
,
0
,
0.54
,
0
,
0
,
0
,
0
,
0
,ω
u
2
→
=
0
,
0
,
0
,
0
,
0
,
0
,
2.31
,
0
,
0
,
0.72
,
0
,
0.58
,
0
,
0
,
0
,ω
u
3
→
=
0
,
0
,
0
,
0
,
0
,
2.34
,
0
,
0
,
0.54
,
0
,
0
,
0.44
,
0
,
0
,
1.75
,ω
u
4
→
=
0
,
0
,
0
,
0
,
0
,
0
,
0
,
6.64
,
0
,
0
,
1.69
,
0
,
0
,
0
,
0
,ω
u
5
→
=
0
,
0
,
0
,
0
,
0
,
0
,
1.75
,
0
,
0.54
,
0
,
0
,
0
,
1.35
,
1.35
,
0
.The candidate services:(10)ω1→=0,0,0,0,0,3.09,0,0,0,0.72,0,0.58,0,0,0,ω2→=0,0,0,0,4.66,0,0,0,0,0,1.12,0,0,0,0,ω3→=1.35,0,0,0,0,0,0,0,0.54,0,0,0,1.35,1.35,0,ω4→=0,0,0,2.34,0,0,0,0,0.54,0,0,0.44,0,0,1.75,ω5→=0,0,14.36,0,0,0,0,0,0,0,1.12,0,0,0,0,ω6→=0,3.11,0,0,0,0,0,0,0,0.72,0,0.58,0,0,0,ω7→=0,0,0,0,0,0,3.5,0,0,0,1.69,0,0,0,0,ω8→=0,0,0,0,0,0,1.75,0,0.54,0,0,0,1.35,1.35,0,ω9→=0,0,0,0,0,0,0,6.64,0,1.09,0,0,0,0,0,ω10→=2.69,0,0,0,0,0,0,0,0,0.54,0,0.44,0,0,0.


### 4.3. Step 3: Predict the Ranking Scores of Candidate Services

According to equation (5), the cosine similarity of the TF-IDF weight vectors is calculated sequentially for each candidate web service with each historically used web service in the set P, and the CosSimi,j value of each candidate service is obtained. Then, the ranking score of each candidate web service is calculated by equation (6), and it is shown in Table 7.Table 7
The ranking scores of candidate web services.
Web3
Web8
Web4
Web2
Web1
Scorej
15.685
13.166
11.253
9.834
8.311
Web7
Web6
Web10
Web9
Web5
Scorej
7.052
6.234
5.801
3.347
0.275We set the threshold “b” to 8 and make all candidate web services with a ranking score higher than 8 form a set Y. It is shown that the web services which are in set Y contain Web3, Web8, Web4, Web2, and Web1.


### 4.4. Step 4: Create a Diversified Web Service Recommended List

Suppose the value ofK is 3. Then, we need to build a diversified recommended list containing 3 web services for the user. Step 4 establishes an index of all candidate web services in the set Y, and three web services are selected according to different index numbers to form multiple recommended lists. The list-diversity of each recommended list is calculated by equation (7). Finally, the recommended list with the highest list-diversity value is selected as the top-3 recommended list recommended to the user. The results are shown in Table 8.Table 8
The list-diversity and the rank of recommended list.
Recommended list
List-diversity
Rank
Web3, Web8, Web4
0.930
10
Web3, Web8, Web2
0.938
8
Web3, Web8, Web1
0.938
8
Web3, Web4, Web2
0.996
4
Web3, Web4, Web1
0.993
7
Web3, Web2, Web1
1.000
1
Web8, Web4, Web2
0.996
4
Web8, Web4, Web1
0.994
6
Web8, Web2, Web1
1.000
1
Web4, Web2, Web1
0.997
3As shown in Table8, we can see that there are two recommended lists ranked first. If two lists have the same ranking value that indicates the same diversity, we need to consider accuracy to further rank them. In other words, we need to compare the sum of every candidate service’s ranking score through Step 3. And the list that has a higher ranking score sum of candidate services is preferred. As a consequence, we choose the list including Web3, Web2, and Web1 as the top-3 web service recommended list.


## 4.1. Step 1: Explore Users’ Preferences Approximately

We use equation (1) to calculate the user’s preference degree for each module and make an approximate positioning of the user’s preference. After the calculation, we get the preference degree values Mj, and the results are shown in Table 4.Table 4
The user’s module preference degree.
Entertainment
Military
Sports
M
j
1.8
1.8
4.0
Life
Finance
Cars
M
j
3.8
1.4
2.0
Games
Films
Shopping
M
j
1.4
3.8
1.6Because we have set the threshold “a” to 3, the modules containing sports, life, and films whose Mj greater than 3 are the user’s approximate preference modules. The web services under these three modules form a set P.


## 4.2. Step 2: Calculate TF-IDF Weight Vectors of Web Services

After approximately exploring the user’s preferences, we calculate the weight vectors of web services utilizing the WSDL documents of all services in the set P and the WSDL documents of all candidate services. Table5 shows the WSDL documents of all web services in the set P, and Table 6 shows the WSDL documents of all candidate services.Table 5
The WSDL documents of web services in set P.
Sports
Life
Films
Webu1
Shooting
Marriage
Ang Lee
Video
Marriage
Ang Lee
Long
Article
Ang Lee
Slow
Long
Article
Webu2
Shooting
Marriage
Hollywood
Video
Picture
Article
Short
Long
Fast
Webu3
Gymnastics
Cooking
Ang Lee
Video
Video
Picture
Short
Long
Fast
Slow
Webu4
Shooting
Cooking
Action movie
Shooting
Cooking
Picture
Article
Cooking
Long
Picture
Webu5
Gymnastics
Cooking
Hollywood
Video
Cooking
Video
Long
Cooking
Short
Slow
Article
FastTable 6
The WSDL documents of candidate web services.
Candidate services
Web1
Ang Lee, article, long
Web2
Cooking, cooking, picture
Web3
Shooting, video, short, fast
Web4
Marriage, video, long, slow
Web5
Diving, diving, picture
Web6
Gymnastics, article, long
Web7
Hollywood, picture
Web8
Hollywood, video, short, fast
Web9
Action movie, article
Web10
Shooting, shooting, article, longA corpus containing all meaningful words from the WSDL documents of all services in the set P and the WSDL documents of all candidate services is made (shooting, gymnastics, diving, marriage, cooking, Ang Lee, Hollywood, action movie, video, article, picture, long, short, fast, and slow). Then, we calculate the weight vector of each web service according to equation (4).The sports module:(8)ωu1→=1.35,0,0,0,0,0,0,0,0.54,0,0,0.44,0,0,1.75,ωu2→=1.35,0,0,0,0,0,0,0,0.54,0,0,0,1.35,1.35,0,ωu3→=0,4.68,0,0,0,0,0,0,0,0,1.69,0,0,0,0,ωu4→=2.69,0,0,0,0,0,0,0,0,0.54,0,0.44,0,0,0,ωu5→=0,2.34,0,0,0,0,0,0,0.54,0,0,0.44,0,0,1.75.The life module:(9)ωu1→=0,0,0,4.68,0,0,0,0,0,0.54,0,0.44,0,0,0,ωu2→=0,0,0,4.68,0,0,0,0,0,0,1.69,0,0,0,0,ωu3→=0,0,0,0,1.75,0,0,0,0.54,0,0,0,1.35,1.35,0,ωu4→=0,0,0,0,5.24,0,0,0,0,0,0.84,0,0,0,0,ωu5→=0,0,0,0,5.24,0,0,0,0,0.54,0,0,0,0,0,The films module:ω
u
1
→
=
0
,
0
,
0
,
0
,
0
,
7.01
,
0
,
0
,
0
,
0.54
,
0
,
0
,
0
,
0
,
0
,ω
u
2
→
=
0
,
0
,
0
,
0
,
0
,
0
,
2.31
,
0
,
0
,
0.72
,
0
,
0.58
,
0
,
0
,
0
,ω
u
3
→
=
0
,
0
,
0
,
0
,
0
,
2.34
,
0
,
0
,
0.54
,
0
,
0
,
0.44
,
0
,
0
,
1.75
,ω
u
4
→
=
0
,
0
,
0
,
0
,
0
,
0
,
0
,
6.64
,
0
,
0
,
1.69
,
0
,
0
,
0
,
0
,ω
u
5
→
=
0
,
0
,
0
,
0
,
0
,
0
,
1.75
,
0
,
0.54
,
0
,
0
,
0
,
1.35
,
1.35
,
0
.The candidate services:(10)ω1→=0,0,0,0,0,3.09,0,0,0,0.72,0,0.58,0,0,0,ω2→=0,0,0,0,4.66,0,0,0,0,0,1.12,0,0,0,0,ω3→=1.35,0,0,0,0,0,0,0,0.54,0,0,0,1.35,1.35,0,ω4→=0,0,0,2.34,0,0,0,0,0.54,0,0,0.44,0,0,1.75,ω5→=0,0,14.36,0,0,0,0,0,0,0,1.12,0,0,0,0,ω6→=0,3.11,0,0,0,0,0,0,0,0.72,0,0.58,0,0,0,ω7→=0,0,0,0,0,0,3.5,0,0,0,1.69,0,0,0,0,ω8→=0,0,0,0,0,0,1.75,0,0.54,0,0,0,1.35,1.35,0,ω9→=0,0,0,0,0,0,0,6.64,0,1.09,0,0,0,0,0,ω10→=2.69,0,0,0,0,0,0,0,0,0.54,0,0.44,0,0,0.


## 4.3. Step 3: Predict the Ranking Scores of Candidate Services

According to equation (5), the cosine similarity of the TF-IDF weight vectors is calculated sequentially for each candidate web service with each historically used web service in the set P, and the CosSimi,j value of each candidate service is obtained. Then, the ranking score of each candidate web service is calculated by equation (6), and it is shown in Table 7.Table 7
The ranking scores of candidate web services.
Web3
Web8
Web4
Web2
Web1
Scorej
15.685
13.166
11.253
9.834
8.311
Web7
Web6
Web10
Web9
Web5
Scorej
7.052
6.234
5.801
3.347
0.275We set the threshold “b” to 8 and make all candidate web services with a ranking score higher than 8 form a set Y. It is shown that the web services which are in set Y contain Web3, Web8, Web4, Web2, and Web1.


## 4.4. Step 4: Create a Diversified Web Service Recommended List

Suppose the value ofK is 3. Then, we need to build a diversified recommended list containing 3 web services for the user. Step 4 establishes an index of all candidate web services in the set Y, and three web services are selected according to different index numbers to form multiple recommended lists. The list-diversity of each recommended list is calculated by equation (7). Finally, the recommended list with the highest list-diversity value is selected as the top-3 recommended list recommended to the user. The results are shown in Table 8.Table 8
The list-diversity and the rank of recommended list.
Recommended list
List-diversity
Rank
Web3, Web8, Web4
0.930
10
Web3, Web8, Web2
0.938
8
Web3, Web8, Web1
0.938
8
Web3, Web4, Web2
0.996
4
Web3, Web4, Web1
0.993
7
Web3, Web2, Web1
1.000
1
Web8, Web4, Web2
0.996
4
Web8, Web4, Web1
0.994
6
Web8, Web2, Web1
1.000
1
Web4, Web2, Web1
0.997
3As shown in Table8, we can see that there are two recommended lists ranked first. If two lists have the same ranking value that indicates the same diversity, we need to consider accuracy to further rank them. In other words, we need to compare the sum of every candidate service’s ranking score through Step 3. And the list that has a higher ranking score sum of candidate services is preferred. As a consequence, we choose the list including Web3, Web2, and Web1 as the top-3 web service recommended list.


## 5. Conclusions and Future Work

This paper presents a new web service recommendation method called DivMTID. This method first uses users’ history ratings about web services to approximately explore users’ preferences. Second, it uses the TF-IDF algorithm to calculate the weight vectors of each web service. Third, it uses the cosine similarity to calculate the similarity between candidate web services and historical services in order to estimate the ranking scores of candidate services. Finally, list-diversity is used to generate the top-K recommended list. DivMTID takes the accuracy and diversity index of web service recommendation into account and achieves high diversity of recommendation results while ensuring high accuracy. It comprehensively balances the influence of accuracy and diversity on recommendation results, avoiding the appearance of recommendation redundancy and solving the problem of overfitting. DivMTID is an effective, accurate, and diverse service recommendation method, which is worth popularizing and using.However, the specific influence of this method in many aspects of the recommender system is not measured. Therefore, in the future work, we will do more experiments about this method’s influence on each index of the recommender system.In addition, we will take the time and space factors into consideration to improve the algorithm from many aspects, such as privacy [22–25]. We will also further improve the performance and effectiveness of the algorithm [26–28] by combining some new approaches such as Blockchain and Edge Computing [29–32].



---

*Source: 8822992-2020-12-17.xml*